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
dist
*.local
lerna-debug.json

View File

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

View File

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

View File

@ -1,8 +1,5 @@
import ElButton from '../index';
export default {
title: 'Button',
component: ElButton,
};
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"
}
}