Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add theming capability to Explorer 1 #433

Merged
merged 40 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dac0484
converting monorepo (pnpm workspaces)
stephiescastle May 20, 2024
91f7f12
fixing symlinks issue in mdx
stephiescastle May 20, 2024
2067fd6
fixing ts config in packages/html
stephiescastle May 20, 2024
33b8602
small fixes to tailwind config and mdx render
stephiescastle May 20, 2024
5f69fd6
unifying prettier config and tsconfig
stephiescastle May 20, 2024
4902c42
prototyping how to share story data between storybooks
stephiescastle May 20, 2024
cf454c5
completing @explorer-1/vue package
stephiescastle May 20, 2024
8abac70
completing @explorer-1/storybook-vue app
stephiescastle May 21, 2024
0ffed09
updating makefile
stephiescastle May 21, 2024
71cfbbd
switching vue vite to library mode
stephiescastle May 21, 2024
857f94d
adding @explorer-1/nuxt module
stephiescastle May 21, 2024
0091991
adding module to makeful, minor cleanup
stephiescastle May 21, 2024
6548a8e
fixing duplicate modules in vite
stephiescastle May 21, 2024
a74fa2f
fixing make commands, building module
stephiescastle May 21, 2024
1c2c475
removing ignored dist
stephiescastle May 22, 2024
ef6df67
updating gitignore
stephiescastle May 22, 2024
eb1f8fb
renaming storybook-* to *-storybook
stephiescastle May 22, 2024
5e0196d
updating Storybook to 8.1.2
stephiescastle May 22, 2024
0107fef
wip updating github workflow for pnpm
stephiescastle May 22, 2024
81ef970
Adding scaffolding for theming Explorer-1
stephiescastle May 22, 2024
4ab62c4
Improvements to Storybook theme switcher
stephiescastle May 23, 2024
0ed7365
wip renaming ThemeLight, ThemeDark, and implementing theme-color via …
stephiescastle May 23, 2024
02cdf18
adding @explorer-1/common-storybook
stephiescastle May 23, 2024
70103e3
merging in latest monorepo changes
stephiescastle May 23, 2024
0bc1b29
restoring deleted files
stephiescastle May 23, 2024
29a1927
adding more addons to vue-storybook
stephiescastle May 23, 2024
b87dcc1
disabling linting in ci (temporary), fixing storybook action
stephiescastle May 23, 2024
7f5dd74
restore some linting actions
stephiescastle May 23, 2024
5cf88b2
updating gitignore
stephiescastle May 23, 2024
b090337
adding gitkeep for public folder
stephiescastle May 23, 2024
d739328
merging in latest monorepo branch
stephiescastle May 23, 2024
a21dff0
removing old themes key
stephiescastle May 23, 2024
f40d553
Feature: monorepo eslint upgrade to flat config (#435)
jamesray May 24, 2024
bf0d6bd
convert packages/html to use vite instead of parcel
stephiescastle May 24, 2024
b72e94e
merging in latest feature/monorepo
stephiescastle May 24, 2024
efa2418
clean up
stephiescastle May 24, 2024
adb8f1f
tailwind config cleanup
stephiescastle May 24, 2024
8eb3beb
merging in latest main
stephiescastle May 24, 2024
b2aecc4
lint emits
stephiescastle May 24, 2024
830ad87
Merge branch 'main' into poc/edu-theme
stephiescastle May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ html-storybook-build:
html-dev:
pnpm --filter @explorer-1/html dev

html: html-dev

## HTML: build assets
html-build:
pnpm --filter @explorer-1/html build
Expand All @@ -85,6 +87,8 @@ vue-storybook-build:
vue-dev:
pnpm --filter @explorer-1/vue dev

vue: vue-dev

## Vue: build assets
vue-build:
pnpm --filter @explorer-1/vue build
Expand All @@ -93,6 +97,8 @@ vue-build:
nuxt-dev:
pnpm --filter @explorer-1/nuxt dev

nuxt: nuxt-dev

## Nuxt: build module
nuxt-build:
pnpm --filter @explorer-1/nuxt build
Expand Down
3 changes: 2 additions & 1 deletion apps/html-storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export default {
{
name: '@storybook/addon-essentials',
options: {
actions: false,
backgrounds: false,
actions: false
outlines: false
}
},
{
Expand Down
35 changes: 28 additions & 7 deletions apps/html-storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,41 @@ const customViewports = {
const preview = {
globalTypes: {
themesConfig: {
defaultValue: ['ThemeLight', 'ThemeInternal', 'ThemeDark'],
method: 'css'
defaultValue: {
options: ['ThemeVariantLight', 'ThemeInternal'],
method: 'css'
}
},
theme: {
description: 'Global theme for components',
defaultValue: 'ThemeLight',
description: 'Global Theme',
defaultValue: 'ThemeVariantLight',
toolbar: {
title: 'Theme',
// https://storybook.js.org/docs/faq#what-icons-are-available-for-my-toolbar-or-my-addon
icon: 'eye',
items: [
{ value: 'ThemeLight', icon: 'circlehollow', title: 'Light' },
{ value: 'ThemeDark', icon: 'circle', title: 'Dark' },
{ value: 'ThemeInternal', icon: 'collapse', title: 'Internal' }
{ value: 'ThemeVariantLight', icon: 'circlehollow', title: 'Default Theme' },
{ value: 'ThemeInternal', icon: 'collapse', title: 'Internal Theme' }
],
dynamicTitle: true
}
},
variantsConfig: {
defaultValue: {
options: ['ThemeVariantLight', 'ThemeVariantDark'],
method: 'css'
}
},
variant: {
description: 'Theme Variant',
defaultValue: 'ThemeVariantLight',
toolbar: {
title: 'Variant',
// https://storybook.js.org/docs/faq#what-icons-are-available-for-my-toolbar-or-my-addon
icon: 'eye',
items: [
{ value: 'ThemeVariantLight', icon: 'circlehollow', title: 'Light Variant' },
{ value: 'ThemeVariantDark', icon: 'circle', title: 'Dark Variant' }
],
dynamicTitle: true
}
Expand Down
1 change: 0 additions & 1 deletion apps/html-storybook/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
Expand Down
21 changes: 16 additions & 5 deletions apps/vue-storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
/** @type { import('@storybook/vue3-vite').StorybookConfig } */
const config = {
stories: ['./../stories/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-essentials', '@chromatic-com/storybook'],
addons: [
{
name: '@storybook/addon-essentials',
options: {
actions: false,
backgrounds: false,
outlines: false,
},
},
'@storybook/addon-a11y',
'@whitespace/storybook-addon-html',
],

framework: {
name: '@storybook/vue3-vite',
options: {}
options: {},
},

docs: {}
}
export default config
docs: {},
};
export default config;
88 changes: 72 additions & 16 deletions apps/vue-storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,83 @@
/** @type { import('@storybook/vue3').Preview } */
import type { App } from 'vue'
import useMockComponents from './_mock-components.js'
import { StoryContext } from '@storybook/types'
import { VueRenderer, setup, type Preview } from '@storybook/vue3'
import { Swiper, SwiperSlide } from 'swiper/vue'
import './../node_modules/@explorer-1/vue/src/assets/scss/styles.scss'
import type { App } from 'vue';
import useMockComponents from './_mock-components.js';
import { StoryContext } from '@storybook/types';
import { VueRenderer, setup, type Preview } from '@storybook/vue3';
import { Swiper, SwiperSlide } from 'swiper/vue';
import '@explorer-1/common-storybook/src/config/canvas.css';
import '@explorer-1/vue/src/assets/scss/styles.scss';

import { withGlobals } from '@explorer-1/common-storybook/src/config/withGlobals';
setup((app: App, context?: StoryContext<VueRenderer>) => {
app.component('Swiper', Swiper)
app.component('SwiperSlide', SwiperSlide)
useMockComponents(app)
})
app.component('Swiper', Swiper);
app.component('SwiperSlide', SwiperSlide);
useMockComponents(app);
});
const preview: Preview = {
globalTypes: {
themesConfig: {
defaultValue: {
themes: ['Default', 'EDU', 'Internal'],
method: 'data-attr',
},
},
variantsConfig: {
defaultValue: {
variants: ['ThemeVariantLight', 'ThemeVariantDark'],
method: 'css',
},
},
theme: {
description: 'Global Theme',
defaultValue: 'defaultTheme',
toolbar: {
title: 'Theme',
// https://storybook.js.org/docs/faq#what-icons-are-available-for-my-toolbar-or-my-addon
icon: 'eye',
items: [
{
value: 'defaultTheme',
icon: 'circlehollow',
title: 'Default Theme',
},
{ value: 'edu', icon: 'circle', title: 'EDU Theme' },
{ value: 'internal', icon: 'collapse', title: 'Internal Theme' },
],
dynamicTitle: true,
},
},
variant: {
description: 'Theme Variant',
defaultValue: 'ThemeVariantLight',
toolbar: {
title: 'Variant',
// https://storybook.js.org/docs/faq#what-icons-are-available-for-my-toolbar-or-my-addon
icon: 'eye',
items: [
{
value: 'ThemeVariantLight',
icon: 'circlehollow',
title: 'Light Variant',
},
{ value: 'ThemeVariantDark', icon: 'circle', title: 'Dark Variant' },
],
dynamicTitle: true,
},
},
},

parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/
}
}
date: /Date$/,
},
},
},

