Skip to content

Commit

Permalink
fix: improve docs SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem committed Jul 4, 2024
1 parent d592a8c commit 00b92a2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 34 deletions.
5 changes: 2 additions & 3 deletions packages/docs/components/layout/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@

<template #right>
<div
v-if="isOptionsListVisible"
class="header__options"
class="header__options hidden sm:flex"
>
<VaButton
v-for="(link, index) in links"
Expand All @@ -52,7 +51,7 @@

<!-- options mobile menu -->
<VaButton
v-if="isOptionsMenuVisible"
class="sm:hidden"
aria-label="Open options menu"
preset="plain"
@click="toggleOptions"
Expand Down
13 changes: 6 additions & 7 deletions packages/nuxt/src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,27 @@ import {
type PartialGlobalConfig
} from 'vuestic-ui'
import { markRaw, computed, watch, type Ref } from 'vue'
import { useHead, ReactiveHead, defineNuxtPlugin, useCookie } from '#imports'
import type { VuesticOptions } from '../types'
import { useHead, ReactiveHead, defineNuxtPlugin, useCookie } from '#imports'
import NuxtLink from '#app/components/nuxt-link'
import configFromFile from '#vuestic-config'

import type { VuesticOptions } from '../types'

function getGlobalProperty (app, key) {
return app.config.globalProperties[key]
}

export default defineNuxtPlugin(async (nuxtApp) => {
export default defineNuxtPlugin((nuxtApp) => {
const { vueApp: app } = nuxtApp

// It's important to use `, because TS will compile qoutes to " and JSON will not be parsed...
const moduleOptions: VuesticOptions = JSON.parse(`<%= options.value %>`)
const moduleOptions: VuesticOptions = JSON.parse('<%= options.value %>')
const themeCookie = useCookie(moduleOptions.themeCookieKey)
const userConfig = configFromFile || moduleOptions.config || {}
const configWithColors: PartialGlobalConfig = {
...userConfig,
colors: {
currentPresetName: themeCookie.value || userConfig.colors?.currentPresetName || 'light',
...userConfig.colors,
...userConfig.colors
}
}

Expand All @@ -44,7 +43,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
VaDropdownPlugin,
VaToastPlugin,
VaModalPlugin,
ColorsClassesPlugin,
ColorsClassesPlugin
},
/** Do not import any components. Nuxt will import them automatically */
components: {}
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/services/color/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 1.10.0

- Removed colortranslator and reduced bundle size
- Color CSS variables now application specific if you have multiple vue apps on page
- Color CSS variables now application specific if you have multiple vue apps on page
- Removed extra predefined CSS variables with default theme
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const createColorConfigPlugin = (app: App, config?: PartialGlobalConfig)
return `${renderedColors};${renderedOnColors}`
}

const renderCSSVariablesStyleContent = (colors: ColorVariables = configColors, selector = ':root') => {
const renderCSSVariablesStyleContent = (colors: ColorVariables = configColors, selector = ':root, :host') => {
const colorNames = Object.keys(colors)

let result = `${selector} {
Expand Down
22 changes: 0 additions & 22 deletions packages/ui/src/styles/global/css-variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,6 @@
--va-form-element-border-width: 1px;
--va-form-element-border-radius: 0.25rem;

/* Colors */
// Accent
--va-primary: #154ec1;
--va-secondary: #767c88;
--va-success: #3d9209;
--va-info: #158de3;
--va-danger: #e42222;
--va-warning: #ffd43a;

// Background Colors
--va-background-primary: #f6f6f6;
--va-background-secondary: #ffffff;
--va-background-element: #ebf1f4;
--va-background-border: #dee5f2;

// Text Colors
--va-text-primary: #262824;
--va-text-inverted: #ffffff;

// Misc
--va-shadow: rgba(0, 0, 0, 0.12);
--va-focus: #49a8ff;
--va-gap-small: 0.25rem;
--va-gap-medium: 0.375rem;
--va-gap-large: 0.75rem;
Expand Down

0 comments on commit 00b92a2

Please sign in to comment.