Skip to content

Commit

Permalink
feat: blocks (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Sep 5, 2023
1 parent 810cff6 commit fc7c24c
Show file tree
Hide file tree
Showing 14 changed files with 2,056 additions and 935 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/app-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ cd server
npm install
cd ../ux
npm install
cd ../blocks
npm install
npm run build
cd ..

echo "Ready!"
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ jobs:
npm ci --audit=false --fund=false
npm run build
- name: Build Blocks
working-directory: blocks
run: |
npm ci --audit=false --fund=false
npm run build
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand Down
2 changes: 2 additions & 0 deletions blocks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
70 changes: 70 additions & 0 deletions blocks/block-index/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { LitElement, html, css } from 'lit'
import folderByPath from './folderByPath.graphql'

/**
* An example element.
*
* @fires count-changed - Indicates when the count changes
* @slot - This element has a slot
* @csspart button - The button
*/
export class BlockIndexElement extends LitElement {
static get styles() {
return css`
:host {
display: block;
border: solid 1px gray;
padding: 16px;
max-width: 800px;
}
`;
}

static get properties() {
return {
/**
* The name to say "Hello" to.
* @type {string}
*/
name: {type: String},

/**
* The number of times the button has been clicked.
* @type {number}
*/
count: {type: Number},
};
}

constructor() {
super();
this.name = 'World';
this.count = 0;
}

render() {
return html`
<h1>${this.sayHello(this.name)}!</h1>
<button @click=${this._onClick} part="button">
Click Count: ${this.count}
</button>
<slot></slot>
`;
}

_onClick() {
this.count++;
this.dispatchEvent(new CustomEvent('count-changed'));
}

/**
* Formats a greeting
* @param name {string} The name to say "Hello" to
* @returns {string} A greeting directed at `name`
*/
sayHello(name) {
return `Hello, ${name}`;
}
}

window.customElements.define('block-index', BlockIndexElement);
6 changes: 6 additions & 0 deletions blocks/block-index/folderByPath.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
query folderByPath($siteId: UUID!, $locale: String!, $path: String!) {
folderByPath(siteId: $siteId, locale: $locale, path: $path) {
id
title
}
}
Loading

0 comments on commit fc7c24c

Please sign in to comment.