Skip to content

Commit

Permalink
configuring exports for @explorer-1/vue
Browse files Browse the repository at this point in the history
updating more import paths
  • Loading branch information
stephiescastle committed Jun 28, 2024
1 parent 6286d2c commit dfbae91
Show file tree
Hide file tree
Showing 22 changed files with 432 additions and 70 deletions.
6 changes: 4 additions & 2 deletions apps/vue-storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { Swiper, SwiperSlide } from 'swiper/vue'
import vClickOutside from 'click-outside-vue3'
import VueCompareImage from 'vue3-compare-image'
import { createPinia } from 'pinia'
import filters from '@explorer-1/vue/src/utils/filters'
import filters from '@explorer-1/vue'
import '@explorer-1/common-storybook/src/config/canvas.css'
import '@explorer-1/vue/src/assets/scss/styles.scss'
import '@explorer-1/common/src/scss/styles.scss'
import { withGlobals, globalTypes } from './withGlobals'
import customTheme from '@explorer-1/common-storybook/src/config/customTheme'
import '@explorer-1/common-storybook/src/config/canvas.css'
import useThemeStore from '@explorer-1/vue'
type Explorer1Theme = 'defaultTheme' | 'ThemeInternal' | 'ThemeEdu'

const pinia = createPinia()

Expand Down
27 changes: 27 additions & 0 deletions apps/vue-storybook/.storybook/themeStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineStore } from 'pinia'
type Explorer1Theme = 'defaultTheme' | 'ThemeInternal' | 'ThemeEdu'

/** Sets the Explorer-1 theme
*/

export interface State {
theme: Explorer1Theme | null
}

export const useThemeStore = defineStore('theme', {
state: (): State => {
return {
theme: null
}
},
actions: {
setTheme(value: Explorer1Theme) {
this.theme = value
}
},
getters: {
isEdu(state) {
return state.theme === 'ThemeEdu'
}
}
})
9 changes: 5 additions & 4 deletions apps/vue-storybook/.storybook/withGlobals.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useGlobals } from '@storybook/preview-api'
import { useThemeStore } from '@explorer-1/vue/src/store/theme'
import { type Explorer1Theme } from '@explorer-1/vue/src/interfaces'
import { useThemeStore } from './themeStore'
type Explorer1Theme = 'defaultTheme' | 'ThemeInternal' | 'ThemeEdu'