tags: ['autodocs']
}
decorators: [withGlobals],

tags: ['autodocs'],
};

export default preview
export default preview;
2 changes: 2 additions & 0 deletions apps/vue-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
"@explorer-1/tsconfig": "workspace:*",
"@explorer-1/vue": "workspace:*",
"@rushstack/eslint-patch": "^1.2.0",
"@storybook/addon-a11y": "^8.1.2",
"@storybook/addon-essentials": "^8.1.2",
"@storybook/blocks": "^8.1.2",
"@storybook/vue3": "^8.1.2",
"@storybook/vue3-vite": "^8.1.2",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/eslint-config-prettier": "^7.1.0",
"@whitespace/storybook-addon-html": "^6.1.1",
"autoprefixer": "^10.4.19",
"msw": "^1.2.1",
"msw-storybook-addon": "^2.0.2",
Expand Down
47 changes: 47 additions & 0 deletions apps/vue-storybook/stories/BaseLink.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import BaseLink, { variants } from '@explorer-1/vue/src/components/BaseLink/BaseLink.vue'
// import BaseLink, { variants } from '@explorer-1/vue/src/components/BaseLink/BaseLink.vue'
export default {
title: 'Components/Base/BaseLink',
component: BaseLink,
// argTypes: {
// variant: {
// control: { type: 'select', options: Object.keys(variants) }
// },
// text: { control: { type: 'text' } }
// },
excludeStories: /.*Data$/
}

