@muban/muban
| Install | |
|---|---|
npm install @muban/muban |
|
| Latest Version: | 1.0.0-alpha.35 |
| License: | MIT |
| Last Updated: | Jun 15, 2023 |
| Links: | GitHub · npm |
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!
Related Packages
Lower level utilities for compiling Vue single file components
Storybook Vue 3 renderer: Develop, document, and test UI components in isolation
Version History
Pre-releases (54)
| Version | Released | License |
|---|---|---|
| 1.0.0-alpha.35 | MIT | |
| 1.0.0-alpha.34 | MIT | |
| 1.0.0-alpha.33 | MIT | |
| 1.0.0-alpha.32 | MIT | |
| 1.0.0-alpha.31 | MIT | |
| 1.0.0-alpha.30 | MIT | |
| 1.0.0-alpha.29 | MIT | |
| 1.0.0-alpha.28 | MIT | |
| 1.0.0-alpha.27 | MIT | |
| 1.0.0-alpha.26 | MIT | |
| 1.0.0-alpha.25 | MIT | |
| 1.0.0-alpha.23 | MIT | |
| 1.0.0-alpha.22 | MIT | |
| 1.0.0-alpha.21 | MIT | |
| 1.0.0-alpha.20 | MIT | |
| 1.0.0-alpha.19 | MIT | |
| 1.0.0-alpha.18 | MIT | |
| 1.0.0-alpha.17 | MIT | |
| 1.0.0-alpha.16 | MIT | |
| 1.0.0-alpha.15 | MIT | |
| 1.0.0-alpha.14 | MIT | |
| 1.0.0-alpha.13 | MIT | |
| 1.0.0-alpha.12 | MIT | |
| 1.0.0-alpha.11 | MIT | |
| 1.0.0-alpha.10 | MIT | |
| 1.0.0-alpha.9 | MIT | |
| 1.0.0-alpha.8 | MIT | |
| 1.0.0-alpha.7 | MIT | |
| 1.0.0-alpha.6 | MIT | |
| 1.0.0-alpha.5 | MIT |
Showing the latest 30 of 54. See every release on npm