const getConfig = (config) => {
export const getConfig = (config) => {
// default values
let defaultMethod: string = 'css'
let options: string[] | undefined = undefined
Expand Down Expand Up @@ -40,6 +40,7 @@ const getConfig = (config) => {

export const withGlobals = (StoryFn, context) => {
const useTheme = useThemeStore()
// function useTheme((context) => useThemeStore)
const { themesConfig, variantsConfig } = context.globals
const { options, method } = getConfig(themesConfig)
const { options: variantOptions, method: variantMethod } = getConfig(variantsConfig)
Expand Down Expand Up @@ -119,7 +120,7 @@ export const withGlobals = (StoryFn, context) => {
useEffect(() => {
if (variant) {
const savedVariant = window.localStorage.getItem('data-variant')
document.body.classList.remove(savedVariant)
if (savedVariant) document.body.classList.remove(savedVariant)
document.body.classList.add(variant)
window.localStorage.setItem('data-variant', variant)
}
Expand Down
6 changes: 3 additions & 3 deletions apps/vue-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"init-msw": "msw init public/"
},
"dependencies": {
"@explorer-1/common": "workspace:*",
"@explorer-1/common-storybook": "workspace:*",
"@explorer-1/vue": "workspace:*",
"@fancyapps/ui": "^4.0.26",
"@tailwindcss/forms": "^0.5.7",
"click-outside-vue3": "^4.0.1",
Expand All @@ -38,12 +41,9 @@
"vue3-compare-image": "^1.2.5"
},
"devDependencies": {
"@explorer-1/common": "workspace:*",
"@explorer-1/common-storybook": "workspace:*",
"@explorer-1/html": "workspace:*",
"@explorer-1/prettier-config": "workspace:*",
"@explorer-1/tsconfig": "workspace:*",
"@explorer-1/vue": "workspace:*",
"@rushstack/eslint-patch": "^1.2.0",
"@storybook/addon-a11y": "^8.1.6",
"@storybook/addon-essentials": "^8.1.6",
Expand Down
4 changes: 4 additions & 0 deletions apps/vue-storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extends": "@explorer-1/tsconfig/storybook.json",
"compilerOptions": {
"moduleResolution": "bundler",
"module": "ESNext"
},
"exclude": ["node_modules"],
"include": ["./**/*"]
}
4 changes: 2 additions & 2 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
},
"prettier": "@explorer-1/prettier-config",
"dependencies": {
"@explorer-1/common": "workspace:*",
"@explorer-1/vue": "workspace:*",
"@fancyapps/ui": "^4.0.26",
"@nuxt/kit": "^3.11.2",
"@nuxtjs/tailwindcss": "^6.12.0",
Expand All @@ -53,9 +55,7 @@
"vue3-compare-image": "^1.2.5"
},
"devDependencies": {
"@explorer-1/common": "workspace:*",
"@explorer-1/prettier-config": "workspace:*",
"@explorer-1/vue": "workspace:*",
"@nuxt/devtools": "^1.2.0",
"@nuxt/module-builder": "^0.7.0",
"@nuxt/schema": "^3.11.2",
Expand Down
3 changes: 0 additions & 3 deletions packages/nuxt/playground/eslint.config.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion packages/nuxt/playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default defineNuxtConfig({
modules: ['@nuxt/eslint', '../src/module'],
modules: ['../src/module'],
explorer1: {},
devtools: { enabled: true }
})
4 changes: 0 additions & 4 deletions packages/nuxt/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,5 @@
},
"dependencies": {
"nuxt": "^3.11.2"
},
"devDependencies": {
"@nuxt/eslint": "^0.3.13",
"@explorer-1/eslint-config": "workspace:*"
}
}
9 changes: 4 additions & 5 deletions packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default defineNuxtModule<ModuleOptions>({
})
} // types
addImportsSources({
from: '@explorer-1/vue/src/interfaces',
from: '@explorer-1/vue/interfaces',
imports: ['ImageObject', 'Explorer1Theme']
})
if (options.includePageTemplates) {
Expand All @@ -107,15 +107,14 @@ export default defineNuxtModule<ModuleOptions>({
}
if (options.includeStore) {
await installModule('@pinia/nuxt', {
autoImports: ['useThemeStore'],
storesDirs: ['./store/**', resolver.resolve(runtimeDir, 'store')]
storesDirs: ['./store/**']
})
addImportsSources({
from: '@explorer-1/vue/src/store/theme',
from: '@explorer-1/vue',
imports: ['useThemeStore']
})
addImportsSources({
from: '@explorer-1/vue/src/store/header',
from: '@explorer-1/vue',
imports: ['useHeaderStore']
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/runtime/plugins/dayjs.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import dayjs from '@explorer-1/vue/src/utils/dayjs'
import dayjs from '@explorer-1/vue'
export default dayjs
2 changes: 1 addition & 1 deletion packages/nuxt/src/runtime/plugins/filters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import filters from '@explorer-1/vue/src/utils/filters'
import filters from '@explorer-1/vue'
import { defineNuxtPlugin } from 'nuxt/app'

export default defineNuxtPlugin((nuxtApp) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/runtime/store/header.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { useHeaderStore } from '@explorer-1/vue/src/store/header'
import useHeaderStore from '@explorer-1/vue'

export default useHeaderStore
2 changes: 1 addition & 1 deletion packages/nuxt/src/runtime/store/theme.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { useThemeStore } from '@explorer-1/vue/src/store/theme'
import useThemeStore from '@explorer-1/vue'

export default useThemeStore
Loading

0 comments on commit dfbae91

Please sign in to comment.