Created
July 22, 2025 16:15
-
-
Save JLarky/472efbe7d6d3a366f0fecb7c582c03af to your computer and use it in GitHub Desktop.
lift-html solid counter
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 { liftHtml } from '@lift-html/core'; | |
import html from "solid-js/html"; | |
import { createSignal } from "solid-js"; | |
import { render } from "solid-js/web"; | |
const css = /*css*/ ` | |
* { font-size: 200%; } | |
span { | |
width: 4rem; | |
display: inline-block; | |
text-align: center; | |
} | |
button { | |
width: 4rem; height: 4rem; | |
border: none; | |
border-radius: 10px; | |
background-color: seagreen; | |
color: white; | |
outline: none; | |
cursor: pointer; | |
} | |
` | |
liftHtml('my-counter', { | |
init() { | |
const [count, setCount] = createSignal(0); | |
const App = () => html` | |
<style>${css}</style> | |
<button onClick=${() => setCount(count() - 1)}>-</button> | |
<span>${count}</span> | |
<button onClick=${() => setCount(count() + 1)}>+</button> | |
` | |
render(App, this.shadowRoot || this.attachShadow( {mode: 'open' })); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment