Skip to content

Commit a02f3c7

Browse files
committed
chore: replace storybook with a custom library
1 parent 2955a94 commit a02f3c7

File tree

10 files changed

+2960
-3750
lines changed

10 files changed

+2960
-3750
lines changed

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true
4+
}

.storybook/config.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

.storybook/manager.ejs

Lines changed: 0 additions & 47 deletions
This file was deleted.

.storybook/poi.config.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

package.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,23 @@
1919
"prepublishOnly": "npm run build",
2020
"test": "echo fine",
2121
"build": "bili --format cjs,es,umd,umd-min --module-name contentLoaders",
22-
"storybook": "poi --config .storybook/poi.config.js",
23-
"build:storybook": "poi build --config .storybook/poi.config.js"
22+
"storybook": "poi -so --config stories/poi.config.js",
23+
"build:storybook": "poi --prod --config stories/poi.config.js"
2424
},
2525
"author": {
2626
"name": "EGOIST",
2727
"email": "[email protected]"
2828
},
2929
"license": "MIT",
30-
"poi": {
31-
"entry": "example/index.js",
32-
"dist": "example/dist",
33-
"homepage": "./"
34-
},
3530
"devDependencies": {
36-
"@poi/plugin-storybook": "^10.0.0-rc.2",
37-
"@storybook/vue": "^3.3.15",
31+
"@types/poi": "^12.5.0",
3832
"babel-plugin-transform-vue-jsx": "^4",
3933
"bili": "^3.0.12",
40-
"poi": "^10.0.0-rc.6",
41-
"vue-test-utils": "^1.0.0-beta.9",
42-
"webpack": "^4.2.0"
34+
"poi": "^12.6.10",
35+
"vue": "^2.6.10",
36+
"vue-router": "^3.0.6",
37+
"vue-template-compiler": "^2.6.10",
38+
"vue-test-utils": "^1.0.0-beta.9"
4339
},
4440
"dependencies": {
4541
"babel-helper-vue-jsx-merge-props": "^2.0.3"

stories/Storybook.vue

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<template>
2+
<div>
3+
<div class="sidebar">
4+
<div class="sections">
5+
<div class="section" v-for="(section, sectionIndex) in sections" :key="sectionIndex">
6+
<div class="section-title">{{ section.title }}</div>
7+
<div class="stories">
8+
<router-link
9+
:to="{ query: { section: section.title, story: story.title } }"
10+
class="story-title"
11+
v-for="(story, storyIndex) in section.stories"
12+
:key="storyIndex"
13+
>{{ story.title }}</router-link>
14+
</div>
15+
</div>
16+
</div>
17+
</div>
18+
<div class="main">
19+
<component :is="currentComponent"/>
20+
</div>
21+
</div>
22+
</template>
23+
24+
<script>
25+
export default {
26+
props: ['sections', 'site'],
27+
28+
computed: {
29+
current() {
30+
const { query } = this.$route
31+
for (const section of this.sections) {
32+
if (section.title === query.section) {
33+
for (const story of section.stories) {
34+
if (story.title === query.story) {
35+
return {
36+
section,
37+
story
38+
}
39+
}
40+
}
41+
}
42+
}
43+
},
44+
45+
currentComponent() {
46+
if (this.current) {
47+
const { story } = this.current
48+
return typeof story.component === 'function'
49+
? story.component()
50+
: story.component
51+
}
52+
},
53+
54+
currentTitle() {
55+
if (this.current) {
56+
const { story, section } = this.current
57+
return `${story.title} ${section.title} - - ${this.site.title}`
58+
}
59+
return this.site.title
60+
}
61+
},
62+
63+
watch: {
64+
currentTitle: {
65+
handler(title) {
66+
document.title = title
67+
},
68+
immediate: true
69+
}
70+
}
71+
}
72+
</script>
73+
74+
<style>
75+
:root {
76+
--sidebar-width: 240px;
77+
}
78+
</style>
79+
80+
<style scoped>
81+
.sidebar {
82+
border-right: 1px solid #e2e2e2;
83+
width: var(--sidebar-width);
84+
position: fixed;
85+
top: 0;
86+
bottom: 0;
87+
left: 0;
88+
}
89+
90+
.section:not(:last-child) {
91+
border-bottom: 1px solid #e2e2e2;
92+
}
93+
94+
.section-title {
95+
padding: 10px;
96+
border-bottom: 1px solid #e2e2e2;
97+
}
98+
99+
.story-title {
100+
display: block;
101+
padding: 10px;
102+
color: blue;
103+
text-decoration: none;
104+
}
105+
106+
.story-title:hover {
107+
background: #f9f9f9;
108+
}
109+
110+
.story-title.router-link-exact-active {
111+
background: #f0f0f0;
112+
}
113+
114+
.main {
115+
padding: 20px;
116+
margin-left: var(--sidebar-width);
117+
}
118+
</style>

0 commit comments

Comments
 (0)