This is a barebones repo that provides one demo WebC component for use by other projects.
See the live demo of an external site that uses this project's component, installed via NPM.
You probably don't want to use this for real, but if you did this is what you'd do.
First, install this repo as a package:
npm install ashur/demo-shared-webc-components#semver:^v0.1.0
Note — It feels a little silly to publish an entire package to NPM just for a quick demo, so this is the syntax for installing from a GitHub repo.
If it were published to NPM, the install command might look like the more traditional:
npm install @aaashur/demo-shared-webc-components
Next, drop this snippet into your WebC markup:
<confetti-button
webc:import="npm:@aaashur/demo-shared-webc-components">
</confetti-button>
Note — Even though we installed from GitHub, the package is installed at
./node_modules/@aaashur/demo-shared-webc-components
(because that's what I called it inpackage.json
) so that's how it should be referenced by the WebC import.
If you want to be fancy and set a custom button label, use the text
prop:
<confetti-button
text="It’s Confetti Time"
webc:import="npm:@aaashur/demo-shared-webc-components">
</confetti-button>