Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.

Commit ec95c12

Browse files
committed
Update documentation
- remove addon-info until it support Vue - generated readme section for Installation - generated readme section for Extending component - more feature explanation - more template usage explanation
1 parent e1cb1a3 commit ec95c12

File tree

4 files changed

+144
-44
lines changed

4 files changed

+144
-44
lines changed

README.md

Lines changed: 74 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,95 @@
11
# vue-authoring-template
22
<!-- [![CircleCI](https://circleci.com/gh/DrSensor/vue-authoring-template.svg?style=shield)](https://circleci.com/gh/DrSensor/vue-authoring-template) -->
3-
![minimal config](https://img.shields.io/badge/config-minimal-grey.svg?maxAge=2592000&style=flat-square)
4-
![circleci support](https://img.shields.io/badge/circleci-support-blue.svg?maxAge=2592000&style=flat-square)
5-
![vue 2.x](https://img.shields.io/badge/vue-2.x-4fc08d.svg?maxAge=2592000&style=flat-square)
6-
![storyboard 3.x](https://img.shields.io/badge/storybook-3.x-E91E63.svg?maxAge=2592000&style=flat-square)
3+
<sub>Click one of this badge for more info</sub>
4+
5+
[![minimal config](https://img.shields.io/badge/config-minimal-grey.svg?maxAge=2592000&style=flat-square)](https://poi.js.org)
6+
[![circleci support](https://img.shields.io/badge/circleci-support-blue.svg?maxAge=2592000&style=flat-square)](https://circleci.com/docs/1.0/npm-continuous-deployment/)
7+
[![surge support](https://img.shields.io/badge/deploy_to-surge-63c299.svg?maxAge=2592000&style=flat-square)](https://surge.sh/help/integrating-with-circleci)
8+
[![vue 2.x](https://img.shields.io/badge/vue-2.x-4fc08d.svg?maxAge=2592000&style=flat-square)](https://vuejs.org/)
9+
[![storyboard 3.x](https://img.shields.io/badge/storybook-3.x-E91E63.svg?maxAge=2592000&style=flat-square)](https://storybook.js.org/)
710
[![donate](https://img.shields.io/badge/donate-$-yellowgreen.svg?maxAge=2592000&style=flat-square)](https://github.com/DrSensor/vue-authoring-template/blob/master/DONATE.md)
811

12+
---
913
This template is to help authoring Vue component with it's use case in story-scenario (storybook) format.
1014

1115
![](./screenplay.gif)
1216

13-
Authoring component and publish it to `npm` for later use can help reduce complexity <sup><sup><sup><sup><sup>by delegating the work of finding bug and adding feature</sup></sup></sup></sup></sup> of big/long-running project <sub><sub><sub><sub><sub>to the community</sub></sub></sub></sub></sub>
17+
> In case you need to convince your Lead Dev to give you permission open-sourcing your work :
18+
19+
"Authoring component and publish it to `npm` for later use can help reduce complexity <sup><sup><sup><sup><sup>by delegating the work of finding bug and adding feature</sup></sup></sup></sup></sup> of big/long-running project <sub><sub><sub><sub><sub>to the community</sub></sub></sub></sub></sub>"
20+
1421
## Motivation
15-
1. There is a time when developer involved in a project then build component to solve specific problem 😎.
16-
2. One day this developer happen to do the same thing again in different project with slight alteration 😏.
17-
3. Then doing it again, and again, and again 😫.
18-
4. Now this developer have build many component with the same topic 😂.
19-
5. So, why not publish it as a single component with that one topic in mind to [`npm`](https://www.npmjs.com/)? 😲
20-
6. However, the component must be showcased in [mvce](https://stackoverflow.com/help/mcve) style to make it easy to understand and maintainable 😖.
21-
7. As the time passed, he/she is to lazy to do that because no template/config/cli/whatever for authoring the component in that way :poop:.
22+
23+
1. There is a time when developer involved in a project then build component to solve specific problem 😎
24+
1. One day this developer happen to do the same thing again in different project with slight alteration 😏
25+
1. Then doing it again, and again, and again 😫
26+
1. Now this developer have build many component with the same topic 😂
27+
1. So, why not publish it as a single component with that one topic in mind to [`npm`](https://www.npmjs.com/)? 😲
28+
1. However, the component must be showcased in [mvce](https://stackoverflow.com/help/mcve) style to make it easy to understand and maintainable 😖
29+
1. As the time passed, he/she is to lazy to do that because no template/config/cli/whatever for authoring the component in that way :poop:
30+
31+
## Features
32+
33+
- Support `vue init` workflow
34+
- Minimal configuration. Thanks to [poi](https://poi.js.org)
35+
- Write your storybook `story-scenario` (a.k.a *use case*) in `.vue` **single-file-component format**, not `.js` or `.jsx`
36+
- Option to generate [circleci](https:circleci.com) config to:
37+
- publish vue component to `npm` and `unpkg` <sub>(need to `git push --tags`)</sub>
38+
- deploy storybook page to [surge.sh](https://surge.sh)
39+
- evaluate pull-requests and temporarily deploy storybook page to `<name><#PR_number>.surge.sh` <sub>(auto teardown when PR is merged)</sub>
40+
- Choose pre-installed and configured storybook addon:
41+
- [knobs](https://github.com/storybooks/storybook/tree/master/addons/knobs)
42+
- [actions](https://github.com/storybooks/storybook/tree/master/addons/actions)
43+
- docs related addon:
44+
- [readme](https://github.com/tuchk4/storybook-readme)
45+
- [notes](https://github.com/storybooks/storybook/tree/master/addons/notes)
46+
- Order the story and scenario *alphabetically* or manually re-order using `Array|Object` in `src/stories/config.js`
47+
- Auto generate [`README.md`](./template/README.md)
48+
- Custom blocks (experimental, looking for feedback)
2249

2350
## Usage
51+
2452
```bash
2553
vue init DrSensor/vue-authoring-template
2654
```
27-
After that,
2855

29-
- to build vue component use
30-
```
31-
[npm|yarn] build:component
56+
After that, you can:
57+
58+
- start in development mode
59+
60+
```bash
61+
[npm|yarn] dev
3262
```
33-
- to build the storybook use
63+
64+
- deploy storybook page directly to http://surge.sh
65+
66+
```bash
67+
[npm|yarn] run deploy
3468
```
35-
[npm|yarn] build:storybook
69+
70+
- publish component directly to http://npmjs.com
71+
72+
```bash
73+
# see https://docs.npmjs.com/getting-started/semantic-versioning#semver-for-publishers
74+
npm version [patch|minor|major]
75+
npm publish
3676
```
37-
- to start it in development mode use
77+
78+
- build vue component
79+
80+
```bash
81+
[npm|yarn] build:component # as CJS module, the output will be in dist/
82+
[npm|yarn] build:component:umd # as UMD module, the output will be in umd/
3883
```
39-
[npm|yarn] dev
84+
85+
- build the storybook page
86+
87+
```bash
88+
[npm|yarn] build:storybook # the output will be in .storybook/dist/
4089
```
4190

4291
## Project Structure
92+
4393
```markdown
4494
.
4595
├── package.json // choose and configure the component you want to package in here (still need to edit `scripts: {}` block)
@@ -49,9 +99,7 @@ After that,
4999
├── .circleci
50100
│ └── config.yml
51101
├── .loader // loader for processing custom blocks
52-
│ ├── docs-loader.js
53-
│ ├── info-loader.js
54-
│ └── notes-loader.js
102+
│ └── docs-loader.js
55103
├── .storybook
56104
│ ├── addons.js
57105
│ ├── config.js
@@ -74,21 +122,10 @@ After that,
74122
└── index.js // chain and add the addon here
75123
```
76124

77-
## Features
78-
- Support `vue init` workflow
79-
- Minimal configuration. Thanks to [poi](https://poi.js.org).
80-
- Prebuilt [circleci](https:circleci.com) config to build, deploy, and evaluate pull-requests. By default its deployed to [surge.sh](https://surge.sh).
81-
- Order the story-scenario *alphabetically* or define it using `Array`|`Object` in `src/stories/config.js`.
82-
- Preinstall and configured storybook addon:
83-
- knobs
84-
- readme, info(experimental), and notes
85-
- actions
86-
- Custom blocks (experimental, looking for feedback).
87-
88-
## Looking for suggestion (Open New Issues)
89-
- Make chaining storybook-addon on each scenario in elegant way
125+
## Looking for suggestion! (Open/Comment New Issues)
126+
90127
- How to customize style of the storybook
91-
- Authoring `Vuex` module? (is it necessary?)
128+
- Authoring `Vuex` module? [Is it necessary?](https://github.com/DrSensor/vue-authoring-template/issues/3)
92129
- any others?
93130

94131
## Support

meta.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ module.exports = {
5151
choices: [
5252
'knobs',
5353
'notes',
54-
{
55-
name: 'info (experimental)',
56-
value: 'info',
57-
short: 'info'
58-
},
54+
// {
55+
// name: 'info (experimental)',
56+
// value: 'info',
57+
// short: 'info'
58+
// },
5959
'readme',
6060
'actions'
6161
],

template/README.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,53 @@
55
<!-- Use https://github.com/phw/peek or https://github.com/ShareX/ShareX to record your component in action as gif -->
66
![](./screenplay.gif)
77

8+
## Installation
9+
10+
### via NPM
11+
12+
```bash
13+
npm install --save {{name}}
14+
# or if you use yarn
15+
yarn add {{name}}
16+
```
17+
18+
then you can import it
19+
20+
```js
21+
import {{pascalCase name}} from '{{name}}'
22+
```
23+
24+
### via CDN
25+
26+
```html
27+
<script src="https://unpkg.com/vue"></script>
28+
<script src="https://unpkg.com/{{name}}"></script>
29+
```
30+
831
## Usage
932

33+
### Example
34+
1035
```html
1136
<{{name}} hello="Hello world!!!" @click="clicked">
1237
</{{name}}>
1338
```
1439

1540
```js
41+
export default {
42+
components: {
43+
{{pascalCase name}}
44+
},
1645
methods: {
1746
clicked (helloText) {
1847
console.log(helloText)
1948
}
2049
}
50+
}
2151
```
2252

53+
> For more comprehensive example, open one of `<story>/<scenario>.vue` in [./src/stories](./src/stories)
54+
2355
### Props
2456

2557
| Prop name | Description | Type | Required | Default value |
@@ -34,12 +66,39 @@
3466

3567
### Slots
3668

37-
| Slot name | Description | Accepted Element |
69+
| Slot name | Description | Accepted Element | Slot scope |
70+
|---------- |-------- |---------- |---------- |
71+
| `default` | slot without name are placed in default | `any` | `NaN` |
72+
73+
---
74+
75+
## Extending {{name}}
76+
77+
In case if you want to extend and/or override {{name}} basic functionality.
78+
79+
### Example
80+
81+
```js
82+
export default {
83+
extends: {{pascalCase name}},
84+
methods: {
85+
clicked (helloText) {
86+
console.log('this execute first', helloText)
87+
}
88+
}
89+
}
90+
```
91+
92+
### Methods
93+
94+
| Method name | Description | Parameters |
3895
|---------- |-------- |---------- |
39-
| `default` | slot without name are placed in default | `any` |
96+
| `clicked` | execute when button is clicked | helloText: `String` |
4097

98+
---
4199

42100
## Contributing
101+
43102
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guide.
44103

45104
---

template/src/components/HelloWorld.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export default {
3333
methods: {
3434
clicked () {
3535
this.toggle = !this.toggle
36+
{{#isEnabled addons 'actions'}}
3637
this.$action('click', [this.hello])
38+
{{else}}
39+
console.log('click', this.hello)
40+
{{/isEnabled}}
3741
}
3842
}
3943
}

0 commit comments

Comments
 (0)