Skip to content
/ muser Public

A Canvas Componentization Framework to Help You Build Complex UI.

Notifications You must be signed in to change notification settings

ymssx/muser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
yami
Dec 31, 2024
367e48b · Dec 31, 2024
Dec 30, 2024
Feb 28, 2022
Mar 10, 2022
Dec 31, 2024
Nov 26, 2021
Mar 4, 2022
Jul 13, 2021
Nov 14, 2023
Apr 28, 2022
Nov 14, 2023
Nov 13, 2023
Nov 14, 2023
Mar 31, 2022
Jul 14, 2021
Jul 14, 2021
Feb 7, 2023
Mar 4, 2022
Apr 28, 2022
Mar 4, 2022
Apr 28, 2022

Repository files navigation

Muser

中文

A Canvas Componentization Framework to Help You Build Complex UI.

  • Componentization
  • High Performance
  • Easy to Use

This repo is still under development. If you encounter any issues, please feel free to contact me. Additionally, you are welcome to participate in the development together.

Install

npm install muser

or

yarn add muser

Usage

import { Element, useElement, Brush } from 'muser';
import ChildrenElement from 'src/components/children-element';

export default class App extends Element<{ value: string }> {
  state = { width: 10, color: 'green' };

  render({ state, props }: App) {
    const child = useElement(ChildrenElement, {
      width: 100,
      height: 100,
      key: 'key-of-child-element',
    });

    // re-render when 'width' or 'value' or 'color' was changed
    return ({ rect }: Brush) => {
      const { width, color } = state;
      const { value } = props;

      rect([0, 0, width, width], { fillStyle: color });

      child({ value })
        .paste({  x: 0, y: 0 });
    };
  }
}

const app = new App({ width: 100, height: 100 });
app.init({ value: 'hello world!' });

Document

See Document

About

A Canvas Componentization Framework to Help You Build Complex UI.

Topics

Resources

Stars

Watchers

Forks