mirror of
https://github.com/fmhy/edit.git
synced 2026-03-11 08:55:38 +00:00
* Add custom theme color selector to ColorPicker Introduces a CustomColorSelector component and integrates it into the ColorPicker, allowing users to define and persist custom link, text, and background colors for the site theme. Updates dependencies to include tinycolor2 and its types for color manipulation. * Add custom theme mode with improved color handling Introduces a 'custom' display mode for themes, allowing users to define and persist their own color schemes. Updates ColorPicker and ThemeDropdown to support the custom mode, including UI logic to prevent switching from custom to default modes without explicit action. Enhances themeHandler to register and apply custom themes from localStorage, manage previous mode restoration, and apply additional CSS variables for custom backgrounds. * Remove unused variables from theme components Cleaned up ColorPicker.vue and ThemeDropdown.vue by removing unused variables and functions related to theme state. This improves code clarity and maintainability. * Remove close on overlay click in color selector modal The @click.self handler was removed from the modal overlay, so clicking the overlay no longer closes the CustomColorSelector modal. * Increase card background lightening for custom themes Adjusted the lightening values for card backgrounds in custom themes from 5/8 to 10/15 to improve visual distinction between cards and the main background. * Improve custom color theme handling in color picker Exclude the 'custom' theme from preset theme options in ColorPicker.vue and correct button text color assignments for custom themes. In CustomColorSelector.vue, update button styles to reflect selected custom colors dynamically, enhancing the user experience when previewing and applying custom color selections. * Update Vue version and config improvements Bump Vue dependency to 3.5.0 in package.json. Add SCSS preprocessor option to VitePress config for modern compiler API. Refactor UnoCSS config to use kebab-case CSS property names for consistency. * Update pnpm lockfile Regenerated pnpm-lock.yaml to reflect updated dependencies. * Update header description text color style Replaces the description paragraph's class-based text color with an inline style using the CSS variable '--vp-c-text-1' for improved consistency with theming. * Add contrast warnings to color selector Introduces computed warnings for low contrast between link/text and background colors based on WCAG AA standards. Displays warning messages in the UI when contrast ratios fall below 4.5:1 to improve accessibility awareness.
140 lines
No EOL
3.2 KiB
TypeScript
140 lines
No EOL
3.2 KiB
TypeScript
/**
|
|
* Copyright (c) 2025 taskylizard. Apache License 2.0.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import type { Rule } from 'unocss'
|
|
import { colors, shortcuts } from '@fmhy/colors'
|
|
import {
|
|
defineConfig,
|
|
presetAttributify,
|
|
presetIcons,
|
|
presetUno,
|
|
presetWebFonts,
|
|
transformerDirectives
|
|
} from 'unocss'
|
|
|
|
const colorScales = [
|
|
'50',
|
|
'100',
|
|
'200',
|
|
'300',
|
|
'400',
|
|
'500',
|
|
'600',
|
|
'700',
|
|
'800',
|
|
'900',
|
|
'950'
|
|
] as const
|
|
|
|
const colorPattern = Object.keys(colors).join('|')
|
|
const createColorRules = (type: 'text' | 'bg' | 'border'): Rule[] => {
|
|
const property =
|
|
type === 'text'
|
|
? 'color'
|
|
: type === 'bg'
|
|
? 'background-color'
|
|
: 'border-color'
|
|
|
|
return colorScales.map(
|
|
(scale) =>
|
|
[
|
|
new RegExp(`^${type}-(${colorPattern})-${scale}$`),
|
|
([, color]) => ({ [property]: colors[color][scale] })
|
|
] as const
|
|
)
|
|
}
|
|
|
|
export default defineConfig({
|
|
content: {
|
|
filesystem: ['.vitepress/config.mts', '.vitepress/constants.ts']
|
|
},
|
|
theme: {
|
|
colors: {
|
|
...colors,
|
|
primary: 'var(--vp-c-brand-1)',
|
|
bg: 'var(--vp-c-bg)',
|
|
'bg-alt': 'var(--vp-c-bg-alt)',
|
|
'bg-elv': 'var(--vp-c-bg-elv)',
|
|
text: 'var(--vp-c-text-1)',
|
|
'text-2': 'var(--vp-c-text-2)',
|
|
div: 'var(--vp-c-divider)'
|
|
}
|
|
},
|
|
rules: [
|
|
// Brand color utilities
|
|
[
|
|
/^brand-(\d+)$/,
|
|
([, d]) => ({ color: `var(--vp-c-brand-${d})` })
|
|
] as const,
|
|
[
|
|
/^bg-brand-(\d+)$/,
|
|
([, d]) => ({ 'background-color': `var(--vp-c-brand-${d})` })
|
|
] as const,
|
|
[
|
|
/^border-brand-(\d+)$/,
|
|
([, d]) => ({ 'border-color': `var(--vp-c-brand-${d})` })
|
|
] as const,
|
|
[
|
|
/^text-brand-(\d+)$/,
|
|
([, d]) => ({ color: `var(--vp-c-brand-${d})` })
|
|
] as const,
|
|
|
|
// Color scale utilities
|
|
...createColorRules('text'),
|
|
...createColorRules('bg'),
|
|
...createColorRules('border'),
|
|
|
|
[
|
|
'kbd',
|
|
{
|
|
display: 'inline-block',
|
|
padding: '0.2em 0.4em',
|
|
'font-size': '0.75em',
|
|
'font-weight': '500',
|
|
'line-height': '1',
|
|
color: 'var(--vp-c-text-1)',
|
|
'background-color': 'rgb(var(--vp-c-bg-alt))',
|
|
'border-radius': '4px'
|
|
}
|
|
]
|
|
],
|
|
presets: [
|
|
presetUno(),
|
|
presetAttributify(),
|
|
presetIcons({
|
|
autoInstall: true,
|
|
scale: 1.2,
|
|
extraProperties: {
|
|
display: 'inline-block',
|
|
'vertical-align': 'middle'
|
|
},
|
|
collections: {
|
|
custom: {
|
|
privateersclub: () =>
|
|
fetch('https://megathread.pages.dev/favicon.svg').then((r) =>
|
|
r.text()
|
|
)
|
|
}
|
|
}
|
|
}),
|
|
presetWebFonts({
|
|
fonts: {
|
|
mono: 'Geist Mono'
|
|
}
|
|
})
|
|
],
|
|
transformers: [transformerDirectives()]
|
|
}) |