From f2966ad4cd210403b0b2b8bfc0a41385742d699a Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Wed, 2 Oct 2024 16:45:38 +0100 Subject: [PATCH 01/13] Theme simplications before extraction --- src/components/AboutDialog.tsx | 2 +- src/components/ActionBar.tsx | 2 +- src/components/BluetoothPatternInput.tsx | 4 +- src/components/BrokenFirmwareDialog.tsx | 6 +- src/components/CertaintyThresholdGridItem.tsx | 2 +- src/components/ConnectBatteryDialog.tsx | 4 +- src/components/DownloadProgressDialog.tsx | 2 +- src/components/ErrorHandlerErrorView.tsx | 2 +- src/components/LedIcon.tsx | 2 +- src/components/LiveGraphPanel.tsx | 2 +- src/components/LoadingAnimation/index.tsx | 2 +- src/components/ManualFlashingDialog.tsx | 2 +- src/components/MoreMenuButton.tsx | 1 - src/components/NotFound.tsx | 2 +- src/components/SaveProgressDialog.tsx | 2 +- src/components/StartOverWarningDialog.tsx | 2 +- .../TrainingModelProgressDialog.tsx | 2 +- src/components/UnsupportedMicrobitDialog.tsx | 4 +- src/deployment/default/colors.ts | 144 +----------------- src/deployment/default/components/alert.ts | 1 + src/deployment/default/components/avatar.ts | 19 --- src/deployment/default/components/button.ts | 52 +------ src/deployment/default/components/heading.ts | 15 -- src/deployment/default/components/text.ts | 15 -- src/deployment/default/components/tooltip.ts | 9 -- src/deployment/default/default-graph.ts | 14 -- src/deployment/default/fonts.ts | 10 +- src/deployment/default/graph.ts | 17 --- src/deployment/default/theme.ts | 8 - src/recording-graph.ts | 2 +- vite.config.ts | 2 +- 31 files changed, 48 insertions(+), 305 deletions(-) delete mode 100644 src/deployment/default/components/avatar.ts delete mode 100644 src/deployment/default/components/heading.ts delete mode 100644 src/deployment/default/components/text.ts delete mode 100644 src/deployment/default/components/tooltip.ts delete mode 100644 src/deployment/default/default-graph.ts delete mode 100644 src/deployment/default/graph.ts diff --git a/src/components/AboutDialog.tsx b/src/components/AboutDialog.tsx index 162284c7d..913e5e110 100644 --- a/src/components/AboutDialog.tsx +++ b/src/components/AboutDialog.tsx @@ -87,7 +87,7 @@ const AboutDialog = ({ href="https://microbit.org" target="_blank" rel="noopener" - color="purple.500" + color="blue.600" > {chunks} diff --git a/src/components/ActionBar.tsx b/src/components/ActionBar.tsx index 71ce7c590..d8ed539ff 100644 --- a/src/components/ActionBar.tsx +++ b/src/components/ActionBar.tsx @@ -18,7 +18,7 @@ const ActionBar = ({ px={5} alignItems="center" justifyContent="space-between" - bgColor="green.500" + bgColor="brand2.500" h="64px" minH="64px" {...rest} diff --git a/src/components/BluetoothPatternInput.tsx b/src/components/BluetoothPatternInput.tsx index a0bf00a45..86388515b 100644 --- a/src/components/BluetoothPatternInput.tsx +++ b/src/components/BluetoothPatternInput.tsx @@ -128,9 +128,9 @@ const PatternBox = ({ onClick={onClick} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} - bgColor={isOn ? "green.500" : "gray.300"} + bgColor={isOn ? "brand2.500" : "gray.300"} borderWidth={isHighlighted && !isOn ? 3 : 0} - borderColor={isHighlighted ? (isOn ? "white" : "green.500") : undefined} + borderColor={isHighlighted ? (isOn ? "white" : "brand2.500") : undefined} opacity={isHighlighted && isOn ? 0.25 : 1} /> ); diff --git a/src/components/BrokenFirmwareDialog.tsx b/src/components/BrokenFirmwareDialog.tsx index 437353bd8..830387f30 100644 --- a/src/components/BrokenFirmwareDialog.tsx +++ b/src/components/BrokenFirmwareDialog.tsx @@ -55,7 +55,7 @@ const BrokenFirmwareDialog = ({ values={{ link: (chunks: ReactNode) => ( diff --git a/src/components/CertaintyThresholdGridItem.tsx b/src/components/CertaintyThresholdGridItem.tsx index a7288af69..90dd5557c 100644 --- a/src/components/CertaintyThresholdGridItem.tsx +++ b/src/components/CertaintyThresholdGridItem.tsx @@ -35,7 +35,7 @@ const CertaintyThresholdGridItem = ({ const intl = useIntl(); const barWidth = 240; const colorScheme = useMemo( - () => (isTriggered ? "green.500" : undefined), + () => (isTriggered ? "brand2.500" : undefined), [isTriggered] ); diff --git a/src/components/ConnectBatteryDialog.tsx b/src/components/ConnectBatteryDialog.tsx index c4c6e2a63..7f2f01e55 100644 --- a/src/components/ConnectBatteryDialog.tsx +++ b/src/components/ConnectBatteryDialog.tsx @@ -19,7 +19,7 @@ const ConnectBatteryDialog = ({ ...props }: ConnectBatteryDialogProps) => { { diff --git a/src/components/DownloadProgressDialog.tsx b/src/components/DownloadProgressDialog.tsx index 9f7dc36ee..64bc041e7 100644 --- a/src/components/DownloadProgressDialog.tsx +++ b/src/components/DownloadProgressDialog.tsx @@ -54,7 +54,7 @@ const DownloadProgressDialog = ({ diff --git a/src/components/ErrorHandlerErrorView.tsx b/src/components/ErrorHandlerErrorView.tsx index d1d3c7ab7..29648e6af 100644 --- a/src/components/ErrorHandlerErrorView.tsx +++ b/src/components/ErrorHandlerErrorView.tsx @@ -14,7 +14,7 @@ const ErrorHandlerErrorView = () => { values={{ link: (chunks: ReactNode) => ( { return "gray.200"; } if (typeof isTriggered === "boolean" && isTriggered) { - return "green.500"; + return "brand2.500"; } if (typeof isTriggered === "boolean" && !isTriggered) { return "gray.600"; diff --git a/src/components/LiveGraphPanel.tsx b/src/components/LiveGraphPanel.tsx index ca4841f95..e283f36ab 100644 --- a/src/components/LiveGraphPanel.tsx +++ b/src/components/LiveGraphPanel.tsx @@ -127,7 +127,7 @@ const LiveGraphPanel = ({ { return ( - + ); }; diff --git a/src/components/ManualFlashingDialog.tsx b/src/components/ManualFlashingDialog.tsx index 93df9816b..803e94154 100644 --- a/src/components/ManualFlashingDialog.tsx +++ b/src/components/ManualFlashingDialog.tsx @@ -70,7 +70,7 @@ const ManualFlashingDialog = ({ id="connectMB.transferHex.manualDownload" values={{ link: (chunks: ReactNode) => ( - + {chunks} ), diff --git a/src/components/MoreMenuButton.tsx b/src/components/MoreMenuButton.tsx index e21a07a80..448335fda 100644 --- a/src/components/MoreMenuButton.tsx +++ b/src/components/MoreMenuButton.tsx @@ -26,7 +26,6 @@ const MoreMenuButton = React.forwardRef(function MoreMenuButtonInner( ref={ref} variant={variant} borderLeft="1px" - borderRadius="button" as={IconButton} icon={ { const intl = useIntl(); return ( - + diff --git a/src/components/SaveProgressDialog.tsx b/src/components/SaveProgressDialog.tsx index d372c8f76..acc08cdac 100644 --- a/src/components/SaveProgressDialog.tsx +++ b/src/components/SaveProgressDialog.tsx @@ -34,7 +34,7 @@ const SaveProgressDialog = ({ isOpen }: SavingDialogProps) => { - + diff --git a/src/components/StartOverWarningDialog.tsx b/src/components/StartOverWarningDialog.tsx index b01fed7d4..39cbd8e94 100644 --- a/src/components/StartOverWarningDialog.tsx +++ b/src/components/StartOverWarningDialog.tsx @@ -56,7 +56,7 @@ const StartOverWarningDialog = ({ values={{ link: (chunks: ReactNode) => ( diff --git a/src/components/UnsupportedMicrobitDialog.tsx b/src/components/UnsupportedMicrobitDialog.tsx index af125a475..27ee15e14 100644 --- a/src/components/UnsupportedMicrobitDialog.tsx +++ b/src/components/UnsupportedMicrobitDialog.tsx @@ -50,7 +50,7 @@ const UnsupportedMicrobitDialog = ({ values={{ link: (chunks: ReactNode) => ( ( { diff --git a/src/deployment/default/components/avatar.ts b/src/deployment/default/components/avatar.ts deleted file mode 100644 index 5dfbecab7..000000000 --- a/src/deployment/default/components/avatar.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { avatarAnatomy } from "@chakra-ui/anatomy"; -import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react"; - -const { definePartsStyle, defineMultiStyleConfig } = - createMultiStyleConfigHelpers(avatarAnatomy.keys); - -const md2 = defineStyle({ - width: 10, - height: 10, - fontSize: "md", -}); - -const sizes = { - "2md": definePartsStyle({ container: md2 }), -}; - -const avatarTheme = defineMultiStyleConfig({ sizes }); - -export default avatarTheme; diff --git a/src/deployment/default/components/button.ts b/src/deployment/default/components/button.ts index e11571eb8..f39366c9b 100644 --- a/src/deployment/default/components/button.ts +++ b/src/deployment/default/components/button.ts @@ -1,4 +1,3 @@ -import { theme, StyleFunctionProps } from "@chakra-ui/react"; import { StyleConfig } from "@chakra-ui/theme-tools"; const Button: StyleConfig = { @@ -9,25 +8,9 @@ const Button: StyleConfig = { unstyled: { borderRadius: "unset", }, - zoom: (props: StyleFunctionProps) => { - const base = { - ...theme.components.Button.variants!.solid(props), - }; - return { - ...base, - _hover: { - ...base._hover, - backgroundColor: "gray.400", - }, - _active: { - ...base._active, - backgroundColor: "gray.500", - }, - }; - }, link: () => ({ borderWidth: "0", - color: "purple.500", + color: "blue.600", fontWeight: "normal", bg: "transparent", }), @@ -47,14 +30,14 @@ const Button: StyleConfig = { led: () => ({ borderWidth: "2px", borderRadius: 5, - borderColor: "green.500", - color: "green.700", + borderColor: "brand2.500", + color: "brand2.700", bg: "transparent", _hover: { cursor: "pointer", - borderColor: "green.500", + borderColor: "brand2.500", }, - _active: { bg: "green.500", borderColor: "green.500" }, + _active: { bg: "brand2.500", borderColor: "brand2.500" }, }), ghost: () => ({ color: "black", @@ -108,33 +91,12 @@ const Button: StyleConfig = { boxShadow: "outlineDark", }, }), - sidebar: (props: StyleFunctionProps) => { - const base = { - ...theme.components.Button.variants!.ghost(props), - }; - return { - ...base, - _hover: { - ...base._hover, - bg: "white", - color: "gray.700", - _disabled: { - bg: base.bg, - }, - }, - _active: { - ...base._hover, - bg: "white", - color: "gray.800", - }, - }; - }, language: () => ({ borderWidth: "2px", borderColor: "gray.200", - color: "green.500", + color: "brand2.500", _hover: { - color: "green.600", + color: "brand2.600", bg: "gray.100", }, }), diff --git a/src/deployment/default/components/heading.ts b/src/deployment/default/components/heading.ts deleted file mode 100644 index ff79c21fe..000000000 --- a/src/deployment/default/components/heading.ts +++ /dev/null @@ -1,15 +0,0 @@ -const Heading = { - variants: { - label: { - fontSize: "4xl", - color: "#cd0365", - }, - subtitle: { - fontSize: "xl", - fontWeight: "normal", - color: "#cd0365", - }, - }, -}; - -export default Heading; diff --git a/src/deployment/default/components/text.ts b/src/deployment/default/components/text.ts deleted file mode 100644 index 3fc813535..000000000 --- a/src/deployment/default/components/text.ts +++ /dev/null @@ -1,15 +0,0 @@ -const Text = { - sizes: { - sm: { - fontSize: "sm", - }, - md: { - fontSize: "md", - }, - }, - defaultProps: { - size: "md", - }, -}; - -export default Text; diff --git a/src/deployment/default/components/tooltip.ts b/src/deployment/default/components/tooltip.ts deleted file mode 100644 index 73741e475..000000000 --- a/src/deployment/default/components/tooltip.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { StyleConfig } from "@chakra-ui/theme-tools"; - -const Tooltip: StyleConfig = { - baseStyle: { - fontSize: "md", - }, -}; - -export default Tooltip; diff --git a/src/deployment/default/default-graph.ts b/src/deployment/default/default-graph.ts deleted file mode 100644 index d5cf28804..000000000 --- a/src/deployment/default/default-graph.ts +++ /dev/null @@ -1,14 +0,0 @@ -export const defaultGraphColors = [ - // Green - "rgb(0, 200, 0)", - // Blue - "rgb(62, 182, 253)", - // Pink - "rgb(205, 3, 101)", - // Salmon - "rgb(231, 100, 92)", - // Purple - "rgb(108, 75, 193)", - // Teal - "rgb(123, 205, 194)", -]; diff --git a/src/deployment/default/fonts.ts b/src/deployment/default/fonts.ts index 35ead9c4a..4d9bf9a30 100644 --- a/src/deployment/default/fonts.ts +++ b/src/deployment/default/fonts.ts @@ -1,6 +1,12 @@ +/** + * (c) 2021, Micro:bit Educational Foundation and contributors + * + * SPDX-License-Identifier: MIT + */ const fonts = { - heading: "Helvetica Now, sans-serif", - body: "Helvetica Now, sans-serif", + heading: "Helvetica, Arial, sans-serif", + body: "Helvetica, Arial, sans-serif", + code: "Source Code Pro, monospace", }; export default fonts; diff --git a/src/deployment/default/graph.ts b/src/deployment/default/graph.ts deleted file mode 100644 index aeccd9db2..000000000 --- a/src/deployment/default/graph.ts +++ /dev/null @@ -1,17 +0,0 @@ -// micro:bit brand colors -export const defaultGraphColors = [ - // green.500 - "#00a000", - // teal.500 - "#7bcdc2", - // pink.500 - "#cd0365", - // blue.500 - "#2a94d6", - // purple.500 - "#6c4bc1", - // Grey 50% - "#808080", - // orange.500 - "#e7645c", -]; diff --git a/src/deployment/default/theme.ts b/src/deployment/default/theme.ts index 37edee589..2a2c1be3f 100644 --- a/src/deployment/default/theme.ts +++ b/src/deployment/default/theme.ts @@ -2,12 +2,8 @@ import { extendTheme, withDefaultVariant } from "@chakra-ui/react"; import colors from "./colors"; import Alert from "./components/alert"; import Button from "./components/button"; -import Text from "./components/text"; -import Heading from "./components/heading"; -import Tooltip from "./components/tooltip"; import fonts from "./fonts"; import radii from "./radii"; -import Avatar from "./components/avatar"; import shadows from "./shadows"; // See https://chakra-ui.com/docs/theming/customize-theme @@ -19,10 +15,6 @@ const overrides = { components: { Alert, Button, - Heading, - Tooltip, - Text, - Avatar, }, }; diff --git a/src/recording-graph.ts b/src/recording-graph.ts index e6b7bd218..17acdb7bf 100644 --- a/src/recording-graph.ts +++ b/src/recording-graph.ts @@ -62,7 +62,7 @@ export const getConfig = ({ }, { label: "y", - borderColor: "green", + borderColor: "brand2", borderWidth: 1, pointRadius: 0, pointHoverRadius: 0, diff --git a/vite.config.ts b/vite.config.ts index 267840c24..84f1b590e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,7 +12,7 @@ import { configDefaults } from "vitest/config"; import svgr from "vite-plugin-svgr"; // Support optionally pulling in external branding if the module is installed. -const theme = "TODO: theme package"; +const theme = "@microbit-foundation/ml-trainer-microbit"; const external = `node_modules/${theme}`; const internal = "src/deployment/default"; From d3aadc6263f042f2c4fa4be628175db741a932f3 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Wed, 2 Oct 2024 16:57:39 +0100 Subject: [PATCH 02/13] Use links from deployment --- src/components/HelpMenu.tsx | 74 +++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/src/components/HelpMenu.tsx b/src/components/HelpMenu.tsx index ec185d6e7..75161bf9d 100644 --- a/src/components/HelpMenu.tsx +++ b/src/components/HelpMenu.tsx @@ -19,6 +19,7 @@ import AboutDialog from "./AboutDialog"; import { FormattedMessage, useIntl } from "react-intl"; import { useRef } from "react"; import { manageCookies } from "../compliance"; +import { useDeployment } from "../deployment"; interface HelpMenuProps { isMobile?: boolean; @@ -33,6 +34,7 @@ const HelpMenu = ({ isMobile, appName, cookies, ...rest }: HelpMenuProps) => { const aboutDialogDisclosure = useDisclosure(); const intl = useIntl(); const MenuButtonRef = useRef(null); + const deployment = useDeployment(); return ( @@ -60,44 +62,54 @@ const HelpMenu = ({ isMobile, appName, cookies, ...rest }: HelpMenuProps) => { /> - } - > - - - - } - > - - - } - > - - - {cookies && ( + {deployment.supportLink && ( + <> + } + > + + + + + )} + {deployment.termsOfUseLink && ( + } + > + + + )} + {deployment.privacyPolicyLink && ( + } + > + + + )} + {deployment.compliance.manageCookies && ( } > )} - + {(deployment.privacyPolicyLink || + deployment.compliance.manageCookies || + deployment.termsOfUseLink) && } } onClick={aboutDialogDisclosure.onOpen} From 2495365dd3ee575e9464b27cd8316c2d5255c465 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Wed, 2 Oct 2024 19:26:22 +0100 Subject: [PATCH 03/13] Extract logos/app name --- lang/ui.en.json | 16 +++----- src/components/AboutDialog.tsx | 16 +++----- src/components/AppLogo.tsx | 51 ++++++++++++++----------- src/components/DefaultPageLayout.tsx | 14 +++---- src/components/HelpMenu.tsx | 14 +++---- src/components/InfoToolTip.tsx | 4 +- src/components/MicrobitLogo.tsx | 33 ---------------- src/components/TrainModelHelpDialog.tsx | 7 +++- src/components/TryAgainDialog.tsx | 7 +++- src/constants.ts | 1 - src/deployment/default/index.tsx | 31 ++++++++++++++- src/deployment/index.ts | 10 +++-- src/images/app-name.svg | 3 -- src/pages/HomePage.tsx | 4 +- 14 files changed, 105 insertions(+), 106 deletions(-) delete mode 100644 src/components/MicrobitLogo.tsx delete mode 100644 src/constants.ts delete mode 100644 src/images/app-name.svg diff --git a/lang/ui.en.json b/lang/ui.en.json index 3730ad02d..0b6384d1e 100644 --- a/lang/ui.en.json +++ b/lang/ui.en.json @@ -368,7 +368,7 @@ "description": "" }, "connectMB.usbTryAgain.closeTabs2": { - "defaultMessage": "Close any other tabs that may be using WebUSB (e.g. MakeCode, Python Editor, AI creator), or unplug and replug the micro:bit before trying again.", + "defaultMessage": "Close any other tabs that may be using WebUSB (e.g. MakeCode, Python Editor, {appNameShort}), or unplug and replug the micro:bit before trying again.", "description": "" }, "connectMB.usbTryAgain.heading": { @@ -432,7 +432,7 @@ "description": "" }, "content.data.classHelpBody": { - "defaultMessage": "The type of movement you want the micro:bit AI creator to recognise e.g. ‘waving’ or ‘clapping’.", + "defaultMessage": "The type of movement you want the {appNameFull} to recognise e.g. ‘waving’ or ‘clapping’.", "description": "" }, "content.data.classPlaceholderNewClass": { @@ -508,7 +508,7 @@ "description": "" }, "content.model.output.action.descriptionBody": { - "defaultMessage": "The type of movement you want the micro:bit AI creator to recognise e.g. ‘waving’ or ‘clapping’.", + "defaultMessage": "The type of movement you want the {appNameFull} to recognise e.g. ‘waving’ or ‘clapping’.", "description": "" }, "content.model.output.action.descriptionTitle": { @@ -556,7 +556,7 @@ "description": "" }, "content.trainer.description": { - "defaultMessage": "The computer program spots patterns or differences in your data samples, and uses these to build a mathematical model that allows the micro:bit AI creator to recognise different actions when you move your micro:bit.", + "defaultMessage": "The computer program spots patterns or differences in your data samples, and uses these to build a mathematical model that allows the {appNameFull} to recognise different actions when you move your micro:bit.", "description": "" }, "content.trainer.failure.body": { @@ -701,11 +701,7 @@ }, "homepage-subtitle": { "defaultMessage": "Introduce students to machine learning concepts through physical movement and data", - "description": "Subtitle of micro:bit AI creator home page" - }, - "homepage-title": { - "defaultMessage": "micro:bit AI creator", - "description": "Title of micro:bit AI creator home page" + "description": "Subtitle of the home page" }, "homepage.Link": { "defaultMessage": "Home page", @@ -979,4 +975,4 @@ "defaultMessage": "Train model", "description": "Train model step title" } -} \ No newline at end of file +} diff --git a/src/components/AboutDialog.tsx b/src/components/AboutDialog.tsx index 913e5e110..86ee052a3 100644 --- a/src/components/AboutDialog.tsx +++ b/src/components/AboutDialog.tsx @@ -28,12 +28,11 @@ import { import { ReactNode } from "react"; import { RiFileCopy2Line, RiGithubFill } from "react-icons/ri"; import { FormattedMessage, useIntl } from "react-intl"; +import { useDeployment } from "../deployment"; import aarhusLogo from "../images/aulogo_uk_var2_blue.png"; import microbitHeartImage from "../images/microbit-heart.png"; -import MicrobitLogo from "./MicrobitLogo"; interface AboutDialogProps { - appName: string; isOpen: boolean; onClose: () => void; finalFocusRef?: React.RefObject; @@ -42,15 +41,11 @@ interface AboutDialogProps { /** * An about dialog with version information. */ -const AboutDialog = ({ - isOpen, - onClose, - appName, - finalFocusRef, -}: AboutDialogProps) => { +const AboutDialog = ({ isOpen, onClose, finalFocusRef }: AboutDialogProps) => { + const { appNameFull } = useDeployment(); const versionInfo = [ { - name: `micro:bit ${appName}`, + name: appNameFull, value: import.meta.env.VITE_VERSION, href: "https://github.com/microbit-foundation/ml-trainer", }, @@ -61,6 +56,7 @@ const AboutDialog = ({ .join("\n"); const { hasCopied, onCopy } = useClipboard(clipboardVersion); + const { OrgLogo } = useDeployment(); const intl = useIntl(); return ( - + {OrgLogo && } diff --git a/src/components/AppLogo.tsx b/src/components/AppLogo.tsx index cff916430..1ca2c3e88 100644 --- a/src/components/AppLogo.tsx +++ b/src/components/AppLogo.tsx @@ -1,6 +1,5 @@ -import { As, Divider, HStack, Image } from "@chakra-ui/react"; -import AppNameLogo from "../images/app-name.svg"; -import MicrobitLogo from "./MicrobitLogo"; +import { As, Divider, HStack } from "@chakra-ui/react"; +import { useDeployment } from "../deployment"; const AppLogo = ({ color = "#FFF", @@ -9,25 +8,31 @@ const AppLogo = ({ color?: string; beta?: boolean; as?: As; - name: string; -}) => ( - - - - micro:bit - -); +}) => { + const { AppLogo, OrgLogo } = useDeployment(); + return ( + + {OrgLogo && ( + <> + + + + )} + + + ); +}; export default AppLogo; diff --git a/src/components/DefaultPageLayout.tsx b/src/components/DefaultPageLayout.tsx index fe7d86404..b71bdad78 100644 --- a/src/components/DefaultPageLayout.tsx +++ b/src/components/DefaultPageLayout.tsx @@ -14,7 +14,6 @@ import { ReactNode, useCallback, useEffect } from "react"; import { RiDownload2Line, RiFolderOpenLine, RiHome2Line } from "react-icons/ri"; import { FormattedMessage, useIntl } from "react-intl"; import { useNavigate } from "react-router"; -import { TOOL_NAME } from "../constants"; import { flags } from "../flags"; import { useProject } from "../hooks/project-hooks"; import { SaveStep, TrainModelDialogStage } from "../model"; @@ -35,6 +34,7 @@ import SaveDialogs from "./SaveDialogs"; import SettingsMenu from "./SettingsMenu"; import ToolbarMenu from "./ToolbarMenu"; import TrainModelDialogs from "./TrainModelFlowDialogs"; +import { useDeployment } from "../deployment"; interface DefaultPageLayoutProps { titleId?: string; @@ -63,13 +63,13 @@ const DefaultPageLayout = ({ const { saveHex } = useProject(); const [settings] = useSettings(); const toast = useToast(); + const { appNameFull } = useDeployment(); useEffect(() => { - const appName = `micro:bit ${TOOL_NAME}`; document.title = titleId - ? `${intl.formatMessage({ id: titleId })} | ${appName}` - : appName; - }, [intl, titleId]); + ? `${intl.formatMessage({ id: titleId })} | ${appNameFull}` + : appNameFull; + }, [appNameFull, intl, titleId]); useEffect(() => { return useStore.subscribe( @@ -134,7 +134,7 @@ const DefaultPageLayout = ({ )} } - itemsLeft={toolbarItemsLeft || } + itemsLeft={toolbarItemsLeft || } itemsRight={ <> @@ -160,7 +160,7 @@ const DefaultPageLayout = ({ )} - + { +const HelpMenu = ({ isMobile, ...rest }: HelpMenuProps) => { const aboutDialogDisclosure = useDisclosure(); const intl = useIntl(); const MenuButtonRef = useRef(null); @@ -39,7 +36,6 @@ const HelpMenu = ({ isMobile, appName, cookies, ...rest }: HelpMenuProps) => { return ( { {deployment.privacyPolicyLink && ( } diff --git a/src/components/InfoToolTip.tsx b/src/components/InfoToolTip.tsx index c184ed468..37f3a8fa7 100644 --- a/src/components/InfoToolTip.tsx +++ b/src/components/InfoToolTip.tsx @@ -2,12 +2,14 @@ import { Icon, Text, VStack } from "@chakra-ui/react"; import { RiInformationLine } from "react-icons/ri"; import { FormattedMessage } from "react-intl"; import ClickableTooltip from "./ClickableTooltip"; +import { useDeployment } from "../deployment"; export interface InfoToolTipProps { titleId: string; descriptionId: string; } const InfoToolTip = ({ titleId, descriptionId }: InfoToolTipProps) => { + const { appNameFull } = useDeployment(); return ( { - + } diff --git a/src/components/MicrobitLogo.tsx b/src/components/MicrobitLogo.tsx deleted file mode 100644 index 4c22a1639..000000000 --- a/src/components/MicrobitLogo.tsx +++ /dev/null @@ -1,33 +0,0 @@ -const MicrobitLogo = ({ - alt, - fill = "#fff", - height, -}: { - alt: string; - fill?: string; - height?: number; -}) => { - return ( - - {alt} - - - - - - - - ); -}; -export default MicrobitLogo; diff --git a/src/components/TrainModelHelpDialog.tsx b/src/components/TrainModelHelpDialog.tsx index 76132727d..3e1347152 100644 --- a/src/components/TrainModelHelpDialog.tsx +++ b/src/components/TrainModelHelpDialog.tsx @@ -16,6 +16,7 @@ import { import { ComponentProps, useCallback, useState } from "react"; import { FormattedMessage } from "react-intl"; import trainModelImage from "../images/train_model_black.svg"; +import { useDeployment } from "../deployment"; interface TrainModelHelpDialogProps extends Omit, "children"> { @@ -26,6 +27,7 @@ const TrainModelIntroDialog = ({ onNext, ...props }: TrainModelHelpDialogProps) => { + const { appNameFull } = useDeployment(); const [skip, setSkip] = useState(false); const handleNext = useCallback(() => onNext(skip), [onNext, skip]); @@ -56,7 +58,10 @@ const TrainModelIntroDialog = ({ /> - + diff --git a/src/components/TryAgainDialog.tsx b/src/components/TryAgainDialog.tsx index 2acb5c011..cd19e3472 100644 --- a/src/components/TryAgainDialog.tsx +++ b/src/components/TryAgainDialog.tsx @@ -14,6 +14,7 @@ import { } from "@chakra-ui/react"; import { FormattedMessage } from "react-intl"; import { ConnectionFlowStep } from "../connection-stage-hooks"; +import { useDeployment } from "../deployment"; const OneLineContent = ({ textId }: { textId: string }) => { return ( @@ -47,13 +48,17 @@ const ReplugMicrobitContent = () => { }; const CloseTabsContent = () => { + const { appNameShort } = useDeployment(); return ( - + ); diff --git a/src/constants.ts b/src/constants.ts deleted file mode 100644 index 76b04338b..000000000 --- a/src/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const TOOL_NAME = "AI creator"; diff --git a/src/deployment/default/index.tsx b/src/deployment/default/index.tsx index 658d681fe..825642a25 100644 --- a/src/deployment/default/index.tsx +++ b/src/deployment/default/index.tsx @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: MIT */ +import { Box, BoxProps, Text, VStack } from "@chakra-ui/react"; import { ReactNode, createContext } from "react"; import { CookieConsent, DeploymentConfigFactory } from ".."; import { NullLogging } from "./logging"; @@ -18,8 +19,34 @@ const stubConsentContext = createContext( const defaultDeploymentFactory: DeploymentConfigFactory = () => ({ chakraTheme: theme, - // This isn't ideal as it's the branded version. You can just remove the field to remove the welcome dialog. - welcomeVideoYouTubeId: "mREwMW69qKc", + appNameFull: "ml-trainer", + appNameShort: "ml-trainer", + AppLogo: (props: BoxProps) => { + return ( + + ml-trainer + + ); + }, + OrgLogo: (props: BoxProps) => { + return ( + + micro:bit + + ); + }, logging: new NullLogging(), compliance: { ConsentProvider: ({ children }: { children: ReactNode }) => ( diff --git a/src/deployment/index.ts b/src/deployment/index.ts index d0fca8491..d94fd213a 100644 --- a/src/deployment/index.ts +++ b/src/deployment/index.ts @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: MIT */ -import { ReactNode, useContext } from "react"; +import { ComponentType, ReactNode, useContext } from "react"; import { Logging } from "../logging/logging"; export type DeploymentConfigFactory = ( @@ -12,6 +12,7 @@ export type DeploymentConfigFactory = ( // This is configured via a vite alias, defaulting to ./default import { default as df } from "theme-package"; +import { BoxProps } from "@chakra-ui/react"; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const deploymentFactory: DeploymentConfigFactory = df; export const deployment = deploymentFactory(import.meta.env); @@ -22,9 +23,11 @@ export interface CookieConsent { } export interface DeploymentConfig { + appNameShort: string; + appNameFull: string; + AppLogo: ComponentType; + OrgLogo?: ComponentType; welcomeVideoYouTubeId?: string; - squareLogo?: ReactNode; - horizontalLogo?: ReactNode; compliance: { /** * A provider that will be used to wrap the app UI. @@ -48,7 +51,6 @@ export interface DeploymentConfig { guideLink?: string; termsOfUseLink?: string; privacyPolicyLink?: string; - translationLink?: string; logging: Logging; } diff --git a/src/images/app-name.svg b/src/images/app-name.svg deleted file mode 100644 index 91ba31ad4..000000000 --- a/src/images/app-name.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/pages/HomePage.tsx b/src/pages/HomePage.tsx index b2e638afa..91e8ac368 100644 --- a/src/pages/HomePage.tsx +++ b/src/pages/HomePage.tsx @@ -12,6 +12,7 @@ import StartResumeActions from "../components/StartResumeActions"; import addDataImage from "../images/add_data.svg"; import testModelImage from "../images/test_model_blue.svg"; import trainModelImage from "../images/train_model_blue.svg"; +import { useDeployment } from "../deployment"; type StepId = "add-data" | "train-model" | "test-model"; @@ -37,6 +38,7 @@ const stepsConfig: StepConfig[] = [ const HomePage = () => { const intl = useIntl(); + const { appNameFull } = useDeployment(); return ( { > - + {appNameFull} From a5f8cc6a236cfe6728b1ca3145fbe57ff35f7a89 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Thu, 3 Oct 2024 09:48:44 +0100 Subject: [PATCH 04/13] Tidying --- src/components/AboutDialog.tsx | 2 +- src/deployment/index.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/AboutDialog.tsx b/src/components/AboutDialog.tsx index 86ee052a3..5853a1544 100644 --- a/src/components/AboutDialog.tsx +++ b/src/components/AboutDialog.tsx @@ -80,7 +80,7 @@ const AboutDialog = ({ isOpen, onClose, finalFocusRef }: AboutDialogProps) => { values={{ link: (chunks: ReactNode) => ( Date: Thu, 3 Oct 2024 10:35:34 +0100 Subject: [PATCH 05/13] Try installing the package; fix logo size --- .github/workflows/build.yml | 2 +- src/components/AppLogo.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a6c1c3b2..4ec1cf510 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: - run: npm ci env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: npm install --no-save @microbit-foundation/website-deploy-aws@0.6 @microbit-foundation/website-deploy-aws-config@0.9 + - run: npm install --no-save @microbit-foundation/ml-trainer-microbit@0.1.0 @microbit-foundation/website-deploy-aws@0.6 @microbit-foundation/website-deploy-aws-config@0.9 if: github.repository_owner == 'microbit-foundation' env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/components/AppLogo.tsx b/src/components/AppLogo.tsx index 1ca2c3e88..793b05b2b 100644 --- a/src/components/AppLogo.tsx +++ b/src/components/AppLogo.tsx @@ -30,7 +30,7 @@ const AppLogo = ({ /> )} - + ); }; From b08cca8ef597c9e13627db4f0018566ba885c505 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Thu, 3 Oct 2024 10:37:56 +0100 Subject: [PATCH 06/13] Remove unused file, tidy imports --- src/compliance.tsx | 89 -------------------------------- src/deployment/default/index.tsx | 2 +- 2 files changed, 1 insertion(+), 90 deletions(-) delete mode 100644 src/compliance.tsx diff --git a/src/compliance.tsx b/src/compliance.tsx deleted file mode 100644 index 1866c2863..000000000 --- a/src/compliance.tsx +++ /dev/null @@ -1,89 +0,0 @@ -// We use the shared-assets consent API on window, which currently lacks types. -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import { - ReactNode, - createContext, - useContext, - useEffect, - useState, -} from "react"; - -export interface CookieConsent { - analytics: boolean; - functional: boolean; -} - -export const consentContext = createContext( - undefined -); - -const config = { - ga: - import.meta.env.VITE_STAGE === "PRODUCTION" || - import.meta.env.VITE_STAGE === "STAGING" - ? {} - : undefined, - custom: [ - { - type: "cookie", - category: "essential", - name: "pgs-auth-jwt", - domain: "data.microbit.org", - purpose: - "Session information so we know what class code you are signed in as", - }, - { - type: "local", - category: "essential", - name: "settings", - domain: "data.microbit.org", - purpose: - "Used to store your settings and remember which dialogs you've opted not to be shown in future", - }, - ], -}; - -const showConsent = ( - { userTriggered }: { userTriggered: boolean } = { userTriggered: false } -) => { - const w = window as any; - w.commonConsent?.show({ userTriggered, config }); -}; - -const hideConsent = () => { - const w = window as any; - w.commonConsent?.hide(); -}; - -export const manageCookies = () => showConsent({ userTriggered: true }); - -export const ConsentProvider = ({ children }: { children: ReactNode }) => { - const [value, setValue] = useState(undefined); - useEffect(() => { - const w = window as any; - const updateListener = (event: CustomEvent) => { - setValue(event.detail); - }; - w.addEventListener("consentchange", updateListener); - if (w.commonConsent) { - showConsent(); - } else { - w.addEventListener("consentinit", showConsent); - } - return () => { - w.removeEventListener("consentchange", updateListener); - w.removeEventListener("consentinit", showConsent); - hideConsent(); - }; - }, []); - - return ( - {children} - ); -}; -export const useConsent = () => { - return useContext(consentContext); -}; diff --git a/src/deployment/default/index.tsx b/src/deployment/default/index.tsx index 825642a25..588112bd8 100644 --- a/src/deployment/default/index.tsx +++ b/src/deployment/default/index.tsx @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: MIT */ -import { Box, BoxProps, Text, VStack } from "@chakra-ui/react"; +import { BoxProps, Text, VStack } from "@chakra-ui/react"; import { ReactNode, createContext } from "react"; import { CookieConsent, DeploymentConfigFactory } from ".."; import { NullLogging } from "./logging"; From ea3b0e834717ed357c1c7b39e8d19a65b93b4da4 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Thu, 3 Oct 2024 10:45:11 +0100 Subject: [PATCH 07/13] Bump theme package --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ec1cf510..bc49eeb0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: - run: npm ci env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: npm install --no-save @microbit-foundation/ml-trainer-microbit@0.1.0 @microbit-foundation/website-deploy-aws@0.6 @microbit-foundation/website-deploy-aws-config@0.9 + - run: npm install --no-save @microbit-foundation/ml-trainer-microbit@0.2.0-dev.4 @microbit-foundation/website-deploy-aws@0.6 @microbit-foundation/website-deploy-aws-config@0.9 if: github.repository_owner == 'microbit-foundation' env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a12a7d5a58ac97da8947412a70ec2a6ed6067c44 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Thu, 3 Oct 2024 10:52:29 +0100 Subject: [PATCH 08/13] Use brand not blue for links --- src/components/AboutDialog.tsx | 2 +- src/components/BrokenFirmwareDialog.tsx | 6 +++--- src/components/ConnectBatteryDialog.tsx | 4 ++-- src/components/ErrorHandlerErrorView.tsx | 2 +- src/components/ManualFlashingDialog.tsx | 2 +- src/components/NotFound.tsx | 2 +- src/components/StartOverWarningDialog.tsx | 2 +- src/components/UnsupportedMicrobitDialog.tsx | 4 ++-- src/deployment/default/components/button.ts | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/AboutDialog.tsx b/src/components/AboutDialog.tsx index 5853a1544..7883b4acc 100644 --- a/src/components/AboutDialog.tsx +++ b/src/components/AboutDialog.tsx @@ -83,7 +83,7 @@ const AboutDialog = ({ isOpen, onClose, finalFocusRef }: AboutDialogProps) => { href="https://cctd.au.dk/" target="_blank" rel="noopener" - color="blue.600" + color="brand.600" > {chunks} diff --git a/src/components/BrokenFirmwareDialog.tsx b/src/components/BrokenFirmwareDialog.tsx index 830387f30..078e23848 100644 --- a/src/components/BrokenFirmwareDialog.tsx +++ b/src/components/BrokenFirmwareDialog.tsx @@ -55,7 +55,7 @@ const BrokenFirmwareDialog = ({ values={{ link: (chunks: ReactNode) => ( diff --git a/src/components/ConnectBatteryDialog.tsx b/src/components/ConnectBatteryDialog.tsx index 7f2f01e55..7633e6a08 100644 --- a/src/components/ConnectBatteryDialog.tsx +++ b/src/components/ConnectBatteryDialog.tsx @@ -19,7 +19,7 @@ const ConnectBatteryDialog = ({ ...props }: ConnectBatteryDialogProps) => { { diff --git a/src/components/ErrorHandlerErrorView.tsx b/src/components/ErrorHandlerErrorView.tsx index 29648e6af..e97ff4795 100644 --- a/src/components/ErrorHandlerErrorView.tsx +++ b/src/components/ErrorHandlerErrorView.tsx @@ -14,7 +14,7 @@ const ErrorHandlerErrorView = () => { values={{ link: (chunks: ReactNode) => ( ( - + {chunks} ), diff --git a/src/components/NotFound.tsx b/src/components/NotFound.tsx index 1551333b5..6402d6fa2 100644 --- a/src/components/NotFound.tsx +++ b/src/components/NotFound.tsx @@ -11,7 +11,7 @@ const NotFound = ({ href }: NotFoundProps) => { const intl = useIntl(); return ( - + diff --git a/src/components/StartOverWarningDialog.tsx b/src/components/StartOverWarningDialog.tsx index 39cbd8e94..9ddaafe75 100644 --- a/src/components/StartOverWarningDialog.tsx +++ b/src/components/StartOverWarningDialog.tsx @@ -56,7 +56,7 @@ const StartOverWarningDialog = ({ values={{ link: (chunks: ReactNode) => ( ( ( ({ borderWidth: "0", - color: "blue.600", + color: "brand.600", fontWeight: "normal", bg: "transparent", }), From f0613cdb3b708f1826de8781d4fd2d687b5eef48 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon <44397098+microbit-matt-hillsdon@users.noreply.github.com> Date: Thu, 3 Oct 2024 11:04:17 +0100 Subject: [PATCH 09/13] Remove unused font --- src/deployment/default/fonts.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/deployment/default/fonts.ts b/src/deployment/default/fonts.ts index 4d9bf9a30..417ded38d 100644 --- a/src/deployment/default/fonts.ts +++ b/src/deployment/default/fonts.ts @@ -6,7 +6,6 @@ const fonts = { heading: "Helvetica, Arial, sans-serif", body: "Helvetica, Arial, sans-serif", - code: "Source Code Pro, monospace", }; export default fonts; From 360156192c3b4e151c360c0357515ebf0ed2d2b1 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Thu, 3 Oct 2024 11:07:09 +0100 Subject: [PATCH 10/13] Drop the org "logo" --- src/deployment/default/index.tsx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/deployment/default/index.tsx b/src/deployment/default/index.tsx index 588112bd8..1791a5d1f 100644 --- a/src/deployment/default/index.tsx +++ b/src/deployment/default/index.tsx @@ -34,19 +34,7 @@ const defaultDeploymentFactory: DeploymentConfigFactory = () => ({ ); }, - OrgLogo: (props: BoxProps) => { - return ( - - micro:bit - - ); - }, + OrgLogo: undefined, logging: new NullLogging(), compliance: { ConsentProvider: ({ children }: { children: ReactNode }) => ( From 59838724eea7b5337eefed03af9edb129cf35786 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Thu, 3 Oct 2024 11:18:08 +0100 Subject: [PATCH 11/13] Bump theme package --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc49eeb0e..9810cd371 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: - run: npm ci env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: npm install --no-save @microbit-foundation/ml-trainer-microbit@0.2.0-dev.4 @microbit-foundation/website-deploy-aws@0.6 @microbit-foundation/website-deploy-aws-config@0.9 + - run: npm install --no-save @microbit-foundation/ml-trainer-microbit@0.2.0-dev.5 @microbit-foundation/website-deploy-aws@0.6 @microbit-foundation/website-deploy-aws-config@0.9 if: github.repository_owner == 'microbit-foundation' env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9637ca2cce31bf7286d7f1b01f62555956514b81 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Thu, 3 Oct 2024 12:49:16 +0100 Subject: [PATCH 12/13] Tidy --- src/components/AboutDialog.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/AboutDialog.tsx b/src/components/AboutDialog.tsx index 7883b4acc..3a9520932 100644 --- a/src/components/AboutDialog.tsx +++ b/src/components/AboutDialog.tsx @@ -42,7 +42,7 @@ interface AboutDialogProps { * An about dialog with version information. */ const AboutDialog = ({ isOpen, onClose, finalFocusRef }: AboutDialogProps) => { - const { appNameFull } = useDeployment(); + const { appNameFull, OrgLogo } = useDeployment(); const versionInfo = [ { name: appNameFull, @@ -56,7 +56,6 @@ const AboutDialog = ({ isOpen, onClose, finalFocusRef }: AboutDialogProps) => { .join("\n"); const { hasCopied, onCopy } = useClipboard(clipboardVersion); - const { OrgLogo } = useDeployment(); const intl = useIntl(); return ( Date: Thu, 3 Oct 2024 12:51:56 +0100 Subject: [PATCH 13/13] Reinstate some extra grays we use, tidy --- src/deployment/default/colors.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/deployment/default/colors.ts b/src/deployment/default/colors.ts index d0173254a..a324a4350 100644 --- a/src/deployment/default/colors.ts +++ b/src/deployment/default/colors.ts @@ -5,8 +5,19 @@ */ import { theme } from "@chakra-ui/theme"; +const gray = { + 10: "#fcfcfc", + 25: "#f5f5f5", + ...theme.colors.gray, + // Brand grey + 500: "#e5e5e5", + // windi css text color + 600: "#6b7280", +}; + const colors = { ...theme.colors, + gray, brand: theme.colors.blue, brand2: theme.colors.gray, };