@explorer-1/vue-storybook 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/_mock-components.js +21 -0
- package/.storybook/main.ts +43 -0
- package/.storybook/manager-head.html +40 -0
- package/.storybook/manager.ts +11 -0
- package/.storybook/preview-head.html +146 -0
- package/.storybook/preview.ts +166 -0
- package/.storybook/withGlobals.ts +189 -0
- package/LICENSE +21 -0
- package/components.d.ts +238 -0
- package/package.json +70 -0
- package/postcss.config.js +9 -0
- package/public/css/.gitkeep +0 -0
- package/public/css/font-face.css +107 -0
- package/public/edu/.gitkeep +0 -0
- package/public/edu/explorer-1/bg-stars-edu.png +0 -0
- package/public/edu/explorer-1/bg-stars.jpg +0 -0
- package/public/explorer-1/bg-stars-edu.png +0 -0
- package/public/explorer-1/bg-stars.jpg +0 -0
- package/storybook_compiled/favicon.svg +7 -0
- package/storybook_compiled/index.html +151 -0
- package/storybook_compiled/index.json +1 -0
- package/storybook_compiled/project.json +1 -0
- package/storybook_compiled/sb-addons/a11y-6/manager-bundle.js +3 -0
- package/storybook_compiled/sb-addons/a11y-6/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook_compiled/sb-addons/essentials-controls-1/manager-bundle.js +60 -0
- package/storybook_compiled/sb-addons/essentials-controls-1/manager-bundle.js.LEGAL.txt +18 -0
- package/storybook_compiled/sb-addons/essentials-measure-4/manager-bundle.js +3 -0
- package/storybook_compiled/sb-addons/essentials-measure-4/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook_compiled/sb-addons/essentials-outline-5/manager-bundle.js +3 -0
- package/storybook_compiled/sb-addons/essentials-outline-5/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook_compiled/sb-addons/essentials-toolbars-3/manager-bundle.js +3 -0
- package/storybook_compiled/sb-addons/essentials-toolbars-3/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook_compiled/sb-addons/essentials-viewport-2/manager-bundle.js +3 -0
- package/storybook_compiled/sb-addons/essentials-viewport-2/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook_compiled/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +3 -0
- package/storybook_compiled/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
- package/storybook_compiled/sb-addons/whitespace-html-7/manager-bundle.js +93 -0
- package/storybook_compiled/sb-addons/whitespace-html-7/manager-bundle.js.LEGAL.txt +14 -0
- package/storybook_compiled/sb-common-assets/fonts.css +31 -0
- package/storybook_compiled/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook_compiled/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook_compiled/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook_compiled/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook_compiled/sb-manager/WithTooltip-KJL26V4Q-5LS5AN27.js +1 -0
- package/storybook_compiled/sb-manager/chunk-4FMBEAHW.js +274 -0
- package/storybook_compiled/sb-manager/chunk-6GQRNYH2.js +186 -0
- package/storybook_compiled/sb-manager/chunk-B3YDJJJH.js +347 -0
- package/storybook_compiled/sb-manager/chunk-BLWCBWKL.js +9 -0
- package/storybook_compiled/sb-manager/chunk-GUVK2GTO.js +6 -0
- package/storybook_compiled/sb-manager/chunk-ZR5JZWHI.js +1 -0
- package/storybook_compiled/sb-manager/formatter-2WMMO6ZP-JI7RHVTW.js +58 -0
- package/storybook_compiled/sb-manager/globals-module-info.js +1 -0
- package/storybook_compiled/sb-manager/globals-runtime.js +1 -0
- package/storybook_compiled/sb-manager/globals.js +1 -0
- package/storybook_compiled/sb-manager/index.js +1 -0
- package/storybook_compiled/sb-manager/runtime.js +1 -0
- package/storybook_compiled/sb-manager/syntaxhighlighter-BP7B2CQK-WOJYHKQR.js +1 -0
- package/storybook_compiled/sb-preview/globals.js +1 -0
- package/storybook_compiled/sb-preview/runtime.js +156 -0
- package/tailwind.config.ts +18 -0
- package/tsconfig.json +5 -0
- package/vite.config.ts +32 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// import and assign mock components
|
|
2
|
+
import { action } from '@storybook/addon-actions'
|
|
3
|
+
|
|
4
|
+
export default (app) => {
|
|
5
|
+
// nuxt-link mock component
|
|
6
|
+
app.component('NuxtLink', {
|
|
7
|
+
props: ['to', 'href', 'class'],
|
|
8
|
+
methods: {
|
|
9
|
+
log() {
|
|
10
|
+
if (this.to) {
|
|
11
|
+
action('router link')(this.to)
|
|
12
|
+
}
|
|
13
|
+
if (this.href) {
|
|
14
|
+
action('href link')(this.href)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
template:
|
|
19
|
+
'<a href="#" @click.prevent="log()" :class="this.class" v-bind="$attrs"><slot></slot></a>'
|
|
20
|
+
})
|
|
21
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** @type { import('@storybook/vue3-vite').StorybookConfig } */
|
|
2
|
+
import remarkGfm from 'remark-gfm'
|
|
3
|
+
const config = {
|
|
4
|
+
stories: [
|
|
5
|
+
'./../node_modules/@explorer-1/vue/src/**/*.stories.@(js|jsx|ts|tsx)',
|
|
6
|
+
'./../node_modules/@explorer-1/vue/src/**/*.docs.mdx'
|
|
7
|
+
],
|
|
8
|
+
addons: [
|
|
9
|
+
{
|
|
10
|
+
name: '@storybook/addon-essentials',
|
|
11
|
+
options: {
|
|
12
|
+
actions: false,
|
|
13
|
+
backgrounds: false,
|
|
14
|
+
outlines: false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: '@storybook/addon-docs',
|
|
19
|
+
options: {
|
|
20
|
+
mdxPluginOptions: {
|
|
21
|
+
mdxCompileOptions: {
|
|
22
|
+
remarkPlugins: [remarkGfm]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'@storybook/addon-a11y',
|
|
28
|
+
'@whitespace/storybook-addon-html',
|
|
29
|
+
'storybook-addon-vue-slots'
|
|
30
|
+
],
|
|
31
|
+
staticDirs: [
|
|
32
|
+
'./../public',
|
|
33
|
+
'./../node_modules/@explorer-1/common-storybook/src/public',
|
|
34
|
+
'./../node_modules/@explorer-1/common/src'
|
|
35
|
+
],
|
|
36
|
+
framework: {
|
|
37
|
+
name: '@storybook/vue3-vite',
|
|
38
|
+
options: {}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
docs: {}
|
|
42
|
+
}
|
|
43
|
+
export default config
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<style type="text/css">
|
|
2
|
+
/* styles for the storybook sidebar */
|
|
3
|
+
@import 'css/font-face.css';
|
|
4
|
+
|
|
5
|
+
.sidebar-item {
|
|
6
|
+
font-family: Metropolis, sans-serif !important;
|
|
7
|
+
line-height: 1.2rem !important;
|
|
8
|
+
display: flex !important;
|
|
9
|
+
align-items: center !important;
|
|
10
|
+
}
|
|
11
|
+
.sidebar-item svg:not([type='document']) {
|
|
12
|
+
color: inherit !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* www should be in uppercase */
|
|
16
|
+
.sidebar-item#www {
|
|
17
|
+
text-transform: uppercase;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* create illusion of hrs between sidebar sections */
|
|
21
|
+
.sidebar-item#www,
|
|
22
|
+
.sidebar-item#appendix {
|
|
23
|
+
border-radius: 0;
|
|
24
|
+
border-top: 2px solid rgba(0, 0, 0, 0.1);
|
|
25
|
+
margin-top: 0.5rem;
|
|
26
|
+
padding-top: 1rem !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* logo placement tweaks */
|
|
30
|
+
.sidebar-header > div {
|
|
31
|
+
margin-right: 0 !important;
|
|
32
|
+
}
|
|
33
|
+
.sidebar-header a {
|
|
34
|
+
margin: 6px 0 !important;
|
|
35
|
+
}
|
|
36
|
+
.sidebar-header a > img {
|
|
37
|
+
max-width: none !important;
|
|
38
|
+
max-height: none !important;
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// customizing Storybook's manager UI
|
|
2
|
+
// see config options: https://storybook.js.org/docs/vue/configure/features-and-behavior
|
|
3
|
+
|
|
4
|
+
import { addons } from '@storybook/manager-api'
|
|
5
|
+
import customTheme from '@explorer-1/common-storybook/src/config/customTheme'
|
|
6
|
+
|
|
7
|
+
// to collapse all sections and use custom theme
|
|
8
|
+
addons.setConfig({
|
|
9
|
+
theme: customTheme,
|
|
10
|
+
sidebar: { showRoots: false }
|
|
11
|
+
})
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<style type="text/css">
|
|
2
|
+
/* styles for docs tab */
|
|
3
|
+
/* @import 'dist/css/font-face.css'; */
|
|
4
|
+
|
|
5
|
+
#storybook-docs
|
|
6
|
+
.sbdocs
|
|
7
|
+
.sbdocs-content
|
|
8
|
+
*:not(.sbdocs-preview, .sbdocs-preview *, pre, pre *, code, code *) {
|
|
9
|
+
font-family: Metropolis, sans-serif !important;
|
|
10
|
+
}
|
|
11
|
+
/* make docs have full width iframes
|
|
12
|
+
** rescopes width to all nested divs, not the container wrapper */
|
|
13
|
+
.sbdocs.sbdocs-content {
|
|
14
|
+
max-width: 1950px;
|
|
15
|
+
}
|
|
16
|
+
.sbdocs.sbdocs-content > * {
|
|
17
|
+
width: 100%;
|
|
18
|
+
max-width: 950px;
|
|
19
|
+
margin-left: auto;
|
|
20
|
+
margin-right: auto;
|
|
21
|
+
}
|
|
22
|
+
.sbdocs.sbdocs-content > div[id*='anchor--'],
|
|
23
|
+
.sbdocs.sbdocs-content .reactdocs-content {
|
|
24
|
+
max-width: none;
|
|
25
|
+
}
|
|
26
|
+
.sbdocs.sbdocs-content > div[id*='anchor--'] > *,
|
|
27
|
+
.sbdocs.sbdocs-content .reactdocs-content > div,
|
|
28
|
+
.reactdocs-container {
|
|
29
|
+
width: 100%;
|
|
30
|
+
max-width: 950px;
|
|
31
|
+
margin-left: auto;
|
|
32
|
+
margin-right: auto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* .sbdocs.sbdocs-content .sbdocs-pre {
|
|
36
|
+
margin-left: auto;
|
|
37
|
+
margin-right: auto;
|
|
38
|
+
} */
|
|
39
|
+
.sbdocs.sbdocs-content > pre {
|
|
40
|
+
margin-left: auto;
|
|
41
|
+
margin-right: auto;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.sbdocs .sbdocs-content ol:not(.list-none) {
|
|
45
|
+
list-style-type: decimal;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* custom border color for h2 to match gray-light-mid */
|
|
49
|
+
.sbdocs.sbdocs-h2 {
|
|
50
|
+
border-bottom: 1px solid rgba(216, 216, 216, 1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* .sbdocs-preview-full-width overrides max width in doc view
|
|
54
|
+
** use this class via the `className` prop on Canvas
|
|
55
|
+
*/
|
|
56
|
+
.sbdocs.sbdocs-content .sbdocs-preview-full-width,
|
|
57
|
+
.sbdocs-preview-full-width .sbdocs.sbdocs-content .sbdocs-preview,
|
|
58
|
+
.sbdocs.sbdocs-content .sb-anchor .sbdocs-preview {
|
|
59
|
+
max-width: none !important;
|
|
60
|
+
margin-top: 2rem;
|
|
61
|
+
margin-bottom: 2rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* unset the mysterious height that storybook adds to Canvas doc blocks rendered via a React component */
|
|
65
|
+
.sbdocs.sbdocs-content .reactdocs-content .sbdocs-preview .docs-story div[height='20'] {
|
|
66
|
+
height: unset;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* sometimes inline stories still need an explicit height set */
|
|
70
|
+
.sbdocs-inline-height .docs-story {
|
|
71
|
+
height: 500px !important;
|
|
72
|
+
}
|
|
73
|
+
.sbdocs-inline-height-2xs .docs-story {
|
|
74
|
+
height: 200px !important;
|
|
75
|
+
}
|
|
76
|
+
.sbdocs-inline-height-xs .docs-story {
|
|
77
|
+
height: 300px !important;
|
|
78
|
+
}
|
|
79
|
+
.sbdocs-inline-height-sm .docs-story {
|
|
80
|
+
height: 400px !important;
|
|
81
|
+
}
|
|
82
|
+
.sbdocs-inline-height-lg .docs-story {
|
|
83
|
+
height: 600px !important;
|
|
84
|
+
}
|
|
85
|
+
.sbdocs-inline-height-xl .docs-story {
|
|
86
|
+
height: 700px !important;
|
|
87
|
+
}
|
|
88
|
+
.sbdocs-inline-height-2xl .docs-story {
|
|
89
|
+
height: 800px !important;
|
|
90
|
+
}
|
|
91
|
+
.sbdocs-inline-height .docs-story > div:first-child {
|
|
92
|
+
height: inherit !important;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* sbdocs link style */
|
|
96
|
+
.sbdocs.sbdocs-a {
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
border-bottom: 1px solid #489fdf;
|
|
99
|
+
color: black;
|
|
100
|
+
}
|
|
101
|
+
.sbdocs.sbdocs-a:hover {
|
|
102
|
+
border-bottom-color: black;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* sbdocs table styles */
|
|
106
|
+
.sbdocs.sbdocs-table {
|
|
107
|
+
margin-top: 24px;
|
|
108
|
+
margin-bottom: 24px;
|
|
109
|
+
}
|
|
110
|
+
.sbdocs.sbdocs-table tr:nth-of-type(2n) {
|
|
111
|
+
background: white;
|
|
112
|
+
}
|
|
113
|
+
.sbdocs.sbdocs-table tr th,
|
|
114
|
+
.sbdocs.sbdocs-table tr td {
|
|
115
|
+
border-left: none;
|
|
116
|
+
border-right: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* tag or image alignment */
|
|
120
|
+
.sbdocs.sbdocs-content img[src*='#left'] {
|
|
121
|
+
float: left;
|
|
122
|
+
}
|
|
123
|
+
.sbdocs.sbdocs-content img[src*='#right'] {
|
|
124
|
+
float: right;
|
|
125
|
+
}
|
|
126
|
+
.sbdocs.sbdocs-content img[src*='#center'] {
|
|
127
|
+
display: block;
|
|
128
|
+
margin: auto;
|
|
129
|
+
}
|
|
130
|
+
.sbdocs.sbdocs-content img[src*='#inline'] {
|
|
131
|
+
display: inline;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* background color for code blocks */
|
|
135
|
+
.sbdocs .docblock-source {
|
|
136
|
+
background-color: #f5f5f5;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* make details > summary text appear clickable in docs */
|
|
140
|
+
.sbdocs details > summary {
|
|
141
|
+
cursor: pointer;
|
|
142
|
+
}
|
|
143
|
+
.sbdocs details > summary > .sbdocs-span {
|
|
144
|
+
font-size: unset !important;
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/** @type { import('@storybook/vue3').Preview } */
|
|
2
|
+
import type { App } from 'vue'
|
|
3
|
+
import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport'
|
|
4
|
+
import useMockComponents from './_mock-components.js'
|
|
5
|
+
import { StoryContext } from '@storybook/types'
|
|
6
|
+
import { VueRenderer, setup, type Preview } from '@storybook/vue3'
|
|
7
|
+
import { Swiper, SwiperSlide } from 'swiper/vue'
|
|
8
|
+
import vClickOutside from 'click-outside-vue3'
|
|
9
|
+
import VueCompareImage from 'vue3-compare-image'
|
|
10
|
+
import { createPinia } from 'pinia'
|
|
11
|
+
import filters from '@explorer-1/vue/src/utils/filters'
|
|
12
|
+
import '@explorer-1/common-storybook/src/config/canvas.css'
|
|
13
|
+
import '@explorer-1/vue/src/assets/scss/styles.scss'
|
|
14
|
+
import { withGlobals, globalTypes } from './withGlobals'
|
|
15
|
+
import customTheme from '@explorer-1/common-storybook/src/config/customTheme'
|
|
16
|
+
import '@explorer-1/common-storybook/src/config/canvas.css'
|
|
17
|
+
|
|
18
|
+
const pinia = createPinia()
|
|
19
|
+
|
|
20
|
+
setup((app: App, context?: StoryContext<VueRenderer>) => {
|
|
21
|
+
app.use(pinia)
|
|
22
|
+
app.use(vClickOutside)
|
|
23
|
+
app.use(VueCompareImage)
|
|
24
|
+
app.component('Swiper', Swiper)
|
|
25
|
+
app.component('SwiperSlide', SwiperSlide)
|
|
26
|
+
app.config.globalProperties.$filters = filters
|
|
27
|
+
useMockComponents(app)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// viewports that match our tailwind config
|
|
31
|
+
const customViewports = {
|
|
32
|
+
screenSm: {
|
|
33
|
+
name: 'screen-sm',
|
|
34
|
+
styles: {
|
|
35
|
+
width: '640px',
|
|
36
|
+
height: '100%'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
screenMd: {
|
|
40
|
+
name: 'screen-md',
|
|
41
|
+
styles: {
|
|
42
|
+
width: '768px',
|
|
43
|
+
height: '100%'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
screenLg: {
|
|
47
|
+
name: 'screen-lg',
|
|
48
|
+
styles: {
|
|
49
|
+
width: '1024px',
|
|
50
|
+
height: '100%'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
screenXl: {
|
|
54
|
+
name: 'screen-xl',
|
|
55
|
+
styles: {
|
|
56
|
+
width: '1280px',
|
|
57
|
+
height: '100%'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
screen2xl: {
|
|
61
|
+
name: 'screen-2xl',
|
|
62
|
+
styles: {
|
|
63
|
+
width: '1440px',
|
|
64
|
+
height: '100%'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
screen3xl: {
|
|
68
|
+
name: 'screen-3xl',
|
|
69
|
+
styles: {
|
|
70
|
+
width: '1800px',
|
|
71
|
+
height: '100%'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const preview: Preview = {
|
|
77
|
+
globalTypes,
|
|
78
|
+
|
|
79
|
+
parameters: {
|
|
80
|
+
controls: {
|
|
81
|
+
expanded: true,
|
|
82
|
+
matchers: {
|
|
83
|
+
color: /(background|color)$/i,
|
|
84
|
+
date: /Date$/
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
viewport: {
|
|
88
|
+
viewports: {
|
|
89
|
+
...MINIMAL_VIEWPORTS,
|
|
90
|
+
...customViewports
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
// options for the html tab add-on
|
|
94
|
+
html: {
|
|
95
|
+
removeEmptyComments: true
|
|
96
|
+
},
|
|
97
|
+
// set the theme for docs (same as UI)
|
|
98
|
+
docs: {
|
|
99
|
+
theme: customTheme
|
|
100
|
+
},
|
|
101
|
+
options: {
|
|
102
|
+
storySort: {
|
|
103
|
+
method: 'alphabetical',
|
|
104
|
+
order: [
|
|
105
|
+
'Introduction',
|
|
106
|
+
'Roadmap',
|
|
107
|
+
'Getting Started',
|
|
108
|
+
['Developer'],
|
|
109
|
+
'Guides',
|
|
110
|
+
'Foundation',
|
|
111
|
+
[
|
|
112
|
+
'Colors',
|
|
113
|
+
'Typography',
|
|
114
|
+
'Icons',
|
|
115
|
+
'Logos',
|
|
116
|
+
'Themes',
|
|
117
|
+
'Grid and Layout',
|
|
118
|
+
'Responsive Design'
|
|
119
|
+
],
|
|
120
|
+
'Global Layout',
|
|
121
|
+
[
|
|
122
|
+
'Overview',
|
|
123
|
+
'Headers',
|
|
124
|
+
[
|
|
125
|
+
'Overview',
|
|
126
|
+
'External',
|
|
127
|
+
'For Internal Sites',
|
|
128
|
+
[
|
|
129
|
+
'*',
|
|
130
|
+
'Elements',
|
|
131
|
+
['Overview', 'AppBar', 'Navigation', 'Panel', 'Highlight', 'Section']
|
|
132
|
+
]
|
|
133
|
+
],
|
|
134
|
+
'Footers',
|
|
135
|
+
['Overview', 'External', 'Internal']
|
|
136
|
+
],
|
|
137
|
+
'Components',
|
|
138
|
+
[
|
|
139
|
+
'Overview',
|
|
140
|
+
'Base',
|
|
141
|
+
['Overview'],
|
|
142
|
+
'Blocks',
|
|
143
|
+
['Overview', 'Heroes', ['Overview', 'Small', 'Medium', 'Large']],
|
|
144
|
+
'Heroes',
|
|
145
|
+
['*', 'HeroMedia', 'HeroListingIndex'],
|
|
146
|
+
'Forms',
|
|
147
|
+
['Overview', 'TextInput', 'TextArea'],
|
|
148
|
+
'Search',
|
|
149
|
+
['Overview'],
|
|
150
|
+
'Mixins',
|
|
151
|
+
['Overview', 'MixinAnimationCaret', 'MixinVideoBg', 'MixinCarousel'],
|
|
152
|
+
'Utilities',
|
|
153
|
+
['Overview', '*'],
|
|
154
|
+
'EDU'
|
|
155
|
+
]
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
decorators: [withGlobals],
|
|
162
|
+
|
|
163
|
+
tags: ['autodocs']
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export default preview
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { useEffect, useGlobals } from '@storybook/preview-api'
|
|
2
|
+
import { useThemeStore } from '@explorer-1/vue/src/store/theme'
|
|
3
|
+
import { type Explorer1Theme } from '@explorer-1/vue/src/interfaces'
|
|
4
|
+
|
|
5
|
+
const getConfig = (config) => {
|
|
6
|
+
// default values
|
|
7
|
+
let defaultMethod: string = 'css'
|
|
8
|
+
let options: string[] | undefined = undefined
|
|
9
|
+
let method: string | undefined = undefined
|
|
10
|
+
|
|
11
|
+
if (typeof config === 'object') {
|
|
12
|
+
// get options
|
|
13
|
+
if ('options' in config) {
|
|
14
|
+
options = config.options
|
|
15
|
+
}
|
|
16
|
+
// handle method
|
|
17
|
+
if ('method' in config) {
|
|
18
|
+
// case insensitive comparisons
|
|
19
|
+
if (config.method.toUpperCase() === 'css'.toUpperCase()) {
|
|
20
|
+
method = 'css'
|
|
21
|
+
} else if (config.method) {
|
|
22
|
+
method = 'data-attr'
|
|
23
|
+
} else {
|
|
24
|
+
// use "css" method if not specified
|
|
25
|
+
method = defaultMethod
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
method = defaultMethod
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// otherwise undefined
|
|
33
|
+
else {
|
|
34
|
+
options = undefined
|
|
35
|
+
method = undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return { options, method }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const withGlobals = (StoryFn, context) => {
|
|
42
|
+
const useTheme = useThemeStore()
|
|
43
|
+
const { themesConfig, variantsConfig } = context.globals
|
|
44
|
+
const { options, method } = getConfig(themesConfig)
|
|
45
|
+
const { options: variantOptions, method: variantMethod } = getConfig(variantsConfig)
|
|
46
|
+
const [{ theme, variant }, updateGlobals] = useGlobals()
|
|
47
|
+
const isInDocs = context.viewMode === 'docs'
|
|
48
|
+
|
|
49
|
+
// disable usage of updateGlobals in docs
|
|
50
|
+
if (!isInDocs) {
|
|
51
|
+
// check for value in local storage
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const savedTheme: Explorer1Theme = window.localStorage.getItem('data-theme') as Explorer1Theme
|
|
54
|
+
const savedVariant: Explorer1Theme = window.localStorage.getItem(
|
|
55
|
+
'data-variant'
|
|
56
|
+
) as Explorer1Theme
|
|
57
|
+
|
|
58
|
+
const themeOverride: Explorer1Theme | undefined = window.location.search.includes('edu-')
|
|
59
|
+
? 'ThemeEdu'
|
|
60
|
+
: window.location.search.includes('www-')
|
|
61
|
+
? 'defaultTheme'
|
|
62
|
+
: window.location.search.includes('internal-')
|
|
63
|
+
? 'ThemeInternal'
|
|
64
|
+
: undefined
|
|
65
|
+
// handle theme
|
|
66
|
+
if (themeOverride) {
|
|
67
|
+
updateGlobals({ theme: themeOverride })
|
|
68
|
+
useTheme.setTheme(themeOverride)
|
|
69
|
+
} else if (savedTheme) {
|
|
70
|
+
// update theme attribute and save it to local storage
|
|
71
|
+
updateGlobals({ theme: savedTheme })
|
|
72
|
+
useTheme.setTheme(savedTheme)
|
|
73
|
+
} else {
|
|
74
|
+
// set it to the first theme
|
|
75
|
+
if (options && options.length > 0) {
|
|
76
|
+
updateGlobals({ theme: options[0] })
|
|
77
|
+
useTheme.setTheme(options[0] as Explorer1Theme)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// handle variant
|
|
82
|
+
if (savedVariant) {
|
|
83
|
+
// update theme attribute and save it to local storage
|
|
84
|
+
updateGlobals({ variant: savedVariant })
|
|
85
|
+
} else {
|
|
86
|
+
// set it to the first theme
|
|
87
|
+
if (variantOptions && variantOptions.length > 0) {
|
|
88
|
+
updateGlobals({ variant: variantOptions[0] })
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, [])
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// handle theme method
|
|
95
|
+
if (method === 'css') {
|
|
96
|
+
const savedTheme = window.localStorage.getItem('data-theme')
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (theme) {
|
|
99
|
+
if (savedTheme) {
|
|
100
|
+
document.documentElement.classList.remove(savedTheme)
|
|
101
|
+
}
|
|
102
|
+
document.documentElement.classList.add(theme)
|
|
103
|
+
useTheme.setTheme(theme)
|
|
104
|
+
window.localStorage.setItem('data-theme', theme)
|
|
105
|
+
}
|
|
106
|
+
}, [theme])
|
|
107
|
+
} else if (method === 'data-attr') {
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (theme) {
|
|
110
|
+
useTheme.setTheme(theme)
|
|
111
|
+
document.documentElement.setAttribute('data-theme', theme)
|
|
112
|
+
window.localStorage.setItem('data-theme', theme)
|
|
113
|
+
}
|
|
114
|
+
}, [theme])
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// handle variant method
|
|
118
|
+
if (variantMethod === 'css') {
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (variant) {
|
|
121
|
+
const savedVariant = window.localStorage.getItem('data-variant')
|
|
122
|
+
document.body.classList.remove(savedVariant)
|
|
123
|
+
document.body.classList.add(variant)
|
|
124
|
+
window.localStorage.setItem('data-variant', variant)
|
|
125
|
+
}
|
|
126
|
+
}, [variant])
|
|
127
|
+
} else if (variantMethod === 'data-attr') {
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (variant) {
|
|
130
|
+
document.body.setAttribute('data-variant', variant)
|
|
131
|
+
window.localStorage.setItem('data-variant', variant)
|
|
132
|
+
}
|
|
133
|
+
}, [variant])
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return StoryFn()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const globalTypes = {
|
|
140
|
+
themesConfig: {
|
|
141
|
+
defaultValue: {
|
|
142
|
+
themes: ['Default', 'EDU', 'Internal'],
|
|
143
|
+
method: 'css'
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
variantsConfig: {
|
|
147
|
+
defaultValue: {
|
|
148
|
+
variants: ['ThemeVariantLight', 'ThemeVariantDark'],
|
|
149
|
+
method: 'css'
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
theme: {
|
|
153
|
+
description: 'Global Theme',
|
|
154
|
+
defaultValue: 'defaultTheme',
|
|
155
|
+
toolbar: {
|
|
156
|
+
title: 'Theme',
|
|
157
|
+
// https://storybook.js.org/docs/faq#what-icons-are-available-for-my-toolbar-or-my-addon
|
|
158
|
+
icon: 'eye',
|
|
159
|
+
items: [
|
|
160
|
+
{
|
|
161
|
+
value: 'defaultTheme',
|
|
162
|
+
icon: 'home',
|
|
163
|
+
title: 'Default Theme'
|
|
164
|
+
},
|
|
165
|
+
{ value: 'ThemeEdu', icon: 'globe', title: 'EDU Theme' },
|
|
166
|
+
{ value: 'ThemeInternal', icon: 'key', title: 'Internal Theme' }
|
|
167
|
+
],
|
|
168
|
+
dynamicTitle: true
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
variant: {
|
|
172
|
+
description: 'Theme Variant',
|
|
173
|
+
defaultValue: 'ThemeVariantLight',
|
|
174
|
+
toolbar: {
|
|
175
|
+
title: 'Variant',
|
|
176
|
+
// https://storybook.js.org/docs/faq#what-icons-are-available-for-my-toolbar-or-my-addon
|
|
177
|
+
icon: 'eye',
|
|
178
|
+
items: [
|
|
179
|
+
{
|
|
180
|
+
value: 'ThemeVariantLight',
|
|
181
|
+
icon: 'circlehollow',
|
|
182
|
+
title: 'Light Variant'
|
|
183
|
+
},
|
|
184
|
+
{ value: 'ThemeVariantDark', icon: 'circle', title: 'Dark Variant' }
|
|
185
|
+
],
|
|
186
|
+
dynamicTitle: true
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 California Institute of Technology (Caltech). U.S. Government sponsorship acknowledged.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|