diff --git a/packages/extension/src/components/App.tsx b/packages/extension/src/components/App.tsx index a86907b2..1f2803e0 100644 --- a/packages/extension/src/components/App.tsx +++ b/packages/extension/src/components/App.tsx @@ -17,7 +17,7 @@ import { TabContextProvider } from "@/providers/TabContextProvider" import { Ipc, TabCommand } from "@/services/ipc" import { Settings } from "@/services/settings/settings" import { ServiceWorkerData } from "@/services/serviceWorkerData" -import { useTheme } from "@/hooks/useTheme" +import { useTheme, themeContext } from "@/hooks/useTheme" import type { ShowToastParam } from "@/types" ServiceWorkerData.init() @@ -31,7 +31,7 @@ export function App({ rootElm }: Props) { // rootElm is the shadow root; the theme attribute goes on its host so that // the `:host()` selectors in the stylesheets can match it. - useTheme(rootElm instanceof ShadowRoot ? rootElm.host : rootElm) + const theme = useTheme(rootElm instanceof ShadowRoot ? rootElm.host : rootElm) useEffect(() => { const handleShowToast = ( @@ -75,20 +75,22 @@ export function App({ rootElm }: Props) { }, []) return ( - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + ) } diff --git a/packages/extension/src/components/Common.module.css b/packages/extension/src/components/Common.module.css index 43c8932a..05ae2b32 100644 --- a/packages/extension/src/components/Common.module.css +++ b/packages/extension/src/components/Common.module.css @@ -13,6 +13,24 @@ } } +/* + * Composed from other CSS modules (`composes`), which bypasses Tailwind, so + * the dark theme selectors are spelled out instead of `@variant dark`. + */ +:host([data-sc-theme="dark"]) .button, +[data-sc-theme="dark"] .button { + border-color: #4b5563; /* gray-600 */ + background-color: #1f2937; /* gray-800 */ + + &:hover { + background-color: #374151; /* gray-700 */ + } + + svg { + fill: #d1d5db; /* gray-300 */ + } +} + .shadow-xl { box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), diff --git a/packages/extension/src/components/Popup.module.css b/packages/extension/src/components/Popup.module.css index 59724e2b..40d46117 100644 --- a/packages/extension/src/components/Popup.module.css +++ b/packages/extension/src/components/Popup.module.css @@ -41,6 +41,7 @@ --sc-bd-color-s: 10%; --sc-bd-color-l: 26%; --sc-font-color: #e2e8f0; + --sc-icon-color: var(--sc-font-color); --foreground: 213 31% 91%; /* Hover color: lighter than the background, unlike the light theme. */ @@ -68,7 +69,7 @@ } .previewLabel { - @apply font-mono text-gray-800; + @apply font-mono text-gray-800 dark:text-gray-200; font-size: 19.2px; } diff --git a/packages/extension/src/components/Popup.tsx b/packages/extension/src/components/Popup.tsx index 516d9e63..659dda5c 100644 --- a/packages/extension/src/components/Popup.tsx +++ b/packages/extension/src/components/Popup.tsx @@ -8,11 +8,12 @@ import { useSidePanelNavigation } from "@/hooks/useSidePanelNavigation" import { useSidePanelAutoClose } from "@/hooks/useSidePanelAutoClose" import { useSelectContext } from "@/hooks/useSelectContext" import { popupContext } from "@/hooks/usePopupContext" +import { useThemeContext } from "@/hooks/useTheme" import { isMac, onHover, cn } from "@/lib/utils" import { findUserStyleValue, - hasUserStyle, hasUserColors, + usesIconColor, toCssVariables, } from "@/services/option/userStyles" import { t } from "@/services/i18n" @@ -102,9 +103,13 @@ export const Popup = forwardRef( setDetectSelectionEnabled(!hover) } - const hasIconColor = hasUserStyle( + const hasCustomColors = hasUserColors(userSettings?.userStyles) + // The dark theme paints recolorable icons (not favicons or brand icons) + // in its own icon color, as the global icon color setting would: they + // are mostly black glyphs that would vanish on the dark background. + const hasIconColor = usesIconColor( userSettings?.userStyles, - STYLE_VARIABLE.ICON_COLOR, + useThemeContext() === "dark", ) return ( @@ -130,9 +135,7 @@ export const Popup = forwardRef( alignOffset={alignOffset} className={cn(css.popup, isPreview && "z-10 mt-2")} style={userStyles} - data-custom-colors={ - hasUserColors(userSettings?.userStyles) || undefined - } + data-custom-colors={hasCustomColors || undefined} {...onHover(handleOnHover, true)} > {!isContextMenu ? : null} diff --git a/packages/extension/src/components/help/PageActionHelp.tsx b/packages/extension/src/components/help/PageActionHelp.tsx index 1f4059e7..191c9f1f 100644 --- a/packages/extension/src/components/help/PageActionHelp.tsx +++ b/packages/extension/src/components/help/PageActionHelp.tsx @@ -44,7 +44,7 @@ export const PageActionHelp = ({ className }: Props) => {