mirror of https://github.com/nocodb/nocodb
Braks
2 years ago
committed by
GitHub
82 changed files with 694 additions and 912 deletions
@ -1,11 +1,17 @@
|
||||
<script setup lang="ts"> |
||||
import { computed, provideTheme, useRoute } from '#imports' |
||||
|
||||
const route = useRoute() |
||||
|
||||
const disableBaseLayout = $computed(() => route.path.startsWith('/nc/view') || route.path.startsWith('/nc/form')) |
||||
const disableBaseLayout = computed(() => route.path.startsWith('/nc/view') || route.path.startsWith('/nc/form')) |
||||
|
||||
provideTheme() |
||||
</script> |
||||
|
||||
<template> |
||||
<NuxtLayout :name="disableBaseLayout ? false : 'base'"> |
||||
<NuxtPage /> |
||||
</NuxtLayout> |
||||
<a-config-provider> |
||||
<NuxtLayout :name="disableBaseLayout ? false : 'base'"> |
||||
<NuxtPage /> |
||||
</NuxtLayout> |
||||
</a-config-provider> |
||||
</template> |
||||
|
@ -1,4 +0,0 @@
|
||||
:root { |
||||
--primary: #00b786; |
||||
--secondary: #8ceaf6; |
||||
} |
@ -1,19 +0,0 @@
|
||||
::-webkit-scrollbar { |
||||
width: .7em; |
||||
height: .7em |
||||
} |
||||
|
||||
::-webkit-scrollbar-button { |
||||
background: #77777722 |
||||
} |
||||
|
||||
::-webkit-scrollbar-track-piece { |
||||
background: #66666622 |
||||
} |
||||
|
||||
::-webkit-scrollbar-thumb { |
||||
background: #888; |
||||
border-radius: .7em; |
||||
border: .15em solid #00000000; |
||||
background-clip: padding-box; |
||||
} |
@ -0,0 +1,60 @@
|
||||
import { ConfigProvider } from 'ant-design-vue' |
||||
import type { Theme as AntTheme } from 'ant-design-vue/es/config-provider' |
||||
import { useStorage } from '@vueuse/core' |
||||
import { NOCO, hexToRGB, themeV2Colors, toRefs, useCssVar, useInjectionState } from '#imports' |
||||
|
||||
interface ThemeConfig extends AntTheme { |
||||
primaryColor: string |
||||
accentColor: string |
||||
} |
||||
|
||||
const [setup, use] = useInjectionState((config?: Partial<ThemeConfig>) => { |
||||
const primaryColor = useCssVar('--color-primary', typeof document !== 'undefined' ? document.documentElement : null) |
||||
const accentColor = useCssVar('--color-accent', typeof document !== 'undefined' ? document.documentElement : null) |
||||
|
||||
/** current theme config */ |
||||
const currentTheme = useStorage<ThemeConfig>( |
||||
`${NOCO}db-theme`, |
||||
{ |
||||
primaryColor: themeV2Colors['royal-blue'].DEFAULT, |
||||
accentColor: themeV2Colors.pink['500'], |
||||
}, |
||||
localStorage, |
||||
{ mergeDefaults: true }, |
||||
) |
||||
|
||||
/** set initial config */ |
||||
setTheme(config ?? currentTheme.value) |
||||
|
||||
/** set theme (persists in localstorage) */ |
||||
function setTheme(theme: Partial<ThemeConfig>) { |
||||
// convert hex colors to rgb values
|
||||
if (theme.primaryColor) primaryColor.value = hexToRGB(theme.primaryColor) |
||||
if (theme.accentColor) accentColor.value = hexToRGB(theme.accentColor) |
||||
|
||||
currentTheme.value = theme as ThemeConfig |
||||
|
||||
ConfigProvider.config({ |
||||
theme, |
||||
}) |
||||
} |
||||
|
||||
return { |
||||
theme: currentTheme, |
||||
setTheme, |
||||
} |
||||
}) |
||||
|
||||
export const provideTheme = setup |
||||
|
||||
export function useTheme(config?: Partial<ThemeConfig>) { |
||||
const theme = use() |
||||
|
||||
if (!theme) { |
||||
return setup(config) |
||||
} else { |
||||
if (config) theme.setTheme(config) |
||||
} |
||||
|
||||
return theme |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,6 @@
|
||||
import { Menu as AntMenu, ConfigProvider } from 'ant-design-vue' |
||||
import { defineNuxtPlugin, themeColors } from '#imports' |
||||
import { Menu as AntMenu } from 'ant-design-vue' |
||||
import { defineNuxtPlugin } from '#imports' |
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => { |
||||
ConfigProvider.config({ |
||||
theme: { |
||||
primaryColor: themeColors.primary, |
||||
}, |
||||
}) |
||||
|
||||
nuxtApp.vueApp.component(AntMenu.name, AntMenu) |
||||
}) |
||||
|
@ -1,29 +0,0 @@
|
||||
import type { ThemeDefinition } from 'vuetify' |
||||
import { createVuetify } from 'vuetify' |
||||
import { defineNuxtPlugin } from 'nuxt/app' |
||||
|
||||
// todo: exclude unused components
|
||||
// Import everything
|
||||
import * as components from 'vuetify/components' |
||||
|
||||
import { themeColors } from '~/utils/colorsUtils' |
||||
|
||||
const ncLightTheme: ThemeDefinition = { |
||||
dark: false, |
||||
colors: themeColors, |
||||
} |
||||
|
||||
export const createVuetifyPlugin = () => |
||||
createVuetify({ |
||||
components, |
||||
theme: { |
||||
defaultTheme: 'ncLightTheme', |
||||
themes: { |
||||
ncLightTheme, |
||||
}, |
||||
}, |
||||
}) |
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => { |
||||
nuxtApp.vueApp.use(createVuetifyPlugin()) |
||||
}) |
Loading…
Reference in new issue