Last active
May 12, 2023 08:41
-
-
Save MarkoZabcic/10a1c92904fbaa02fe59185903e74f26 to your computer and use it in GitHub Desktop.
Web component generator template files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApplicationElement, html } from '@effectivastudio/lit-components'; | |
import translations from './translations.js'; | |
import style from './style.lit.css'; | |
/** | |
* TODO: Description | |
* | |
* @prop exampleProp - TODO: description | |
* | |
* @slot default - TODO: description | |
* @slot namedSlot - TODO: description | |
*/ | |
export default class GalleryItem extends ApplicationElement { | |
static styles = [ApplicationElement.styles, style]; | |
static properties = { | |
exampleProp: { type: String }, | |
}; | |
constructor() { | |
super(); | |
// this.exampleProp = 0; | |
} | |
/** @internal */ | |
static translations = translations; | |
render() { | |
return html`Hello from xs-gallery-item component!`; | |
} | |
} | |
GalleryItem.registerTagName('xs-gallery-item'); | |
customElements.get('xs-gallery-item') || | |
customElements.define('xs-gallery-item', GalleryItem); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webComponentAutoConfig from "../../.storybook/web_component_helpers.js"; | |
import "./element.js"; | |
const config = webComponentAutoConfig("xs-gallery-item"); | |
export default { | |
title: "Generated/GalleryItem", | |
...config, | |
parameters: { | |
// layout: "padded", | |
}, | |
}; | |
export const ADemo = { | |
args: { | |
exampleProp: 'Hello', | |
}, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fixture, assert, html } from "@open-wc/testing"; | |
import GalleryItem from "./element.js"; | |
describe("xs-gallery-item", () => { | |
it("initialize", async () => { | |
const element = await fixture(html`<xs-gallery-item></xs-gallery-item>`); | |
assert.instanceOf(element, GalleryItem); | |
}); | |
it("default render", async () => { | |
const element = await fixture(html`<xs-gallery-item></xs-gallery-item>`); | |
assert.shadowDom.equal( | |
element, | |
` | |
Hello from xs-gallery-item component! | |
` | |
); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:host { | |
display: block; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
en: { | |
exampleProp: 'Example prop' | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment