mirror of
https://github.com/fmhy/edit.git
synced 2025-10-13 08:11:07 +11:00
halloween thingers 2
This commit is contained in:
parent
eab3cf981f
commit
8081a900d9
2 changed files with 50 additions and 8 deletions
|
@ -3,6 +3,27 @@ import { colors } from '@fmhy/colors'
|
|||
import { useStorage, useStyleTag } from '@vueuse/core'
|
||||
import { watch } from 'vue'
|
||||
|
||||
// Add Halloween colors locally
|
||||
const halloweenColors = {
|
||||
50: '#fff7ed',
|
||||
100: '#ffedd5',
|
||||
200: '#fed7aa',
|
||||
300: '#fdba74',
|
||||
400: '#fb923c',
|
||||
500: '#FF6A00',
|
||||
600: '#ea580c',
|
||||
700: '#c2410c',
|
||||
800: '#9a3412',
|
||||
900: '#7c2d12',
|
||||
950: '#431407'
|
||||
}
|
||||
|
||||
// Extend colors with Halloween theme
|
||||
const extendedColors = {
|
||||
...colors,
|
||||
halloween: halloweenColors
|
||||
}
|
||||
|
||||
const colorScales = [
|
||||
'50',
|
||||
'100',
|
||||
|
@ -17,17 +38,17 @@ const colorScales = [
|
|||
'950'
|
||||
] as const
|
||||
|
||||
type ColorNames = keyof typeof colors
|
||||
type ColorNames = keyof typeof extendedColors
|
||||
const selectedColor = useStorage<ColorNames>('preferred-color', 'swarm')
|
||||
|
||||
const colorOptions = Object.keys(colors).filter(
|
||||
(key) => typeof colors[key as keyof typeof colors] === 'object'
|
||||
const colorOptions = Object.keys(extendedColors).filter(
|
||||
(key) => typeof extendedColors[key as keyof typeof extendedColors] === 'object'
|
||||
) as Array<ColorNames>
|
||||
|
||||
const { css } = useStyleTag('', { id: 'brand-color' })
|
||||
|
||||
const updateThemeColor = (colorName: ColorNames) => {
|
||||
const colorSet = colors[colorName]
|
||||
const colorSet = extendedColors[colorName]
|
||||
|
||||
const cssVars = colorScales
|
||||
.map((scale) => `--vp-c-brand-${scale}: ${colorSet[scale]};`)
|
||||
|
@ -75,7 +96,7 @@ const normalizeColorName = (colorName: string) =>
|
|||
>
|
||||
<span
|
||||
class="inline-block w-6 h-6 rounded-full"
|
||||
:style="{ backgroundColor: colors[color][500] }"
|
||||
:style="{ backgroundColor: extendedColors[color][500] }"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -25,6 +25,27 @@ import {
|
|||
transformerDirectives
|
||||
} from 'unocss'
|
||||
|
||||
// Add Halloween colors to extend the existing 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'
|
||||
}
|
||||
|
||||
// Extend colors with Halloween theme
|
||||
const extendedColors = {
|
||||
...colors,
|
||||
halloween: halloweenColors
|
||||
}
|
||||
|
||||
const colorScales = [
|
||||
'50',
|
||||
'100',
|
||||
|
@ -39,7 +60,7 @@ const colorScales = [
|
|||
'950'
|
||||
] as const
|
||||
|
||||
const colorPattern = Object.keys(colors).join('|')
|
||||
const colorPattern = Object.keys(extendedColors).join('|')
|
||||
const createColorRules = (type: 'text' | 'bg' | 'border'): Rule[] => {
|
||||
const property =
|
||||
type === 'text'
|
||||
|
@ -52,7 +73,7 @@ const createColorRules = (type: 'text' | 'bg' | 'border'): Rule[] => {
|
|||
(scale) =>
|
||||
[
|
||||
new RegExp(`^${type}-(${colorPattern})-${scale}$`),
|
||||
([, color]) => ({ [property]: colors[color][scale] })
|
||||
([, color]) => ({ [property]: extendedColors[color][scale] })
|
||||
] as const
|
||||
)
|
||||
}
|
||||
|
@ -63,7 +84,7 @@ export default defineConfig({
|
|||
},
|
||||
theme: {
|
||||
colors: {
|
||||
...colors,
|
||||
...extendedColors,
|
||||
primary: 'var(--vp-c-brand-1)',
|
||||
bg: 'var(--vp-c-bg)',
|
||||
'bg-alt': 'var(--vp-c-bg-alt)',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue