mirror of https://github.com/requarks/wiki
parent
810cff6012
commit
fc7c24c63f
@ -0,0 +1,2 @@
|
||||
dist
|
||||
node_modules
|
@ -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);
|
@ -0,0 +1,6 @@
|
||||
query folderByPath($siteId: UUID!, $locale: String!, $path: String!) {
|
||||
folderByPath(siteId: $siteId, locale: $locale, path: $path) {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "blocks",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "rollup -c"
|
||||
},
|
||||
"private": true,
|
||||
"author": "Nicolas Giard",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"lit": "^2.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-graphql": "^2.0.3",
|
||||
"@rollup/plugin-node-resolve": "^15.2.1",
|
||||
"@rollup/plugin-terser": "^0.4.3",
|
||||
"glob": "^10.3.4",
|
||||
"rollup": "^2.79.1",
|
||||
"rollup-plugin-summary": "^2.0.0"
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import summary from 'rollup-plugin-summary'
|
||||
import terser from '@rollup/plugin-terser'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import graphql from '@rollup/plugin-graphql'
|
||||
|
||||
import * as glob from 'glob'
|
||||
|
||||
export default {
|
||||
input: Object.fromEntries(
|
||||
glob.sync('@(block-*)/component.js', {
|
||||
ignore: [
|
||||
'dist/**',
|
||||
'node_modules/**'
|
||||
]
|
||||
}).map(file => {
|
||||
const fileParts = file.split('/')
|
||||
return [
|
||||
fileParts[0],
|
||||
file
|
||||
]
|
||||
})
|
||||
),
|
||||
output: {
|
||||
dir: 'dist',
|
||||
format: 'es',
|
||||
globals: {
|
||||
APOLLO_CLIENT: 'APOLLO_CLIENT'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
resolve(),
|
||||
graphql(),
|
||||
terser({
|
||||
ecma: 2017,
|
||||
module: true,
|
||||
warnings: true
|
||||
}),
|
||||
summary()
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue