Skip to content
This repository was archived by the owner on Nov 18, 2023. It is now read-only.
/ r-html Public archive

Tagged templates framework

License

Notifications You must be signed in to change notification settings

dineug/r-html

Repository files navigation

r-html - Tagged templates framework

Getting Started

Installation

npm install @dineug/r-html
import {
  css,
  defineCustomElement,
  FC,
  html,
  observable,
  render,
} from '@dineug/r-html';

const incrementBtn = css`
  color: green;
`;
const decrementBtn = css`
  color: red;
`;

const Counter: FC = () => {
  const state = observable({ count: 0 });

  return () => html`
    <div>Counter: ${state.count}</div>
    <button class=${incrementBtn} @click=${() => state.count++}>
      Increment
    </button>
    <button class=${decrementBtn} @click=${() => state.count--}>
      Decrement
    </button>
  `;
};

const App: FC<{}, HTMLElement> = () => {
  return () => html`<${Counter} />`;
};

defineCustomElement('my-app', {
  render: App,
});

render(document.body, html`<my-app></my-app>`);

About

Tagged templates framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages