forked from element-plus/element-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add story book for component previewing - Add custom preview method for renderering Vue3 Component - Modify scripts for storybook boilerplate - Add documentation in README for booting and previewing project feat/storybook - Add story book for component previewing - Add custom preview method for renderering Vue3 Component - Modify scripts for storybook boilerplate - Add documentation in README for booting and previewing project
- Loading branch information
Showing
10 changed files
with
5,372 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ indent_size = 2 | |
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
quote_type = single |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var VueLoaderPlugin = require('vue-loader/dist/plugin'); | ||
|
||
function webpack(config) { | ||
return { | ||
...config, | ||
plugins: [...config.plugins, new VueLoaderPlugin.default()], | ||
module: { | ||
...config.module, | ||
rules: [ | ||
...config.module.rules, | ||
{ | ||
test: /\.vue$/, | ||
loader: require.resolve('vue-loader'), | ||
options: {}, | ||
}, | ||
{ | ||
test: /\.(ts|tsx)$/, | ||
use: [ | ||
{ | ||
loader: require.resolve('ts-loader'), | ||
options: { | ||
transpileOnly: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
...config.resolve, | ||
extensions: [...config.resolve.extensions, '.vue', '.ts'], | ||
alias: { | ||
...config.resolve.alias, | ||
vue$: require.resolve('vue/dist/vue.esm-bundler.js'), | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
exports.webpack = webpack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
stories: ['../packages/**/*.stories.[tj]s'], | ||
presets: [path.resolve(__dirname, './custom-presets')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { addDecorator } from "@storybook/html"; | ||
import { createApp } from "vue"; | ||
import "../src/style/[email protected]"; | ||
/** | ||
* Wraps a story into a Vue Element | ||
* @param {JSX.Element} template - Story templates | ||
* @param {VueElement} | ||
*/ | ||
const Wrapper = (template) => { | ||
return { | ||
data() { | ||
return {}; | ||
}, | ||
template, | ||
}; | ||
}; | ||
|
||
/** | ||
* Custom Addon for previewing ElementPlus component in Vue3 | ||
* Due to lacking of support for Vue3, the rendering method has to be made by ourself | ||
* This method takes a template string as parameter returns a HTMLElement which will be inserted to the iframe root node by `@StoryBook` | ||
* @param {Story} content | ||
* @return {HTMLElement} | ||
*/ | ||
function CustomDecorator(content) { | ||
const { template, installer } = content(); | ||
const app = createApp(Wrapper(template)); | ||
installer(app); | ||
const entry = document.createElement("div"); | ||
entry.className = "element-plus-previewer"; | ||
app.mount(entry); | ||
return entry; | ||
} | ||
|
||
addDecorator(CustomDecorator); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
Element-Plus | ||
Element-Plus | ||
|
||
## Bootstrap project | ||
With command | ||
```bash | ||
$ yarn bs | ||
``` | ||
the project will install all dependencies and run `lerna bootstrap` to initialize the project | ||
|
||
## Storybook preview | ||
With command | ||
```bash | ||
$ yarn sb | ||
``` | ||
the project will launch `@storybook` client for you to preview all existing component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ElButton from './index'; | ||
|
||
export default { | ||
title: 'Button', | ||
}; | ||
|
||
export const NormalButton = () => { | ||
return { template: '<el-button>With Text</el-button>', installer: ElButton }; | ||
}; | ||
export const ButtonTwo = () => { | ||
return { template: '<el-button>button two</el-button>', installer: ElButton }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.