-
Notifications
You must be signed in to change notification settings - Fork 92
add light and dark mode toggle to home page #7430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
bbf16a9
add light and dark mode toggle to home page
kruulik 801c22b
closer match to chakra styles
kruulik 73f564d
Merge branch 'main' into karolis-darkmode
kruulik ac2c5e6
update changelog
kruulik bb2f391
Update clients/fidesui/src/hooks/useThemeMode.tsx
kruulik f96124f
Update clients/admin-ui/src/home/HomeContainer.tsx
kruulik b82df1d
wrap localstore in try catch
kruulik 0a87e0f
scope height constraints to admin-ui only
kruulik 68bc0f5
lint
kruulik ff98584
cleanup unwanted change
kruulik 20411fa
reduce changes
kruulik 2316cb6
undo changelog
kruulik 44cb409
add changelog
kruulik a98d963
Merge branch 'main' into karolis-darkmode
kruulik 399dd0f
simplify useThemeMode
kruulik 044267a
Merge branch 'karolis-darkmode' of https://github.com/ethyca/fides in…
kruulik 09666a4
Merge branch 'main' into karolis-darkmode
kruulik dce89e0
lint fix
kruulik 9714cac
Merge branch 'karolis-darkmode' of https://github.com/ethyca/fides in…
kruulik c1756c3
Merge branch 'main' into karolis-darkmode
kruulik 999c068
update flex
kruulik 1ac3f6a
remove redundant spreads
kruulik 22c1f5b
remove orphaned code
kruulik 4409ecc
clean up and simplify
kruulik 809d01a
switch inline styles for tailwind
kruulik fded087
set to locked by default
kruulik 6e71545
Merge branch 'main' into karolis-darkmode
kruulik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| type: Added | ||
| description: Adds an (alpha) light/dark mode capability to the Admin UI Home page | ||
| pr: 7430 | ||
| labels: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import type { ThemeMode } from "fidesui"; | ||
| import { Icons, Segmented, useThemeMode } from "fidesui"; | ||
|
|
||
| // NOTE: This button is temporary, only for testing in dev. | ||
|
|
||
| export const ThemeModeSegmented = () => { | ||
| const { mode, setMode } = useThemeMode(); | ||
|
|
||
| return ( | ||
| <Segmented | ||
| size="small" | ||
| value={mode} | ||
| onChange={(value) => setMode(value as ThemeMode)} | ||
| options={[ | ||
| { | ||
| label: <Icons.Light size={14} />, | ||
| value: "light", | ||
| }, | ||
| { | ||
| label: <Icons.Asleep size={14} />, | ||
| value: "dark", | ||
| }, | ||
| ]} | ||
| /> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,68 @@ | ||
| import { ChakraFlex as Flex } from "fidesui"; | ||
| import { | ||
| ConfigProvider, | ||
| darkAntTheme, | ||
| defaultAntTheme, | ||
| Flex, | ||
| ThemeModeProvider, | ||
| useThemeMode, | ||
| } from "fidesui"; | ||
| import palette from "fidesui/src/palette/palette.module.scss"; | ||
| import * as React from "react"; | ||
|
|
||
| import { useFlags } from "~/features/common/features"; | ||
| import Layout from "~/features/common/Layout"; | ||
| import { ThemeModeSegmented } from "~/features/common/ThemeModeToggle"; | ||
|
|
||
| import HomeBanner from "./HomeBanner"; | ||
| import HomeContent from "./HomeContent"; | ||
|
|
||
| const HomeContainer = () => ( | ||
| <Layout title="Home" padded={false}> | ||
| <Flex direction="column" gap={10} pb={6}> | ||
| <HomeBanner /> | ||
| <HomeContent /> | ||
| </Flex> | ||
| </Layout> | ||
| ); | ||
| const HomeContainerInner = () => { | ||
| const { resolvedMode } = useThemeMode(); | ||
| const { | ||
| flags: { alphaDarkMode }, | ||
| } = useFlags(); | ||
|
|
||
| const activeTheme = resolvedMode === "dark" ? darkAntTheme : defaultAntTheme; | ||
| const bgColor = | ||
| resolvedMode === "dark" | ||
| ? palette.FIDESUI_BG_MINOS | ||
| : palette.FIDESUI_FULL_WHITE; | ||
|
|
||
| return ( | ||
| <ConfigProvider theme={activeTheme}> | ||
| {/* this wrapping div can be removed once global theming is applied */} | ||
| <div className="min-h-full w-full" style={{ backgroundColor: bgColor }}> | ||
| <Layout title="Home" padded={false}> | ||
| <Flex vertical gap={40} className="pb-6"> | ||
| {/* NOTE: temporary button placement for testing */} | ||
| {alphaDarkMode && ( | ||
| <Flex className="absolute pl-2 pt-2"> | ||
| <ThemeModeSegmented /> | ||
| </Flex> | ||
| )} | ||
|
|
||
| <HomeBanner /> | ||
| <HomeContent /> | ||
| </Flex> | ||
| </Layout> | ||
| </div> | ||
| </ConfigProvider> | ||
| ); | ||
| }; | ||
|
|
||
| const HomeContainer = () => { | ||
| const { | ||
| flags: { alphaDarkMode }, | ||
| } = useFlags(); | ||
| return ( | ||
| <ThemeModeProvider | ||
| defaultMode="light" | ||
| locked={!alphaDarkMode} | ||
| wrapperStyle={{ width: "100%" }} | ||
| > | ||
| <HomeContainerInner /> | ||
| </ThemeModeProvider> | ||
| ); | ||
| }; | ||
|
|
||
| export default HomeContainer; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { theme, ThemeConfig } from "antd"; | ||
|
|
||
| import palette from "../palette/palette.module.scss"; | ||
| import { defaultAntTheme } from "./default-theme"; | ||
|
|
||
| /** | ||
| * Dark mode theme for Ant Design components. | ||
| * Uses Ant Design's built-in darkAlgorithm for automatic dark color generation, | ||
| * with custom overrides to match the Fides brand palette. | ||
| */ | ||
| export const darkAntTheme: ThemeConfig = { | ||
| ...defaultAntTheme, | ||
| algorithm: theme.darkAlgorithm, | ||
| cssVar: true, | ||
| token: { | ||
| ...defaultAntTheme.token, | ||
| colorBgBase: palette.FIDESUI_BG_MINOS, | ||
| colorTextBase: palette.FIDESUI_CORINTH, | ||
| colorText: palette.FIDESUI_CORINTH, | ||
| colorTextHeading: palette.FIDESUI_CORINTH, | ||
| colorPrimary: palette.FIDESUI_CORINTH, | ||
| colorBgContainer: palette.FIDESUI_BG_MINOS, | ||
| colorBorder: "#3a3a3a", | ||
| }, | ||
| components: { | ||
| ...defaultAntTheme.components, | ||
| Layout: { | ||
| bodyBg: palette.FIDESUI_BG_MINOS, | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| // Main exports for Ant Design theme system | ||
| export { darkAntTheme } from "./dark-theme"; | ||
| export { createDefaultAntTheme, defaultAntTheme } from "./default-theme"; | ||
| export type { ThemeConfig } from "antd/es"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| export type { UseFormModalOptions } from "./useFormModal"; | ||
| export { useFormModal } from "./useFormModal"; | ||
| export type { ThemeMode, ThemeModeProviderProps } from "./useThemeMode"; | ||
| export { ThemeModeProvider, useThemeMode } from "./useThemeMode"; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The theme will only ever be applied to the child contents of this wrapper. This is a pattern we could use elsewhere to start adding theming in sections, without being blocked by a global migration from Chakra to Ant.