-
Notifications
You must be signed in to change notification settings - Fork 17
[doc] Theme generator review step added #2420
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
8 commits
Select commit
Hold shift + click to select a range
cccaab8
Theme generator review step
Jialecl 0ac5d19
Changed how empty logos behavior
Jialecl 1a0fa0a
Package_lock removed
Jialecl ae15ba7
Changes based on feedback
Jialecl 2c1685d
useCopyToClipboard hook created
Jialecl 2c2911f
Added empty assets message and changed User guide and bottom links sp…
Jialecl 496305b
fixed missing footer
Jialecl ffd8f5e
No assets message changed
Jialecl 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,20 @@ | ||
| import { useToast } from "@dxc-technology/halstack-react"; | ||
|
|
||
| const useCopyToClipboard = () => { | ||
| const toast = useToast(); | ||
|
|
||
| const handleCopy = (text: string) => { | ||
| navigator.clipboard | ||
| .writeText(text) | ||
| .then(() => { | ||
| toast.success({ message: "Code copied to the clipboard." }); | ||
| }) | ||
| .catch(() => { | ||
| toast.warning({ message: "Failed to copy the text to the clipboard." }); | ||
| }); | ||
| }; | ||
|
|
||
| return handleCopy; | ||
| }; | ||
|
|
||
| export default useCopyToClipboard; |
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
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
53 changes: 53 additions & 0 deletions
53
apps/website/screens/theme-generator/components/review/ReviewBrandingAssets.tsx
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,53 @@ | ||
| import { DxcContainer, DxcFlex, DxcGrid, DxcImage, DxcParagraph, DxcTypography } from "@dxc-technology/halstack-react"; | ||
| import { useMemo } from "react"; | ||
| import { Logos } from "../../types"; | ||
|
|
||
| const BrandingAsset = ({ label, logo }: { label: string; logo?: string }) => { | ||
| return ( | ||
| <DxcContainer width="250px" height="100%"> | ||
| <DxcFlex direction="column" gap="var(--spacing-gap-xs)" fullHeight> | ||
| <DxcTypography fontWeight="var(--typography-label-semibold)">{label}</DxcTypography> | ||
| <DxcContainer | ||
raquelarrojo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| width="100%" | ||
| maxHeight="calc(100% - 28px)" | ||
| height="130px" | ||
| background={{ color: "var(--color-bg-neutral-light)" }} | ||
| borderRadius="var(--border-radius-m)" | ||
| padding="var(--spacing-padding-m)" | ||
| boxSizing="border-box" | ||
| > | ||
| <DxcFlex alignItems="center" justifyContent="center" fullHeight> | ||
| {logo ? ( | ||
| <DxcImage width="100%" height="100%" objectFit="contain" src={logo} alt={label} /> | ||
| ) : ( | ||
| <DxcParagraph>No asset selected.</DxcParagraph> | ||
| )} | ||
| </DxcFlex> | ||
| </DxcContainer> | ||
| </DxcFlex> | ||
| </DxcContainer> | ||
| ); | ||
| }; | ||
|
|
||
| const ReviewBrandingAssets = ({ logos }: { logos: Logos }) => { | ||
| const brandingAssets = useMemo(() => { | ||
| return [ | ||
| { label: "Main logo", logo: logos.mainLogo?.[0]?.preview }, | ||
| { label: "Footer logo", logo: logos.footerLogo?.[0]?.preview }, | ||
| { label: "Reduced footer logo", logo: logos.footerReducedLogo?.[0]?.preview }, | ||
| { label: "Favicon", logo: logos.favicon?.[0]?.preview }, | ||
| ]; | ||
| }, [logos]); | ||
|
|
||
| return ( | ||
| <DxcGrid templateColumns={["repeat(4, 1fr)"]} templateRows={["1fr"]} gap="var(--spacing-gap-ml)"> | ||
| {brandingAssets.some((asset) => asset.logo) ? ( | ||
| brandingAssets.map((asset) => <BrandingAsset key={asset.label} label={asset.label} logo={asset.logo} />) | ||
| ) : ( | ||
| <DxcParagraph>No branding assets selected.</DxcParagraph> | ||
| )} | ||
| </DxcGrid> | ||
| ); | ||
| }; | ||
|
|
||
| export default ReviewBrandingAssets; | ||
22 changes: 22 additions & 0 deletions
22
apps/website/screens/theme-generator/components/review/ReviewSectionContainer.tsx
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,22 @@ | ||
| import { DxcContainer, DxcFlex } from "@dxc-technology/halstack-react"; | ||
|
|
||
| const ReviewSectionContainer = ({ title, children }: { title: React.ReactNode; children: React.ReactNode }) => { | ||
| return ( | ||
| <DxcContainer | ||
| boxSizing="border-box" | ||
| width="100%" | ||
| maxWidth="1112px" | ||
| padding="var(--spacing-padding-ml)" | ||
| borderRadius="var(--border-radius-m)" | ||
| background={{ color: "var(--color-bg-neutral-lightest)" }} | ||
| boxShadow="var(--shadow-100)" | ||
| > | ||
| <DxcFlex direction="column" gap="var(--spacing-gap-ml)"> | ||
| {title} | ||
| {children} | ||
| </DxcFlex> | ||
| </DxcContainer> | ||
| ); | ||
| }; | ||
|
|
||
| export default ReviewSectionContainer; |
60 changes: 60 additions & 0 deletions
60
apps/website/screens/theme-generator/components/review/ReviewTokensGrid.tsx
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,60 @@ | ||
| import { DxcFlex, DxcGrid, DxcTypography } from "@dxc-technology/halstack-react"; | ||
| import { Tokens } from "../../types"; | ||
| import React, { useMemo } from "react"; | ||
| import { divideColorTokens, SHADE_VALUES } from "../../utils"; | ||
|
|
||
| const ReviewTokensGrid = ({ generatedTokens }: { generatedTokens: Tokens }) => { | ||
| const tokenGroups = useMemo(() => divideColorTokens(generatedTokens), [generatedTokens]); | ||
| return ( | ||
| <DxcGrid | ||
| templateColumns={["100px", "repeat(10, 1fr)"]} | ||
| templateRows={["auto", "repeat(9, 1fr)"]} | ||
| gap="var(--spacing-gap-xs)" | ||
| > | ||
| {SHADE_VALUES.map((value, index) => | ||
| index === 0 ? ( | ||
| <DxcGrid.Item column={"2/3"} key={"shade_" + value}> | ||
| <DxcTypography | ||
| fontSize="var(--typography-body-s)" | ||
| color="var(--color-fg-neutral-strong)" | ||
| textAlign="center" | ||
| > | ||
| {value} | ||
| </DxcTypography> | ||
| </DxcGrid.Item> | ||
| ) : ( | ||
| <DxcTypography | ||
| key={"shade_" + value} | ||
| fontSize="var(--typography-body-s)" | ||
| color="var(--color-fg-neutral-strong)" | ||
| textAlign="center" | ||
| > | ||
| {value} | ||
| </DxcTypography> | ||
| ) | ||
| )} | ||
| {Object.entries(tokenGroups).map(([group, colors]) => ( | ||
| <React.Fragment key={group}> | ||
| <DxcFlex alignItems="center"> | ||
| <DxcTypography fontWeight="var(--typography-label-semibold)"> | ||
| {group.charAt(0).toUpperCase() + group.slice(1)} | ||
| </DxcTypography> | ||
| </DxcFlex> | ||
| {colors.map((color: string, index: number) => ( | ||
| <div | ||
| key={group + "_" + SHADE_VALUES[index]} | ||
| style={{ | ||
| backgroundColor: color, | ||
| width: "100%", | ||
| aspectRatio: "1 / 1", | ||
| borderRadius: "var(--border-radius-m)", | ||
| }} | ||
| /> | ||
| ))} | ||
| </React.Fragment> | ||
| ))} | ||
| </DxcGrid> | ||
| ); | ||
| }; | ||
|
|
||
| export default ReviewTokensGrid; | ||
PelayoFelgueroso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
13 changes: 13 additions & 0 deletions
13
apps/website/screens/theme-generator/components/review/ReviewTokensList.tsx
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,13 @@ | ||
| import { DxcContainer, DxcTypography } from "@dxc-technology/halstack-react"; | ||
|
|
||
| const ReviewTokensList = ({ themeJson }: { themeJson: string }) => { | ||
| return ( | ||
| <DxcContainer height="100%" overflow="auto" borderRadius="var(--border-radius-m)"> | ||
PelayoFelgueroso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <DxcTypography as="pre" fontSize="var(--typography-body-xs)" whiteSpace="pre"> | ||
| {themeJson} | ||
raquelarrojo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </DxcTypography> | ||
| </DxcContainer> | ||
| ); | ||
| }; | ||
|
|
||
| export default ReviewTokensList; | ||
63 changes: 63 additions & 0 deletions
63
apps/website/screens/theme-generator/steps/ReviewDetails.tsx
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,63 @@ | ||
| import { DxcButton, DxcFlex, DxcGrid, DxcTypography } from "@dxc-technology/halstack-react"; | ||
| import { Logos, Tokens } from "../types"; | ||
jsuarezgonz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import ReviewTokensGrid from "../components/review/ReviewTokensGrid"; | ||
| import ReviewTokensList from "../components/review/ReviewTokensList"; | ||
| import ReviewBrandingAssets from "../components/review/ReviewBrandingAssets"; | ||
| import useCopyToClipboard from "hooks/useCopyToClipboard"; | ||
| import { useMemo } from "react"; | ||
| import ReviewSectionContainer from "../components/review/ReviewSectionContainer"; | ||
|
|
||
| const ReviewDetails = ({ generatedTokens, logos }: { generatedTokens: Tokens; logos: Logos }) => { | ||
| const themeJson = useMemo(() => { | ||
| const themeObject = { | ||
| tokens: generatedTokens, | ||
| logos: { | ||
| mainLogo: "", | ||
| footerLogo: "", | ||
| footerReducedLogo: "", | ||
| favicon: "", | ||
| }, | ||
| }; | ||
| return JSON.stringify(themeObject, null, 2); | ||
| }, [generatedTokens]); | ||
|
|
||
| const handleCopy = useCopyToClipboard(); | ||
|
|
||
| return ( | ||
| <> | ||
raquelarrojo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <ReviewSectionContainer | ||
| title={ | ||
| <DxcFlex justifyContent="space-between" alignItems="center"> | ||
| <DxcTypography fontSize="var(--typography-title-l)" fontWeight="var(--typography-title-bold)"> | ||
| Color palette & theme | ||
| </DxcTypography> | ||
| <DxcButton | ||
| mode="secondary" | ||
| icon="content_copy" | ||
| size={{ height: "medium" }} | ||
| onClick={() => handleCopy(themeJson)} | ||
| /> | ||
| </DxcFlex> | ||
| } | ||
| > | ||
| <DxcGrid templateColumns={["2fr", "1fr"]} templateRows={["368px"]} gap="var(--spacing-gap-m)"> | ||
| <DxcFlex justifyContent="center"> | ||
| <ReviewTokensGrid generatedTokens={generatedTokens} /> | ||
| </DxcFlex> | ||
| <ReviewTokensList themeJson={themeJson} /> | ||
| </DxcGrid> | ||
| </ReviewSectionContainer> | ||
| <ReviewSectionContainer | ||
| title={ | ||
| <DxcTypography fontSize="var(--typography-title-l)" fontWeight="var(--typography-title-bold)"> | ||
| Branding assets | ||
| </DxcTypography> | ||
| } | ||
| > | ||
| <ReviewBrandingAssets logos={logos} /> | ||
| </ReviewSectionContainer> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default ReviewDetails; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.