fix: resolve issue #6025 - default color selection in appearance page

- Fix default color selection logic in all color picker components
- Use existing helper functions (isDefaultColor, isDefaultColorPrimary, etc.)
- Ensure default colors are properly highlighted when active
- Apply fix to all color pickers: primary, accent, destructive, main view, and background

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Louis 2025-08-15 19:00:13 +02:00
parent 56fa4f9677
commit 38b0202365
5 changed files with 20 additions and 15 deletions

View File

@ -1,4 +1,4 @@
import { useAppearance } from '@/hooks/useAppearance' import { useAppearance, isDefaultColorAccent } from '@/hooks/useAppearance'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { RgbaColor, RgbaColorPicker } from 'react-colorful' import { RgbaColor, RgbaColorPicker } from 'react-colorful'
import { IconColorPicker } from '@tabler/icons-react' import { IconColorPicker } from '@tabler/icons-react'
@ -37,10 +37,11 @@ export function ColorPickerAppAccentColor() {
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
{predefineAppAccentBgColor.map((item, i) => { {predefineAppAccentBgColor.map((item, i) => {
const isSelected = const isSelected =
item.r === appAccentBgColor.r && (item.r === appAccentBgColor.r &&
item.g === appAccentBgColor.g && item.g === appAccentBgColor.g &&
item.b === appAccentBgColor.b && item.b === appAccentBgColor.b &&
item.a === appAccentBgColor.a item.a === appAccentBgColor.a) ||
(isDefaultColorAccent(appAccentBgColor) && isDefaultColorAccent(item))
return ( return (
<div <div
key={i} key={i}

View File

@ -1,4 +1,4 @@
import { useAppearance } from '@/hooks/useAppearance' import { useAppearance, isDefaultColor } from '@/hooks/useAppearance'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { RgbaColor, RgbaColorPicker } from 'react-colorful' import { RgbaColor, RgbaColorPicker } from 'react-colorful'
import { IconColorPicker } from '@tabler/icons-react' import { IconColorPicker } from '@tabler/icons-react'
@ -57,10 +57,11 @@ export function ColorPickerAppBgColor() {
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
{predefineAppBgColor.map((item, i) => { {predefineAppBgColor.map((item, i) => {
const isSelected = const isSelected =
item.r === appBgColor.r && (item.r === appBgColor.r &&
item.g === appBgColor.g && item.g === appBgColor.g &&
item.b === appBgColor.b && item.b === appBgColor.b &&
item.a === appBgColor.a item.a === appBgColor.a) ||
(isDefaultColor(appBgColor) && isDefaultColor(item))
return ( return (
<div <div
key={i} key={i}

View File

@ -1,4 +1,4 @@
import { useAppearance } from '@/hooks/useAppearance' import { useAppearance, isDefaultColorDestructive } from '@/hooks/useAppearance'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { RgbaColor, RgbaColorPicker } from 'react-colorful' import { RgbaColor, RgbaColorPicker } from 'react-colorful'
import { IconColorPicker } from '@tabler/icons-react' import { IconColorPicker } from '@tabler/icons-react'
@ -42,10 +42,11 @@ export function ColorPickerAppDestructiveColor() {
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
{predefineAppDestructiveBgColor.map((item, i) => { {predefineAppDestructiveBgColor.map((item, i) => {
const isSelected = const isSelected =
item.r === appDestructiveBgColor.r && (item.r === appDestructiveBgColor.r &&
item.g === appDestructiveBgColor.g && item.g === appDestructiveBgColor.g &&
item.b === appDestructiveBgColor.b && item.b === appDestructiveBgColor.b &&
item.a === appDestructiveBgColor.a item.a === appDestructiveBgColor.a) ||
(isDefaultColorDestructive(appDestructiveBgColor) && isDefaultColorDestructive(item))
return ( return (
<div <div
key={i} key={i}

View File

@ -1,4 +1,4 @@
import { useAppearance } from '@/hooks/useAppearance' import { useAppearance, isDefaultColorMainView } from '@/hooks/useAppearance'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { RgbaColor, RgbaColorPicker } from 'react-colorful' import { RgbaColor, RgbaColorPicker } from 'react-colorful'
import { IconColorPicker } from '@tabler/icons-react' import { IconColorPicker } from '@tabler/icons-react'
@ -30,10 +30,11 @@ export function ColorPickerAppMainView() {
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
{predefineAppMainViewBgColor.map((item, i) => { {predefineAppMainViewBgColor.map((item, i) => {
const isSelected = const isSelected =
item.r === appMainViewBgColor.r && (item.r === appMainViewBgColor.r &&
item.g === appMainViewBgColor.g && item.g === appMainViewBgColor.g &&
item.b === appMainViewBgColor.b && item.b === appMainViewBgColor.b &&
item.a === appMainViewBgColor.a item.a === appMainViewBgColor.a) ||
(isDefaultColorMainView(appMainViewBgColor) && isDefaultColorMainView(item))
return ( return (
<div <div
key={i} key={i}

View File

@ -1,4 +1,4 @@
import { useAppearance } from '@/hooks/useAppearance' import { useAppearance, isDefaultColorPrimary } from '@/hooks/useAppearance'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { RgbaColor, RgbaColorPicker } from 'react-colorful' import { RgbaColor, RgbaColorPicker } from 'react-colorful'
import { IconColorPicker } from '@tabler/icons-react' import { IconColorPicker } from '@tabler/icons-react'
@ -42,10 +42,11 @@ export function ColorPickerAppPrimaryColor() {
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
{predefineappPrimaryBgColor.map((item, i) => { {predefineappPrimaryBgColor.map((item, i) => {
const isSelected = const isSelected =
item.r === appPrimaryBgColor.r && (item.r === appPrimaryBgColor.r &&
item.g === appPrimaryBgColor.g && item.g === appPrimaryBgColor.g &&
item.b === appPrimaryBgColor.b && item.b === appPrimaryBgColor.b &&
item.a === appPrimaryBgColor.a item.a === appPrimaryBgColor.a) ||
(isDefaultColorPrimary(appPrimaryBgColor) && isDefaultColorPrimary(item))
return ( return (
<div <div
key={i} key={i}