// data
export const BaseLinkData = {
variant: 'primary',
to: '/',
href: '/',
caret: false,
caretColor: 'text-theme-red'
}

// templates
const BaseLinkTemplate = (args) => ({
components: { BaseLink },
setup() {
return { args }
},
template: `<BaseLink v-bind="args">Base Link</BaseLink>`
})

// stories
export const Primary = BaseLinkTemplate.bind({})
Primary.args = { ...BaseLinkData }

export const Secondary = BaseLinkTemplate.bind({})
Secondary.args = { ...BaseLinkData, variant: 'secondary' }

export const DefaultBody = BaseLinkTemplate.bind({})
DefaultBody.args = { ...BaseLinkData, variant: 'default' }

export const Unstyled = BaseLinkTemplate.bind({})
Unstyled.args = {
...BaseLinkData,
variant: 'none'
}
26 changes: 26 additions & 0 deletions apps/vue-storybook/stories/Icons/Icons.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import IconCaret from '@explorer-1/vue/src/components/Icons/IconCaret.vue'

export default {
title: 'Icons',
component: IconCaret,
decorators: [
() => ({
template: `<div class="inline-block"><story/></div>`
})
],
parameters: {
docs: {
description: {
component: 'Use with tailwind text classes to specify size and color'
}
}
}
}

export const Caret = (args) => ({
components: { IconCaret },
setup() {
return { args }
},
template: `<IconCaret v-bind="args" />`
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import MixinAnimationCaret from '@explorer-1/vue/src/components/MixinAnimationCaret/MixinAnimationCaret.vue'

export default {
title: 'Mixins/MixinAnimationCaret',
component: MixinAnimationCaret,
parameters: {
viewMode: 'docs',
docs: {
description: {
component: 'This component appends an animated caret to a line of text.'
}
}
}
}

// templates
const MixinAnimationCaretTemplate = (args) => ({
components: { MixinAnimationCaret },
setup() {
return { args }
},
template: `<MixinAnimationCaret v-bind="args">Demo of animated caret</MixinAnimationCaret>`
})

// stories
export const Default = MixinAnimationCaretTemplate.bind({})
4 changes: 1 addition & 3 deletions apps/vue-storybook/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Config } from 'tailwindcss'

/*
** TailwindCSS Configuration File
**
Expand All @@ -10,7 +8,7 @@ import type { Config } from 'tailwindcss'
// import explorer 1's tailwind config
import explorer1Config from '@explorer-1/common/tailwind.config'

export default <Partial<Config>>{
export default {
...explorer1Config,
content: ['./node_modules/@explorer-1/vue/src/components/**/*.vue']
}
1 change: 0 additions & 1 deletion apps/vue-storybook/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

Expand Down
12 changes: 6 additions & 6 deletions packages/common-storybook/src/config/canvas.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* styles that are applied to story canvas */

html.ThemeLight,
body.ThemeLight,
.ThemeLight .sbdocs-preview {
html.ThemeVariantLight,
body.ThemeVariantLight,
.ThemeVariantLight .sbdocs-preview {
background: #ffffff;
}

html.ThemeDark,
body.ThemeDark,
.ThemeDark .sbdocs-preview {
html.ThemeVariantDark,
body.ThemeVariantDark,
.ThemeVariantDark .sbdocs-preview {
background: #000000;
}

Expand Down
Loading