mirror of
https://github.com/tree-company/sprinkles-js.git
synced 2025-10-24 05:59:14 +00:00
No description
Bumps [stylelint](https://github.com/stylelint/stylelint) from 16.24.0 to 16.25.0. - [Release notes](https://github.com/stylelint/stylelint/releases) - [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md) - [Commits](https://github.com/stylelint/stylelint/compare/16.24.0...16.25.0) --- updated-dependencies: - dependency-name: stylelint dependency-version: 16.25.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|---|---|---|
| .github | ||
| src | ||
| .gitignore | ||
| CHANGELOG.md | ||
| eslint.config.js | ||
| index.html | ||
| LICENSE | ||
| logo_tree.png | ||
| package.json | ||
| README.md | ||
| vite.config.js | ||
| yarn.lock | ||
Sprinkles
Sprinkles is a small library to add small amounts of javascript to your html.
We try to simplify working with custom elements by:
- Reducing the amount of boilerplate you have to write to add and remove event listeners
- Providing a convention for referencing nodes within your element
This approach takes inspiration from AlpineJS and Stimulus, but is fully build around custom elements.
Using the library
Build your own elements
You can easily build your own custom element on top of SprinklesElement. A simple hello world:
import { SprinklesElement } from "sprinkles-js";
class HelloWorldElement extends SprinklesElement {
static tagName = "hello-world";
static events = {
click: "greet"
}
greet(event) {
console.log("Got click event: ", event);
alert("Hello world!")
}
}
HelloWorldElement.register();
<hello-world></hello-world>
Included components
In addition to the abstract sprinkles element, we also include some basic elements that you can use.
ClickableCard
A card that can be clicked anywhere to follow the link inside it:
import { ClickableCard } from "sprinkles-js";
ClickableCard.register();
<clickable-card>
<p>Some text</p>
</p>
<a href="https://example.com" data-clickable-card-ref="link">A link</a>
<button>A button that doesn't trigger</button>
</clickable-card>
This library was extracted from various projects at Tree company.
