-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(site): add custom color example to palette page
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"@suid/site": minor | ||
--- | ||
|
||
Add custom color example to palette page |
57 changes: 57 additions & 0 deletions
57
packages/site/src/pages/customization/theme/PalettePage/CustomColorExample.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,57 @@ | ||
import { Typography, Box, Stack, Button } from "@suid/material"; | ||
import { createTheme, ThemeProvider } from "@suid/material/styles"; | ||
|
||
// Augment the palette to include an ochre color | ||
declare module "@suid/material/styles" { | ||
interface Palette { | ||
ochre: Palette["primary"]; | ||
} | ||
|
||
interface PaletteOptions { | ||
ochre?: PaletteOptions["primary"]; | ||
} | ||
} | ||
|
||
// Update the Button's color options to include an ochre option | ||
declare module "@suid/material/Button" { | ||
interface ButtonPropsColorOverrides { | ||
ochre: true; | ||
} | ||
} | ||
|
||
const theme = createTheme({ | ||
palette: { | ||
ochre: { | ||
main: "#E3D026", | ||
light: "#E9DB5D", | ||
dark: "#A29415", | ||
contrastText: "#242105", | ||
}, | ||
}, | ||
}); | ||
|
||
export default function CustomColor() { | ||
return ( | ||
<ThemeProvider theme={theme}> | ||
<Stack gap={2} alignItems="center"> | ||
<Button variant="contained" color="ochre"> | ||
Ochre | ||
</Button> | ||
<Stack direction="row" gap={1}> | ||
<Stack alignItems="center"> | ||
<Typography variant="body2">light</Typography> | ||
<Box sx={{ bgcolor: "ochre.light", width: 40, height: 20 }} /> | ||
</Stack> | ||
<Stack alignItems="center"> | ||
<Typography variant="body2">main</Typography> | ||
<Box sx={{ bgcolor: "ochre.main", width: 40, height: 20 }} /> | ||
</Stack> | ||
<Stack alignItems="center"> | ||
<Typography variant="body2">dark</Typography> | ||
<Box sx={{ bgcolor: "ochre.dark", width: 40, height: 20 }} /> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
</ThemeProvider> | ||
); | ||
} |
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