diff --git a/packages/configuration-builder/package.json b/packages/configuration-builder/package.json index 5f76fea29..137f46588 100644 --- a/packages/configuration-builder/package.json +++ b/packages/configuration-builder/package.json @@ -19,11 +19,14 @@ "@react-aria/i18n": "3.8.1", "@react-aria/numberfield": "3.7.0", "@react-stately/numberfield": "3.6.0", + "@vanilla-extract/css": "1.12.0", + "@vanilla-extract/recipes": "0.5.0", "i18next": "22.5.1", "react": "18.2.0", "react-dom": "18.2.0", "react-i18next": "12.3.1", - "ts-pattern": "5.0.5" + "react-router-dom": "^6.15.0", + "ts-pattern": "3.3.5" }, "devDependencies": { "@react-types/numberfield": "3.5.0", @@ -32,11 +35,15 @@ "@types/react-dom": "18.2.7", "@typescript-eslint/eslint-plugin": "6.5.0", "@typescript-eslint/parser": "6.5.0", + "@vanilla-extract/dynamic": "2.0.3", + "@vanilla-extract/sprinkles": "1.6.1", + "@vanilla-extract/vite-plugin": "3.8.2", "@vitejs/plugin-react": "4.0.4", "eslint": "8.48.0", "eslint-plugin-react-hooks": "4.6.0", "eslint-plugin-react-refresh": "0.4.3", "typescript": "5.1.3", - "vite": "4.4.9" + "vite": "4.4.9", + "vite-plugin-checker": "^0.6.2" } } diff --git a/packages/configuration-builder/src/App.tsx b/packages/configuration-builder/src/App.tsx index 38148d669..c4231055f 100644 --- a/packages/configuration-builder/src/App.tsx +++ b/packages/configuration-builder/src/App.tsx @@ -1,14 +1,18 @@ -import { Stack } from "@buildo/bento-design-system"; +import { Box, Divider } from "@buildo/bento-design-system"; import { Header } from "./Header/Header"; -import { ThemeConfigurator } from "./ThemeConfigurator/ThemeConfigurator"; +import { RouterProvider } from "react-router-dom"; +import { router } from "./router"; -function App() { +export function App() { return ( - +
- - + + + + + + + ); } - -export default App; diff --git a/packages/configuration-builder/src/ColorEditor/Palette.tsx b/packages/configuration-builder/src/ColorEditor/Palette.tsx index 0f26f6036..d0188654e 100644 --- a/packages/configuration-builder/src/ColorEditor/Palette.tsx +++ b/packages/configuration-builder/src/ColorEditor/Palette.tsx @@ -1,7 +1,7 @@ import { Box } from "@buildo/bento-design-system"; import { LightnessInterpolation } from "./ColorEditor"; import { useState } from "react"; -import { IconEyedropper } from "../Icons/IconEyedropper"; +import { IconEyedropper } from "../PhosphorIcons"; import { HSLToHex, HexColor } from "../utils/colorUtils"; type Props = { diff --git a/packages/configuration-builder/src/ColorsSection/BrandColors.tsx b/packages/configuration-builder/src/ColorsSection/BrandColors.tsx index 1fb6de325..3d0f4d847 100644 --- a/packages/configuration-builder/src/ColorsSection/BrandColors.tsx +++ b/packages/configuration-builder/src/ColorsSection/BrandColors.tsx @@ -2,8 +2,8 @@ import { Button, Headline, Inline, Stack, Actions } from "@buildo/bento-design-s import { useTranslation } from "react-i18next"; import { ColorConfig, ColorEditor } from "../ColorEditor/ColorEditor"; import { HexColor } from "../utils/colorUtils"; -import { ThemeConfig } from "../ThemeConfigurator/ThemeConfigurator"; import { defaultColorConfig } from "./defaultColor"; +import { ThemeConfig } from "../ConfiguratorStatusContext"; type BrandColors = ThemeConfig["colors"]["brand"]; diff --git a/packages/configuration-builder/src/ColorsSection/ColorsSection.tsx b/packages/configuration-builder/src/ColorsSection/ColorsSection.tsx index 954231941..24f3e2229 100644 --- a/packages/configuration-builder/src/ColorsSection/ColorsSection.tsx +++ b/packages/configuration-builder/src/ColorsSection/ColorsSection.tsx @@ -1,7 +1,6 @@ import { useTranslation } from "react-i18next"; import { ConfiguratorSection } from "../ConfiguratorSection/ConfiguratorSection"; import { BrandColors } from "./BrandColors"; -import { ThemeConfig } from "../ThemeConfigurator/ThemeConfigurator"; import { useState } from "react"; import { match } from "ts-pattern"; import { InteractiveColor } from "./InteractiveColor"; @@ -9,16 +8,9 @@ import { NeutralColor } from "./NeutralColor"; import { SemanticColors } from "./SemanticColors"; import { DataVizColors } from "./DataVizColors"; import { SectionCompleted } from "./SectionCompleted"; +import { ThemeConfig, useConfiguratorStatusContext } from "../ConfiguratorStatusContext"; -type ColorsConfig = ThemeConfig["colors"]; - -type Props = { - value: ColorsConfig; - onChange: (value: ColorsConfig) => void; - onComplete: () => void; -}; - -export function ColorsSection(props: Props) { +export function ColorsSection() { const steps = [ "brand" as const, "interactive" as const, @@ -27,6 +19,13 @@ export function ColorsSection(props: Props) { "dataVisualization" as const, ]; const { t } = useTranslation(); + const { theme, setTheme, completeSection } = useConfiguratorStatusContext(); + + const colors = theme.colors; + + const onChange = (newValue: ThemeConfig["colors"]) => { + setTheme({ ...theme, colors: newValue }); + }; const [completed, setCompleted] = useState(false); const [currentStep, setCurrentStep] = useState<(typeof steps)[0]>("brand"); @@ -42,11 +41,12 @@ export function ColorsSection(props: Props) { return match(completed) .with(true, () => ( - {}} goToTypography={() => {}} /> + )) .with(false, () => ( ({ label: t(`ColorsSection.Step.${step}`) }))} currentStep={currentStepIndex} @@ -54,47 +54,45 @@ export function ColorsSection(props: Props) { {match(currentStep) .with("brand", () => ( props.onChange({ ...props.value, brand: value })} + value={colors.brand} + onChange={(value) => onChange({ ...colors, brand: value })} onCancel={() => {}} onNext={onNext} /> )) .with("interactive", () => ( props.onChange({ ...props.value, interactive: value })} - brandColors={props.value.brand} + value={theme.colors.interactive} + onChange={(value) => onChange({ ...colors, interactive: value })} + brandColors={colors.brand} onBack={onBack} onNext={onNext} /> )) .with("neutral", () => ( props.onChange({ ...props.value, neutral })} + value={colors.neutral} + onChange={(neutral) => onChange({ ...colors, neutral })} onBack={onBack} onNext={onNext} /> )) .with("semantic", () => ( props.onChange({ ...props.value, semantic })} + value={colors.semantic} + onChange={(semantic) => onChange({ ...colors, semantic })} onBack={onBack} onNext={onNext} /> )) .with("dataVisualization", () => ( - props.onChange({ ...props.value, dataVisualization }) - } + value={colors.dataVisualization} + onChange={(dataVisualization) => onChange({ ...colors, dataVisualization })} onBack={onBack} onNext={() => { setCompleted(true); - props.onComplete(); + completeSection("colors"); }} /> )) diff --git a/packages/configuration-builder/src/ColorsSection/DataVizColors.tsx b/packages/configuration-builder/src/ColorsSection/DataVizColors.tsx index 002332fa3..3994c0d60 100644 --- a/packages/configuration-builder/src/ColorsSection/DataVizColors.tsx +++ b/packages/configuration-builder/src/ColorsSection/DataVizColors.tsx @@ -1,7 +1,7 @@ import { useTranslation } from "react-i18next"; -import { ThemeConfig } from "../ThemeConfigurator/ThemeConfigurator"; import { Actions, Headline, Stack } from "@buildo/bento-design-system"; import { ColorEditor } from "../ColorEditor/ColorEditor"; +import { ThemeConfig } from "../ConfiguratorStatusContext"; type DataVizColors = ThemeConfig["colors"]["dataVisualization"]; diff --git a/packages/configuration-builder/src/ColorsSection/InteractiveColor.tsx b/packages/configuration-builder/src/ColorsSection/InteractiveColor.tsx index fba935c2d..52566a39f 100644 --- a/packages/configuration-builder/src/ColorsSection/InteractiveColor.tsx +++ b/packages/configuration-builder/src/ColorsSection/InteractiveColor.tsx @@ -6,10 +6,10 @@ import { Stack, unsafeLocalizedString, } from "@buildo/bento-design-system"; -import { ThemeConfig } from "../ThemeConfigurator/ThemeConfigurator"; import { ColorEditor } from "../ColorEditor/ColorEditor"; import { useTranslation } from "react-i18next"; import { useState } from "react"; +import { ThemeConfig } from "../ConfiguratorStatusContext"; type InteractiveColor = ThemeConfig["colors"]["interactive"]; type BrandColors = ThemeConfig["colors"]["brand"]; diff --git a/packages/configuration-builder/src/ColorsSection/NeutralColor.tsx b/packages/configuration-builder/src/ColorsSection/NeutralColor.tsx index bb3f7f9f7..3913f959b 100644 --- a/packages/configuration-builder/src/ColorsSection/NeutralColor.tsx +++ b/packages/configuration-builder/src/ColorsSection/NeutralColor.tsx @@ -1,10 +1,10 @@ import { useTranslation } from "react-i18next"; -import { ThemeConfig } from "../ThemeConfigurator/ThemeConfigurator"; import { Actions, Headline, Stack } from "@buildo/bento-design-system"; import { ColorEditor } from "../ColorEditor/ColorEditor"; import { ColorPresets } from "./ColorPresets"; import { HexColor } from "../utils/colorUtils"; import { defaultColorConfig } from "./defaultColor"; +import { ThemeConfig } from "../ConfiguratorStatusContext"; type NeutralColor = ThemeConfig["colors"]["neutral"]; diff --git a/packages/configuration-builder/src/ColorsSection/SectionCompleted.tsx b/packages/configuration-builder/src/ColorsSection/SectionCompleted.tsx index 3d96a6681..c985d71e6 100644 --- a/packages/configuration-builder/src/ColorsSection/SectionCompleted.tsx +++ b/packages/configuration-builder/src/ColorsSection/SectionCompleted.tsx @@ -1,31 +1,26 @@ -import { Button, Feedback, Inline, Stack } from "@buildo/bento-design-system"; +import { ButtonLink, Feedback, Inline, Stack } from "@buildo/bento-design-system"; import { useTranslation } from "react-i18next"; -import { IconConfetti } from "../Icons/IconConfetti"; +import { IconConfetti } from "../PhosphorIcons"; -type Props = { - goToMyTheme: () => void; - goToTypography: () => void; -}; - -export function SectionCompleted(props: Props) { +export function SectionCompleted() { const { t } = useTranslation(); return ( -