diff --git a/sections/Theme/Theme.tsx b/sections/Theme/Theme.tsx index 17241025..766f4440 100644 --- a/sections/Theme/Theme.tsx +++ b/sections/Theme/Theme.tsx @@ -6,6 +6,7 @@ */ import SiteTheme, { Font } from "apps/website/components/Theme.tsx"; import Color from "npm:colorjs.io"; +import type { ComponentChildren } from "preact"; export interface ThemeColors { /** @@ -130,6 +131,10 @@ export interface Props { buttonStyle?: Button; otherStyles?: Miscellaneous; font?: Font; + /** + * @description This is the admin's color-scheme mode + */ + mode?: "dark" | "light"; } type Theme = @@ -272,184 +277,125 @@ function Section({ } export function Preview(props: Props) { + const adminColorMode = props.mode === "dark" ? "dark" : "light"; return ( <> + { + /* This stylesheet is used to simulate the colors from the admin's color schema (admin's light or dark mode), which are not accessible in the site's color schema. + * This is a temporary solution until the admin's color schema is accessible. + * TODO(@carol): Change this temporary solution. + */ + } +
-
-
-
The quick brown fox jumps over the lazy dog
- {" "} - {" "} -
-
- {" "} - {" "} - {" "} - - {" "} -
-
- {" "} - {" "} - - {" "} - - {" "} -
- {" "} -
-
- Base{" "} - Primary{" "} - Secondary{" "} - Accent - {" "} -
{" "} -
-
Content
-
Primary
-
Secondary
-
Accent
-
- {" "} -
{" "} -
-
The quick brown fox jumps over the lazy dog
- {" "} - {" "} -
-
- {" "} - {" "} - {" "} - - {" "} -
-
- {" "} - - {" "} - - {" "} -
- {" "} -
-
- Base{" "} - Primary{" "} - Secondary{" "} - Accent - {" "} -
{" "} -
-
Content
-
Primary
-
Secondary
-
Accent
-
- {" "} -
{" "} -
-
The quick brown fox jumps over the lazy dog
- {" "} - {" "} -
-
- {" "} - {" "} - - {" "} -
-
- {" "} - - {" "} - - {" "} -
- {" "} -
-
- Base{" "} - Secondary{" "} - Accent - {" "} -
{" "} -
-
Content
-
Secondary
-
Accent
-
- {" "} -
{" "} -
-
The quick brown fox jumps over the lazy dog
- {" "} - {" "} -
-
- {" "} - {" "} - - {" "} -
-
- {" "} - {" "} - - {" "} -
- {" "} -
-
- Base{" "} - Primary{" "} - Accent - {" "} -
{" "} -
-
Content
-
Primary
-
Accent
-
- {" "} -
{" "} -
-
The quick brown fox jumps over the lazy dog
- {" "} - {" "} -
-
- {" "} - {" "} - - {" "} -
-
- {" "} - {" "} - - {" "} -
- {" "} -
-
- Base{" "} - Primary{" "} - Secondary - {" "} -
{" "} -
-
Content
-
Primary
-
Secondary
-
- {" "} +
+
Components and styles
+
+ + + + + + + + + + + +
- {" "}
{props.font?.family && ( -
+
Font: {props.font.family}
)} @@ -457,4 +403,221 @@ export function Preview(props: Props) { ); } +const ButtonSizesPreview = () => { + const buttonSizes = { + lg: "Large", + md: "Normal", + sm: "Small", + xs: "Tiny", + }; + + const buttonStyles = ["", "primary", "secondary", "accent"]; + + const renderButtonRow = (style: string) => ( +
+ {Object.entries(buttonSizes).map(([sizeCode, sizeText]) => ( + + ))} +
+ ); + + return ( +
+ {buttonStyles.map((style) => renderButtonRow(style))} +
+ ); +}; + +const ButtonColorsPreview = () => { + const buttonTypesClasses = ["btn", "btn-outline", "btn-ghost", "btn-link"]; + const buttonColorsClasses = [ + "", + "btn-primary", + "btn-secondary", + "btn-accent", + ]; + + const renderButtonRow = (type: string) => ( +
+ {buttonColorsClasses.map((color) => ( + + ))} +
+ ); + + return ( +
+ {buttonTypesClasses.map((type) => renderButtonRow(type))} +
+ ); +}; + +const ButtonStylesPreview = () => { + const buttonStylesClasses = ["", "btn-outline", "btn-ghost", "btn-link"]; + + return ( +
+ {buttonStylesClasses.map((style) => ( + + ))} +
+ ); +}; + +const TextColorsPreview = () => { + const textColorsClasses = [ + "", + "text-primary", + "text-secondary", + "text-accent", + ]; + + return ( +
+ {textColorsClasses.map((color) => ( +
+ {color ? color.split("-")[1] : "Content"} +
+ ))} +
+ ); +}; + +const PreviewContainer = ( + { mode, title, children, codeString }: { + mode: string; + title: string; + children: ComponentChildren; + codeString: string; + }, +) => { + const borderClass = mode === "dark" + ? "border-color-dark" + : "border-color-light"; + const btnOutlineClass = mode === "dark" + ? "btn-outline-dark" + : "btn-outline-light"; + const checkboxId = `show-code-${title.replace(/\s+/g, "-").toLowerCase()}`; + const codeBlockId = `code-block-${title.replace(/\s+/g, "-").toLowerCase()}`; + + // Estilos dinĂ¢micos adicionados para esconder/mostrar labels baseado no estado do checkbox + const dynamicStyle = ` + #${codeBlockId} { + display: none; + } + #${checkboxId}:checked ~ #${codeBlockId} { + display: block; + } + #${checkboxId}:checked ~ .show-label { + display: none; + } + #${checkboxId}:not(:checked) ~ .hide-label { + display: none; + } + #${checkboxId}:checked ~ .hide-label { + background-color: ${mode === "dark" ? "var(--admin-hover-bg-color)" : "var(--admin-text-color-light)"}; + color: ${mode === "dark" ? "var(--admin-text-color-light)" : "var(--admin-hover-bg-color)"}; + } + `; + + return ( + <> + +
+
+
{title}
+
+ + {/* Label for "Show code" */} + + {/* Label for "Hide code" */} + +
+
{codeString}
+
+
+
+ {children} +
+ + ); +}; + + +// TODO(@carol): find a way to make these snippets more dynamic +const snippets = { + textColors: ` +
Content
+
Primary
+
Secondary
+
Accent
`, + buttonStyles: ` + + + + `, + buttonColors: ` + {/* First row */} + + + + + + {/* Second row */} + + + + + + {/* Third row */} + + + + + + {/* Fourth row */} + + + + `, + buttonSizes: ` + {/* First row */} + + + + + + {/* Second row */} + + + + + + {/* Third row */} + + + + + + {/* Fourth row */} + + + + `, +}; + export default Section;