feat(settings): enhance accent color handling for dark mode
- Updated accent color logic to support dark mode by utilizing a new color mapping. - Refactored components to apply the correct accent color based on the current theme. - Improved styling consistency across the application by integrating dark and light color variants. This change enhances the user experience by ensuring that the accent colors adapt to the selected theme. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -102,9 +102,9 @@ export const ShadowDOM: FC<
|
||||
() => ({
|
||||
fontFamily: `${uiFont},"SN Pro", system-ui, sans-serif`,
|
||||
"--pointer": usePointerCursor ? "pointer" : "default",
|
||||
"--fo-a": hexToHslString(getAccentColorValue(accentColor)),
|
||||
"--fo-a": hexToHslString(getAccentColorValue(accentColor)[dark ? "dark" : "light"]),
|
||||
}),
|
||||
[uiFont, usePointerCursor, accentColor],
|
||||
[uiFont, usePointerCursor, accentColor, dark],
|
||||
)}
|
||||
id="shadow-html"
|
||||
data-motion-reduce={reduceMotion}
|
||||
|
||||
@@ -575,7 +575,7 @@ const ACCENT_COLORS: AccentColor[] = [
|
||||
const AccentColorSelector = () => {
|
||||
const { t } = useTranslation("settings")
|
||||
const accentColor = useUISettingKey("accentColor")
|
||||
|
||||
const isDark = useIsDark()
|
||||
return (
|
||||
<SettingItemGroup>
|
||||
<div className="mt-4 flex items-center justify-between">
|
||||
@@ -592,7 +592,7 @@ const AccentColorSelector = () => {
|
||||
className="group relative flex size-7 items-center justify-center rounded-full transition-all duration-200 hover:scale-110"
|
||||
onClick={() => setUISetting("accentColor", color)}
|
||||
style={{
|
||||
backgroundColor: colorValue,
|
||||
backgroundColor: colorValue[isDark ? "dark" : "light"],
|
||||
}}
|
||||
>
|
||||
{/* Selection ring */}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { useIsDark } from "@follow/hooks"
|
||||
import { getAccentColorValue } from "@follow/shared/settings/constants"
|
||||
import type { UISettings } from "@follow/shared/settings/interface"
|
||||
import { useUnreadAll } from "@follow/store/unread/hooks"
|
||||
@@ -52,11 +53,15 @@ const useUISettingSync = () => {
|
||||
root.style.fontSize = `${setting.uiTextSize * (mobile ? 1.125 : 1)}px`
|
||||
}, [setting.uiTextSize])
|
||||
|
||||
const isDark = useIsDark()
|
||||
useInsertionEffect(() => {
|
||||
const root = document.documentElement
|
||||
// 21.6 100% 50%;
|
||||
root.style.setProperty("--fo-a", hexToHslString(getAccentColorValue(setting.accentColor)))
|
||||
}, [setting.accentColor])
|
||||
root.style.setProperty(
|
||||
"--fo-a",
|
||||
hexToHslString(getAccentColorValue(setting.accentColor)[isDark ? "dark" : "light"]),
|
||||
)
|
||||
}, [setting.accentColor, isDark])
|
||||
|
||||
useInsertionEffect(() => {
|
||||
const root = document.documentElement
|
||||
|
||||
@@ -1,30 +1,40 @@
|
||||
import type { AccentColor } from "./interface"
|
||||
|
||||
export const getAccentColorValue = (color: AccentColor) => {
|
||||
switch (color) {
|
||||
case "blue": {
|
||||
return "#007AFF"
|
||||
}
|
||||
case "green": {
|
||||
return "#4CD964"
|
||||
}
|
||||
case "purple": {
|
||||
return "#9B36B7"
|
||||
}
|
||||
case "pink": {
|
||||
return "#FF2D55"
|
||||
}
|
||||
case "red": {
|
||||
return "#FF3B30"
|
||||
}
|
||||
case "yellow": {
|
||||
return "#FFCC00"
|
||||
}
|
||||
case "gray": {
|
||||
return "#8E8E93"
|
||||
}
|
||||
default: {
|
||||
return "#FF5C00" // orange
|
||||
}
|
||||
}
|
||||
const ACCENT_COLOR_MAP: Record<AccentColor, { light: string; dark: string }> = {
|
||||
orange: {
|
||||
light: "#FF6B35",
|
||||
dark: "#FF5C00",
|
||||
},
|
||||
blue: {
|
||||
light: "#007AFF",
|
||||
dark: "#409CFF",
|
||||
},
|
||||
green: {
|
||||
light: "#34C759",
|
||||
dark: "#30E85B",
|
||||
},
|
||||
purple: {
|
||||
light: "#AF52DE",
|
||||
dark: "#BF5AF2",
|
||||
},
|
||||
pink: {
|
||||
light: "#FF2D92",
|
||||
dark: "#FF69B4",
|
||||
},
|
||||
red: {
|
||||
light: "#FF3B30",
|
||||
dark: "#FF6B6B",
|
||||
},
|
||||
yellow: {
|
||||
light: "#FFD54F",
|
||||
dark: "#FFD60A",
|
||||
},
|
||||
gray: {
|
||||
light: "#8E8E93",
|
||||
dark: "#98989D",
|
||||
},
|
||||
}
|
||||
|
||||
export const getAccentColorValue = (color: AccentColor) => {
|
||||
return ACCENT_COLOR_MAP[color]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user