-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): add more documentation around dark mode
- Loading branch information
Showing
4 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...src/app/(main)/(markdown)/(demos)/customization/dark-mode/DarkElevationColors.module.scss
This file contains 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,49 @@ | ||
@use "sass:map"; | ||
@use "@react-md/core" with ( | ||
$color-scheme: dark, | ||
$dark-elevation-colors: ( | ||
// this is really `$dark-theme-background-color` | ||
0: #121212, | ||
1: #1f1f1f, | ||
2: #242424, | ||
3: #262626, | ||
4: #282828, | ||
5: #282828, | ||
6: #2c2c2c, | ||
7: #2c2c2c, | ||
8: #2f2f2f, | ||
9: #2f2f2f, | ||
10: #2f2f2f, | ||
11: #2f2f2f, | ||
12: #333, | ||
13: #333, | ||
14: #333, | ||
15: #333, | ||
16: #353535, | ||
17: #353535, | ||
18: #353535, | ||
19: #353535, | ||
20: #353535, | ||
21: #353535, | ||
22: #353535, | ||
23: #353535, | ||
24: #383838, | ||
) | ||
); | ||
|
||
// NOTE: All the styles below are only required for this demo and should not be | ||
// used in your code. | ||
.container { | ||
@include core.use-dark-theme-elevation-colors; | ||
} | ||
|
||
@for $i from 1 through 24 { | ||
.elevation-#{$i} { | ||
@include core.box-shadow($i); | ||
|
||
// the real behavior is just to keep it empty | ||
@if not map.get(core.$dark-elevation-colors, $i) { | ||
@include core.set-dark-elevation-color($i, transparent); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
apps/docs/src/app/(main)/(markdown)/(demos)/customization/dark-mode/DarkElevationColors.tsx
This file contains 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,20 @@ | ||
import { Box } from "@react-md/core/box/Box"; | ||
import { cnb } from "cnbuilder"; | ||
import { type ReactElement } from "react"; | ||
import styles from "./DarkElevationColors.module.scss"; | ||
|
||
export default function DarkElevationColors(): ReactElement { | ||
return ( | ||
<Box grid className={styles.container}> | ||
{Array.from({ length: 25 }, (_, i) => ( | ||
<Box | ||
key={i} | ||
justify="center" | ||
className={cnb(i > 0 && styles[`elevation-${i}`])} | ||
> | ||
{i} | ||
</Box> | ||
))} | ||
</Box> | ||
); | ||
} |
71 changes: 71 additions & 0 deletions
71
apps/docs/src/app/(main)/(markdown)/(demos)/customization/dark-mode/DarkModeColors.tsx
This file contains 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,71 @@ | ||
import { ColorPreview } from "@react-md/code/ColorPreview"; | ||
import { InlineCode } from "@react-md/code/InlineCode"; | ||
import { tableCell } from "@react-md/core/table/tableCellStyles"; | ||
import { tableHeader } from "@react-md/core/table/tableHeaderStyles"; | ||
import { tableRow } from "@react-md/core/table/tableRowStyles"; | ||
import { table } from "@react-md/core/table/tableStyles"; | ||
import { type ReactElement } from "react"; | ||
|
||
interface Color { | ||
name: string; | ||
color: string; | ||
} | ||
|
||
const colors: Color[] = [ | ||
{ color: "#121212", name: "$dark-theme-background-color" }, | ||
{ color: "#424242", name: "$dark-theme-surface-color" }, | ||
{ color: "#D9D9D9", name: "$dark-theme-text-primary-color" }, | ||
{ color: "#B3B3B3", name: "$dark-theme-text-secondary-color" }, | ||
{ color: "#808080", name: "$dark-theme-text-hint-color" }, | ||
{ color: "#808080", name: "$dark-theme-text-disabled-color" }, | ||
{ | ||
color: "rgba(255, 255, 255, 0.1)", | ||
name: "$dark-surface-hover-background-color", | ||
}, | ||
{ | ||
color: "rgba(255, 255, 255, 0.12)", | ||
name: "$dark-surface-focus-background-color", | ||
}, | ||
{ | ||
color: "rgba(255, 255, 255, 0.24)", | ||
name: "$dark-surface-press-background-color", | ||
}, | ||
{ | ||
color: "rgba(255, 255, 255, 0.12)", | ||
name: "$dark-surface-selected-background-color", | ||
}, | ||
{ | ||
color: "rgba(255, 255, 255, 0.12)", | ||
name: "$dark-surface-ripple-background-color", | ||
}, | ||
{ color: "#B3B3B3", name: "$icon-dark-theme-color" }, | ||
]; | ||
|
||
export function DarkModeColors(): ReactElement { | ||
return ( | ||
<table className={table()}> | ||
<thead className={tableHeader()}> | ||
<tr className={tableRow({ disableHover: true })}> | ||
<th className={tableCell({ header: true, isInTableHeader: true })}> | ||
Name | ||
</th> | ||
<th className={tableCell({ header: true, isInTableHeader: true })}> | ||
Color | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{colors.map(({ name, color }) => ( | ||
<tr key={name} className={tableRow({})}> | ||
<td className={tableCell()}> | ||
<InlineCode>{name}</InlineCode> | ||
</td> | ||
<td className={tableCell()}> | ||
<ColorPreview color={color} /> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
); | ||
} |
This file contains 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