From 00d0608d5270d7e2b0f051bb766e84baea599ed6 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com> Date: Sat, 25 Jul 2020 12:25:38 +0800 Subject: [PATCH] feat: add global components registry --- .gitignore | 1 + .storybook/preview.js | 10 +++------- packages/badge/doc/index.stories.ts | 3 --- packages/button/doc/index.stories.ts | 3 --- packages/element-plus/README.md | 11 +++++++++++ packages/element-plus/index.ts | 12 ++++++++++++ packages/element-plus/package.json | 20 ++++++++++++++++++++ 7 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 packages/element-plus/README.md create mode 100644 packages/element-plus/index.ts create mode 100644 packages/element-plus/package.json diff --git a/.gitignore b/.gitignore index 2c5b3c96f1..c2544a9155 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .DS_Store dist *.local +lerna-debug.json diff --git a/.storybook/preview.js b/.storybook/preview.js index 8a08259bf8..62f89441ec 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -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); diff --git a/packages/badge/doc/index.stories.ts b/packages/badge/doc/index.stories.ts index bc9d758ebe..a2cdcf529b 100644 --- a/packages/badge/doc/index.stories.ts +++ b/packages/badge/doc/index.stories.ts @@ -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 diff --git a/packages/button/doc/index.stories.ts b/packages/button/doc/index.stories.ts index 92d9ecbc71..45aee5c804 100644 --- a/packages/button/doc/index.stories.ts +++ b/packages/button/doc/index.stories.ts @@ -1,8 +1,5 @@ -import ElButton from '../index'; - export default { title: 'Button', - component: ElButton, }; export const NormalButton = () => 'With Text' diff --git a/packages/element-plus/README.md b/packages/element-plus/README.md new file mode 100644 index 0000000000..cd40fec2ed --- /dev/null +++ b/packages/element-plus/README.md @@ -0,0 +1,11 @@ +# `element-plus` + +> TODO: description + +## Usage + +``` +const elementPlus = require('element-plus'); + +// TODO: DEMONSTRATE API +``` diff --git a/packages/element-plus/index.ts b/packages/element-plus/index.ts new file mode 100644 index 0000000000..2cd9fb24ec --- /dev/null +++ b/packages/element-plus/index.ts @@ -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) +} diff --git a/packages/element-plus/package.json b/packages/element-plus/package.json new file mode 100644 index 0000000000..23fffa7e5e --- /dev/null +++ b/packages/element-plus/package.json @@ -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" + } +}