1.0.0-alpha.35 • Published 11 months ago

@muban/muban v1.0.0-alpha.35

Weekly downloads
15
License
MIT
Repository
github
Last release
11 months ago

Muban

Please check the full documentation

Getting started

Installing

Add muban to your project:

npm i @muban/muban
yarn add @muban/muban

Simple component

Create your component:

import { defineComponent, bind, ref } from '@muban/muban';

const MyComponent = defineComponent({
  name: 'my-component',
  setup({ props, refs }) {
    const content = ref('Hello World');
    return [
      bind(refs.self, { text: content}),
    ];
  }
});

Make sure to have the following HTML on the page:

<html>
  ...
  <body>
    <div data-component="my-component">Hello</div>
  </body>
</html>

Then init your component:

import { createApp } from '@muban/muban';

createApp(MyComponent).mount(document.body);

Your page should now display Hello World if your component is correctly running.

Dev template

Create our template:

import { html } from '@muban/template';

type MyComponentProps = {
  welcomeText: string;
};

function myComponentTemplate({ welcomeText }: MyComponentProps) {
  return html`<div data-component="my-component">${welcomeText}</div>`;
}

Make sure to have the following HTML on the page:

<html>
  ...
  <body>
    <div id="app">
      <div data-component="my-component">Hello</div>
    </div>
  </body>
</html>

Render your template:

import { createApp } from '@muban/muban';

const appRoot = document.getElementById('app');
const app = createApp(MyComponent);
app.mount(appRoot, myComponentTemplate, { welcomeText: 'Hello' });

Using Storybook

Add @muban/storybook to your project:

npm i -D @muban/storybook
yarn add @muban/storybook

Add these two scripts in your package.json

{
  "scripts": {
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook -o ./dist/storybook"  
  }
}

Create your .storybook/main.js with this content:

module.exports = {
  stories: [
    '../src/**/*.stories.mdx',
    '../src/**/*.stories.@(js|ts)'
  ],
  addons: [
    '@storybook/addon-essentials',
  ]
}

Create your story file:

import type { Story } from '@muban/storybook';

export default {
  title: 'MyComponent',
  argTypes: {
    welcomeText: { control: 'text' },
  },
};

export const Default: Story<MyComponentProps> = {
  render() {
    return {
      template: myComponentTemplate,
      component: MyComponent,
    }
  },
  args: {
    welcomeText: 'Hello',
  }
}

Run storybook:

npm run storybook
yarn storybook

Contributing

Please read the CONTRIBUTING.md for more information. Your help is much appreciated!

1.0.0-dev.d15c406

11 months ago

1.0.0-dev.f17c7f4

11 months ago

1.0.0-dev.c9b0c65

12 months ago

1.0.0-alpha.35

2 years ago

1.0.0-alpha.34

2 years ago

1.0.0-alpha.33

2 years ago

1.0.0-alpha.30

2 years ago

1.0.0-alpha.32

2 years ago

1.0.0-alpha.31

2 years ago

1.0.0-alpha.29

2 years ago

1.0.0-alpha.28

2 years ago

1.0.0-alpha.27

3 years ago

1.0.0-alpha.26

3 years ago

1.0.0-alpha.25

3 years ago

1.0.0-alpha.23

3 years ago

1.0.0-alpha.22

3 years ago

1.0.0-alpha.24

3 years ago

1.0.0-alpha.21

3 years ago

1.0.0-alpha.20

3 years ago

1.0.0-alpha.19

3 years ago

1.0.0-alpha.18

3 years ago

1.0.0-alpha.16

3 years ago

1.0.0-alpha.15

3 years ago

1.0.0-alpha.17

3 years ago

1.0.0-alpha.14

3 years ago

1.0.0-alpha.13

3 years ago

1.0.0-alpha.12

3 years ago

1.0.0-alpha.11

3 years ago

1.0.0-alpha.10

3 years ago

1.0.0-alpha.9

3 years ago

1.0.0-alpha.8

3 years ago

1.0.0-alpha.7

3 years ago

1.0.0-alpha.6

3 years ago

1.0.0-alpha.5

3 years ago

1.0.0-alpha.4

3 years ago

1.0.0-alpha.3

3 years ago

1.0.0-alpha.2

3 years ago

1.0.0-alpha.1

3 years ago