feat: add global components registry

This commit is contained in:
Herrington Darkholme 2020-07-25 12:25:38 +08:00
parent 2739b514da
commit 00d0608d52
7 changed files with 47 additions and 13 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ node_modules
.DS_Store .DS_Store
dist dist
*.local *.local
lerna-debug.json

View File

@ -1,6 +1,8 @@
import { addDecorator } from '@storybook/html'; import { addDecorator } from '@storybook/html';
import { createApp } from 'vue'; import { createApp } from 'vue';
import '../src/style/element-ui@2.13.2.css'; import '../src/style/element-ui@2.13.2.css';
import install from '../packages/element-plus'
/** /**
* Wraps a story into a Vue Element * Wraps a story into a Vue Element
* @param {JSX.Element} template - Story templates * @param {JSX.Element} template - Story templates
@ -27,13 +29,7 @@ function CustomDecorator(content, context) {
const app = typeof templateOrComponent === 'string' const app = typeof templateOrComponent === 'string'
? createApp(Wrapper(templateOrComponent)) ? createApp(Wrapper(templateOrComponent))
: createApp(templateOrComponent) : createApp(templateOrComponent)
install(app)
const installers = context?.parameters?.component
if (Array.isArray(installers)) {
installers.forEach(installer => installer(app))
} else {
installers?.(app)
}
const entry = document.createElement('div'); const entry = document.createElement('div');
entry.className = 'element-plus-previewer'; entry.className = 'element-plus-previewer';
app.mount(entry); app.mount(entry);

View File

@ -1,10 +1,7 @@
import Basic from './basic.vue' import Basic from './basic.vue'
import ElBadge from '../index'
import ElButton from '@element-plus/button'
export default { export default {
title: "Badge", title: "Badge",
component: [ElButton, ElBadge]
} }
export const BasicUsage = () => Basic export const BasicUsage = () => Basic

View File

@ -1,8 +1,5 @@
import ElButton from '../index';
export default { export default {
title: 'Button', title: 'Button',
component: ElButton,
}; };
export const NormalButton = () => '<el-button>With Text</el-button>' export const NormalButton = () => '<el-button>With Text</el-button>'

View File

@ -0,0 +1,11 @@
# `element-plus`
> TODO: description
## Usage
```
const elementPlus = require('element-plus');
// TODO: DEMONSTRATE API
```

View File

@ -0,0 +1,12 @@
import type { App } from 'vue'
import ElButton from '@element-plus/button'
import ElBadge from '@element-plus/badge'
export {
ElButton, ElBadge,
}
export default function install(app: App) {
ElButton(app)
ElBadge(app)
}

View File

@ -0,0 +1,20 @@
{
"name": "element-plus",
"version": "0.0.1",
"description": "> TODO: description",
"author": "Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>",
"homepage": "https://github.com/element-plus/element-plus#readme",
"license": "ISC",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/element-plus/element-plus.git"
},
"bugs": {
"url": "https://github.com/element-plus/element-plus/issues"
},
"dependencies": {
"@element-plus/badge": "^0.0.0",
"@element-plus/button": "^0.0.0"
}
}