diff --git a/.changeset/fresh-guests-report.md b/.changeset/fresh-guests-report.md new file mode 100644 index 0000000..f5067ce --- /dev/null +++ b/.changeset/fresh-guests-report.md @@ -0,0 +1,5 @@ +--- +"saleor-app-crm": minor +--- + +Added dark mode and automatic color synchronization with Dashboard diff --git a/apps/crm/src/assets/mailchimp-dark.png b/apps/crm/src/assets/mailchimp-dark.png new file mode 100644 index 0000000..c997572 Binary files /dev/null and b/apps/crm/src/assets/mailchimp-dark.png differ diff --git a/apps/crm/src/assets/rudderstack.png b/apps/crm/src/assets/rudderstack.png index bf56b1a..369280b 100644 Binary files a/apps/crm/src/assets/rudderstack.png and b/apps/crm/src/assets/rudderstack.png differ diff --git a/apps/crm/src/lib/theme-synchronizer.tsx b/apps/crm/src/lib/theme-synchronizer.tsx new file mode 100644 index 0000000..a4f575b --- /dev/null +++ b/apps/crm/src/lib/theme-synchronizer.tsx @@ -0,0 +1,24 @@ +import { useAppBridge } from "@saleor/app-sdk/app-bridge"; +import { useTheme } from "@saleor/macaw-ui/next"; +import { memo, useEffect } from "react"; + +export function ThemeSynchronizer() { + const { appBridgeState } = useAppBridge(); + const { setTheme } = useTheme(); + + useEffect(() => { + if (!setTheme || !appBridgeState?.theme) { + return; + } + + if (appBridgeState.theme === "light") { + setTheme("defaultLight"); + } + + if (appBridgeState.theme === "dark") { + setTheme("defaultDark"); + } + }, [appBridgeState?.theme, setTheme]); + + return null; +} diff --git a/apps/crm/src/modules/providers/providers-list/providers-list.module.css b/apps/crm/src/modules/providers/providers-list/providers-list.module.css index 49e103c..9ab8bd3 100644 --- a/apps/crm/src/modules/providers/providers-list/providers-list.module.css +++ b/apps/crm/src/modules/providers/providers-list/providers-list.module.css @@ -29,3 +29,7 @@ width: 30px; height: 30px; } + +.list[data-macaw-theme="defaultDark"] :global(.darkmode-logo-invert) { + filter: invert(100%); +} diff --git a/apps/crm/src/modules/providers/providers-list/providers-list.tsx b/apps/crm/src/modules/providers/providers-list/providers-list.tsx index 84f4707..9a350a2 100644 --- a/apps/crm/src/modules/providers/providers-list/providers-list.tsx +++ b/apps/crm/src/modules/providers/providers-list/providers-list.tsx @@ -1,11 +1,12 @@ import { ProviderType } from "../providers-types"; import MailchimpLogo from "../../../assets/mailchimp.svg"; +import MailchimpLogoDark from "../../../assets/mailchimp-dark.png"; import SegmentLogo from "../../../assets/segment.png"; import RudderstackLogo from "../../../assets/rudderstack.png"; import { HTMLAttributes } from "react"; import clsx from "clsx"; import styles from "./providers-list.module.css"; -import { Box, MarketplaceIcon, Text } from "@saleor/macaw-ui/next"; +import { Box, MarketplaceIcon, Text, useTheme } from "@saleor/macaw-ui/next"; import { TextLink } from "../../ui/text-link/text-link"; type Props = { @@ -14,8 +15,10 @@ type Props = { } & HTMLAttributes; export const ProvidersList = ({ className, onProviderClick, activeProvider, ...props }: Props) => { + const { theme } = useTheme(); + return ( -