Skip to content

Commit

Permalink
workaround for nuxt module (#475)
Browse files Browse the repository at this point in the history
* abandoning the nuxt module for now in the interest of time

* bumping version numbers of monorepo packages

* reverting storybook to use @explorer-1/vue directly

* minor cleanup
  • Loading branch information
stephiescastle authored Jun 28, 2024
1 parent 6286d2c commit 3a50775
Show file tree
Hide file tree
Showing 24 changed files with 413 additions and 77 deletions.
2 changes: 1 addition & 1 deletion apps/vue-storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import VueCompareImage from 'vue3-compare-image'
import { createPinia } from 'pinia'
import filters from '@explorer-1/vue/src/utils/filters'
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'
Expand Down
5 changes: 3 additions & 2 deletions apps/vue-storybook/.storybook/withGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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'

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
9 changes: 4 additions & 5 deletions apps/vue-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
"type": "module",
"scripts": {
"dev": "pnpm storybook",
"prepare": "pnpm prepare:public && pnpm prepare:public:edu && pnpm prepare:fontcss",
"prepare": "pnpm prepare:public && pnpm prepare:fontcss",
"prepare:public": "cp -R ./node_modules/@explorer-1/common/src/public/explorer-1/ ./public/explorer-1",
"prepare:public:edu": "cp -R ./node_modules/@explorer-1/common/src/public/explorer-1/ ./public/edu/explorer-1",
"prepare:fontcss": "cp ./node_modules/@explorer-1/common/src/scss/_fonts.scss ./public/css/font-face.css",
"storybook": "storybook dev -c .storybook -p 6006 --ci",
"build": "storybook build -c .storybook -o storybook_compiled",
Expand All @@ -29,6 +28,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 +40,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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
"url": "https://github.com/nasa-jpl/explorer-1"
},
"scripts": {
"clean": "rimraf \"**/node_modules\"",
"clean": "pnpm clean:nodemodules && pnpm clean:dist && pnpm clean:nuxt",
"clean:rimraf": "rimraf \"**/node_modules\"",
"clean:cache": "find . -name '.cache' -type d -prune -exec rm -rf '{}' +",
"clean:dist": "find . -name 'dist' -type d -prune -exec rm -rf '{}' +",
"clean:nodemodules": "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +",
"clean:nuxt": "find . -name '.nuxt' -type d -prune -exec rm -rf '{}' +",
"refresh": "pnpm clean && pnpm i",
"nuke": "rimraf pnpm-lock.yaml && pnpm refresh",
"preinstall": "npx --yes only-allow pnpm",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@explorer-1/common",
"version": "1.0.0",
"version": "1.0.1",
"private": false,
"publishConfig": {
"access": "public"
Expand Down
3 changes: 1 addition & 2 deletions packages/common/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ export default {
selectors: ['.ThemeEdu'],
extend: {
backgroundImage: {
// TODO: would prefer to not hardcode the /edu/ path here
'star-pattern': 'url(/edu/explorer-1/bg-stars-edu.png)'
'star-pattern': 'url(/explorer-1/bg-stars-edu.png)'
}
}
},
Expand Down
9 changes: 4 additions & 5 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
"lint": "eslint ./src",
"lint:fix": "eslint ./src --fix",
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
"prepare": "pnpm prepare:public && pnpm prepare:public:edu",
"prepare:public": "cp -R ./node_modules/@explorer-1/common/src/public/explorer-1/ ./src/runtime/public/explorer-1",
"prepare:public:edu": "cp -R ./node_modules/@explorer-1/common/src/public/explorer-1/ ./src/runtime/public/edu/explorer-1"
"prepare": "pnpm prepare:public",
"prepare:public": "cp -R ./node_modules/@explorer-1/common/src/public/explorer-1/ ./src/runtime/public/explorer-1"
},
"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 +54,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 3a50775

Please sign in to comment.