mirror of
https://github.com/fmhy/edit.git
synced 2025-11-28 00:41:20 +11:00
fix EVERYTHING unc
This commit is contained in:
parent
a424987ffa
commit
962a6bd66e
1 changed files with 46 additions and 130 deletions
|
|
@ -1,30 +1,8 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import { colors } from '@fmhy/colors'
|
import { colors } from '@fmhy/colors'
|
||||||
import { useStorage, useStyleTag } from '@vueuse/core'
|
import { useStorage, useStyleTag } from '@vueuse/core'
|
||||||
import { watch, onMounted } from 'vue'
|
import { watch, onMounted } from 'vue'
|
||||||
import Switch from './Switch.vue'
|
import Switch from './Switch.vue'
|
||||||
|
|
||||||
// Add Halloween colors
|
|
||||||
const halloweenColors = {
|
|
||||||
50: '#fff7ed',
|
|
||||||
100: '#ffedd5',
|
|
||||||
200: '#fed7aa',
|
|
||||||
300: '#fdba74',
|
|
||||||
400: '#fb923c',
|
|
||||||
500: '#FF6A00',
|
|
||||||
600: '#ea580c',
|
|
||||||
700: '#c2410c',
|
|
||||||
800: '#9a3412',
|
|
||||||
900: '#7c2d12',
|
|
||||||
950: '#431407'
|
|
||||||
}
|
|
||||||
|
|
||||||
// hall extend or something
|
|
||||||
const extendedColors = {
|
|
||||||
...colors,
|
|
||||||
halloween: halloweenColors
|
|
||||||
}
|
|
||||||
|
|
||||||
const colorScales = [
|
const colorScales = [
|
||||||
'50',
|
'50',
|
||||||
'100',
|
'100',
|
||||||
|
|
@ -39,18 +17,18 @@ const colorScales = [
|
||||||
'950'
|
'950'
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
type ColorNames = keyof typeof extendedColors
|
type ColorNames = keyof typeof colors
|
||||||
const selectedColor = useStorage<ColorNames>('preferred-color', 'swarm')
|
const selectedColor = useStorage<ColorNames>('preferred-color', 'swarm')
|
||||||
const isAmoledMode = useStorage('amoled-mode', false)
|
const isAmoledMode = useStorage('amoled-mode', false)
|
||||||
|
|
||||||
const colorOptions = Object.keys(extendedColors).filter(
|
const colorOptions = Object.keys(colors).filter(
|
||||||
(key) => typeof extendedColors[key as keyof typeof extendedColors] === 'object'
|
(key) => typeof colors[key as keyof typeof colors] === 'object'
|
||||||
) as Array<ColorNames>
|
) as Array<ColorNames>
|
||||||
|
|
||||||
const { css } = useStyleTag('', { id: 'brand-color' })
|
const { css } = useStyleTag('', { id: 'brand-color' })
|
||||||
|
|
||||||
const updateThemeColor = (colorName: ColorNames, amoledEnabled: boolean) => {
|
const updateThemeColor = (colorName: ColorNames, amoledEnabled: boolean) => {
|
||||||
const colorSet = extendedColors[colorName]
|
const colorSet = colors[colorName]
|
||||||
|
|
||||||
const cssVars = colorScales
|
const cssVars = colorScales
|
||||||
.map((scale) => `--vp-c-brand-${scale}: ${colorSet[scale]};`)
|
.map((scale) => `--vp-c-brand-${scale}: ${colorSet[scale]};`)
|
||||||
|
|
@ -58,122 +36,61 @@ const updateThemeColor = (colorName: ColorNames, amoledEnabled: boolean) => {
|
||||||
|
|
||||||
const htmlElement = document.documentElement
|
const htmlElement = document.documentElement
|
||||||
|
|
||||||
// Manage theme classes
|
|
||||||
if (colorName === 'halloween') {
|
|
||||||
htmlElement.classList.add('theme-halloween')
|
|
||||||
} else {
|
|
||||||
htmlElement.classList.remove('theme-halloween')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amoledEnabled) {
|
if (amoledEnabled) {
|
||||||
htmlElement.classList.add('theme-amoled')
|
htmlElement.classList.add('theme-amoled')
|
||||||
} else {
|
} else {
|
||||||
htmlElement.classList.remove('theme-amoled')
|
htmlElement.classList.remove('theme-amoled')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine dark background color based on AMOLED mode
|
|
||||||
const darkBg = amoledEnabled ? '#000000' : 'rgb(26, 26, 26)'
|
const darkBg = amoledEnabled ? '#000000' : 'rgb(26, 26, 26)'
|
||||||
const darkBgAlt = amoledEnabled ? '#000000' : 'rgb(23, 23, 23)'
|
const darkBgAlt = amoledEnabled ? '#000000' : 'rgb(23, 23, 23)'
|
||||||
const darkBgElv = amoledEnabled ? 'rgba(0, 0, 0, 0.9)' : 'rgba(23, 23, 23, 0.8)'
|
const darkBgElv = amoledEnabled ? 'rgba(0, 0, 0, 0.9)' : 'rgba(23, 23, 23, 0.8)'
|
||||||
const darkBgSoft = amoledEnabled ? '#000000' : 'rgb(23, 23, 23)'
|
const darkBgSoft = amoledEnabled ? '#000000' : 'rgb(23, 23, 23)'
|
||||||
|
|
||||||
// Apply Halloween theme backgrounds or normal backgrounds
|
css.value = `
|
||||||
if (colorName === 'halloween') {
|
:root {
|
||||||
const halloweenDarkBg = amoledEnabled ? '#000000' : 'rgb(15, 15, 15)'
|
${cssVars}
|
||||||
const halloweenDarkBgAlt = amoledEnabled ? '#000000' : 'rgb(12, 12, 12)'
|
--vp-c-brand-1: ${colorSet[500]};
|
||||||
const halloweenDarkBgElv = amoledEnabled ? 'rgba(0, 0, 0, 0.9)' : 'rgba(12, 12, 12, 0.8)'
|
--vp-c-brand-2: ${colorSet[600]};
|
||||||
|
--vp-c-brand-3: ${colorSet[800]};
|
||||||
|
--vp-c-brand-soft: ${colorSet[400]};
|
||||||
|
--vp-c-bg: #ffffff !important;
|
||||||
|
--vp-c-bg-alt: #f9f9f9 !important;
|
||||||
|
--vp-c-bg-elv: rgba(255, 255, 255, 0.7) !important;
|
||||||
|
--vp-c-bg-soft: #f9f9f9 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
${cssVars}
|
||||||
|
--vp-c-brand-1: ${colorSet[400]};
|
||||||
|
--vp-c-brand-2: ${colorSet[500]};
|
||||||
|
--vp-c-brand-3: ${colorSet[700]};
|
||||||
|
--vp-c-brand-soft: ${colorSet[300]};
|
||||||
|
--vp-c-bg: ${darkBg} !important;
|
||||||
|
--vp-c-bg-alt: ${darkBgAlt} !important;
|
||||||
|
--vp-c-bg-elv: ${darkBgElv} !important;
|
||||||
|
--vp-c-bg-soft: ${darkBgSoft} !important;
|
||||||
|
}
|
||||||
|
|
||||||
css.value = `
|
html, body {
|
||||||
:root {
|
background-color: #ffffff !important;
|
||||||
${cssVars}
|
}
|
||||||
--vp-c-brand-1: ${colorSet[500]};
|
|
||||||
--vp-c-brand-2: ${colorSet[600]};
|
.VPApp, .Layout, .VPContent, .VPHome, .VPHero, #app, .vp-doc {
|
||||||
--vp-c-brand-3: ${colorSet[800]};
|
background-color: #ffffff !important;
|
||||||
--vp-c-brand-soft: ${colorSet[400]};
|
}
|
||||||
}
|
|
||||||
|
.dark html, .dark body {
|
||||||
.dark {
|
background-color: ${darkBg} !important;
|
||||||
${cssVars}
|
}
|
||||||
--vp-c-brand-1: ${colorSet[400]};
|
|
||||||
--vp-c-brand-2: ${colorSet[500]};
|
.dark .VPApp, .dark .Layout, .dark .VPContent, .dark .VPHome, .dark .VPHero, .dark #app, .vp-doc {
|
||||||
--vp-c-brand-3: ${colorSet[700]};
|
background-color: ${darkBg} !important;
|
||||||
--vp-c-brand-soft: ${colorSet[300]};
|
}
|
||||||
--vp-c-bg: ${halloweenDarkBg} !important;
|
`
|
||||||
--vp-c-bg-alt: ${halloweenDarkBgAlt} !important;
|
|
||||||
--vp-c-bg-elv: ${halloweenDarkBgElv} !important;
|
|
||||||
--vp-c-bg-soft: ${halloweenDarkBgAlt} !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark html, .dark body {
|
|
||||||
background-color: ${halloweenDarkBg} !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark .VPApp, .dark .Layout, .dark .VPContent, .dark .VPHome, .dark .VPHero, .dark #app, .dark .vp-doc {
|
|
||||||
background-color: ${halloweenDarkBg} !important;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
} else {
|
|
||||||
css.value = `
|
|
||||||
:root {
|
|
||||||
${cssVars}
|
|
||||||
--vp-c-brand-1: ${colorSet[500]};
|
|
||||||
--vp-c-brand-2: ${colorSet[600]};
|
|
||||||
--vp-c-brand-3: ${colorSet[800]};
|
|
||||||
--vp-c-brand-soft: ${colorSet[400]};
|
|
||||||
--vp-c-bg: #ffffff !important;
|
|
||||||
--vp-c-bg-alt: #f9f9f9 !important;
|
|
||||||
--vp-c-bg-elv: rgba(255, 255, 255, 0.7) !important;
|
|
||||||
--vp-c-bg-soft: #f9f9f9 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark {
|
|
||||||
${cssVars}
|
|
||||||
--vp-c-brand-1: ${colorSet[400]};
|
|
||||||
--vp-c-brand-2: ${colorSet[500]};
|
|
||||||
--vp-c-brand-3: ${colorSet[700]};
|
|
||||||
--vp-c-brand-soft: ${colorSet[300]};
|
|
||||||
--vp-c-bg: ${darkBg} !important;
|
|
||||||
--vp-c-bg-alt: ${darkBgAlt} !important;
|
|
||||||
--vp-c-bg-elv: ${darkBgElv} !important;
|
|
||||||
--vp-c-bg-soft: ${darkBgSoft} !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html, body {
|
|
||||||
background-color: #ffffff !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.VPApp, .Layout, .VPContent, .VPHome, .VPHero, #app, .vp-doc {
|
|
||||||
background-color: #ffffff !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark html, .dark body {
|
|
||||||
background-color: ${darkBg} !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark .VPApp, .dark .Layout, .dark .VPContent, .dark .VPHome, .dark .VPHero, .dark #app, .dark .vp-doc {
|
|
||||||
background-color: ${darkBg} !important;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// Set Halloween theme ASAP if its the pref (only in browser)
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
const storedTheme = localStorage.getItem('preferred-color')
|
|
||||||
const storedAmoled = localStorage.getItem('amoled-mode')
|
|
||||||
|
|
||||||
if (!storedTheme || storedTheme === '"halloween"') {
|
|
||||||
document.documentElement.classList.add('theme-halloween')
|
|
||||||
}
|
|
||||||
if (storedAmoled === 'true') {
|
|
||||||
document.documentElement.classList.add('theme-amoled')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedColor.value === 'halloween') {
|
|
||||||
document.documentElement.classList.add('theme-halloween')
|
|
||||||
}
|
|
||||||
if (isAmoledMode.value) {
|
if (isAmoledMode.value) {
|
||||||
document.documentElement.classList.add('theme-amoled')
|
document.documentElement.classList.add('theme-amoled')
|
||||||
}
|
}
|
||||||
|
|
@ -203,10 +120,9 @@ const normalizeColorName = (colorName: string) =>
|
||||||
:title="normalizeColorName(color)"
|
:title="normalizeColorName(color)"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-else
|
|
||||||
class="inline-block w-6 h-6 rounded-full"
|
class="inline-block w-6 h-6 rounded-full"
|
||||||
:style="{ backgroundColor: extendedColors[color][500] }"
|
:style="{ backgroundColor: colors[color][500] }"
|
||||||
/>
|
></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue