diff --git a/sections/Theme/Theme.tsx b/sections/Theme/Theme.tsx index bc04a589..c7738619 100644 --- a/sections/Theme/Theme.tsx +++ b/sections/Theme/Theme.tsx @@ -131,7 +131,7 @@ export interface Props { buttonStyle?: Button; otherStyles?: Miscellaneous; font?: Font; - /** + /** * @description This is the admin's color-scheme mode */ mode?: "dark" | "light"; @@ -333,7 +333,7 @@ export function Preview(props: Props) { } .btn-outline-light:hover, .btn-outline-dark:hover { - background-color: var(--admin-hover-bg-color); + background-color: transparent); display: inline-flex; flex-wrap: nowrap; align-items: center; @@ -364,16 +364,32 @@ export function Preview(props: Props) {
Components and styles
- + - + - + - +
@@ -389,18 +405,22 @@ export function Preview(props: Props) { const ButtonSizesPreview = () => { const buttonSizes = { - lg: 'Large', - md: 'Normal', - sm: 'Small', - xs: 'Tiny' + lg: "Large", + md: "Normal", + sm: "Small", + xs: "Tiny", }; - const buttonStyles = ['', 'primary', 'secondary', 'tertiary', 'accent']; + const buttonStyles = ["", "primary", "secondary", "accent"]; const renderButtonRow = (style: string) => (
{Object.entries(buttonSizes).map(([sizeCode, sizeText]) => ( - ))} @@ -409,20 +429,25 @@ const ButtonSizesPreview = () => { return (
- {buttonStyles.map(style => renderButtonRow(style))} + {buttonStyles.map((style) => renderButtonRow(style))}
); }; const ButtonColorsPreview = () => { - const buttonTypesClasses = ['btn', 'btn-outline', 'btn-ghost', 'btn-link']; - const buttonColorsClasses = ['', 'btn-primary', 'btn-secondary', 'btn-tertiary', 'btn-accent']; + const buttonTypesClasses = ["btn", "btn-outline", "btn-ghost", "btn-link"]; + const buttonColorsClasses = [ + "", + "btn-primary", + "btn-secondary", + "btn-accent", + ]; const renderButtonRow = (type: string) => (
- {buttonColorsClasses.map(color => ( + {buttonColorsClasses.map((color) => ( ))}
@@ -430,57 +455,169 @@ const ButtonColorsPreview = () => { return (
- {buttonTypesClasses.map(type => renderButtonRow(type))} + {buttonTypesClasses.map((type) => renderButtonRow(type))}
); }; - const ButtonStylesPreview = () => { - const buttonStylesClasses = ['', 'btn-outline', 'btn-ghost', 'btn-link']; + const buttonStylesClasses = ["", "btn-outline", "btn-ghost", "btn-link"]; return (
- {buttonStylesClasses.map(style => ( + {buttonStylesClasses.map((style) => ( ))}
); }; - const TextColorsPreview = () => { - const textColorsClasses = ['', 'text-primary', 'text-secondary', 'text-tertiary', 'text-accent']; + const textColorsClasses = [ + "", + "text-primary", + "text-secondary", + "text-accent", + ]; return (
- {textColorsClasses.map(color => ( + {textColorsClasses.map((color) => (
- {color ? color.split('-')[1] : 'Content'} + {color ? color.split("-")[1] : "Content"}
))}
); }; -const PreviewContainer = ({ mode, title, children }: { mode: string, title: string, children: ComponentChildren }) => { - const borderClass = mode === "dark" ? "border-color-dark" : "border-color-light"; - const btnOutlineClass = mode === "dark" ? "btn-outline-dark" : "btn-outline-light" +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}
- + <> + +
+
+
{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;