From f29d50825b455ba90ab87ec120770e008adc88f2 Mon Sep 17 00:00:00 2001 From: Nicolas Van Labeke Date: Mon, 11 Sep 2023 14:23:43 +0100 Subject: [PATCH 01/24] feat(93): Refactor HiveMQ theme to define custom side panels --- .../frontend/src/modules/App/themes/Drawer.ts | 14 ++++++ .../src/modules/App/themes/FormControl.ts | 17 +++++++ .../src/modules/App/themes/themeHiveMQ.ts | 49 ++++++++++++++----- 3 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 hivemq-edge/src/frontend/src/modules/App/themes/Drawer.ts create mode 100644 hivemq-edge/src/frontend/src/modules/App/themes/FormControl.ts diff --git a/hivemq-edge/src/frontend/src/modules/App/themes/Drawer.ts b/hivemq-edge/src/frontend/src/modules/App/themes/Drawer.ts new file mode 100644 index 0000000000..6b9a0fb281 --- /dev/null +++ b/hivemq-edge/src/frontend/src/modules/App/themes/Drawer.ts @@ -0,0 +1,14 @@ +import { createMultiStyleConfigHelpers } from '@chakra-ui/react' +import { drawerAnatomy } from '@chakra-ui/anatomy' + +const { definePartsStyle, defineMultiStyleConfig } = createMultiStyleConfigHelpers(drawerAnatomy.keys) + +const hivemq = definePartsStyle({ + dialog: { + backgroundColor: 'gray.50', + }, +}) + +export const drawerTheme = defineMultiStyleConfig({ + variants: { hivemq }, +}) diff --git a/hivemq-edge/src/frontend/src/modules/App/themes/FormControl.ts b/hivemq-edge/src/frontend/src/modules/App/themes/FormControl.ts new file mode 100644 index 0000000000..b241e8b410 --- /dev/null +++ b/hivemq-edge/src/frontend/src/modules/App/themes/FormControl.ts @@ -0,0 +1,17 @@ +import { createMultiStyleConfigHelpers } from '@chakra-ui/react' +import { formAnatomy } from '@chakra-ui/anatomy' + +const { definePartsStyle, defineMultiStyleConfig } = createMultiStyleConfigHelpers(formAnatomy.keys) + +const hivemq = definePartsStyle({ + container: { + backgroundColor: 'white', + padding: 4, + borderRadius: 6, + borderWidth: 1, + }, +}) + +export const formControlTheme = defineMultiStyleConfig({ + variants: { hivemq }, +}) diff --git a/hivemq-edge/src/frontend/src/modules/App/themes/themeHiveMQ.ts b/hivemq-edge/src/frontend/src/modules/App/themes/themeHiveMQ.ts index 84be6d0bfd..3236c9405d 100644 --- a/hivemq-edge/src/frontend/src/modules/App/themes/themeHiveMQ.ts +++ b/hivemq-edge/src/frontend/src/modules/App/themes/themeHiveMQ.ts @@ -3,7 +3,10 @@ import { defineStyleConfig, extendTheme, theme as baseTheme } from '@chakra-ui/react' import '@fontsource/roboto/400.css' import '@fontsource/roboto/700.css' + import { statTheme } from './Stat' +import { drawerTheme } from './Drawer.ts' +import { formControlTheme } from './FormControl.ts' const Button = defineStyleConfig({ defaultProps: { @@ -17,17 +20,38 @@ export const formStyles = { baseStyle: { container: { label: { - fontWeight: 'bold', + fontWeight: 'medium', }, h5: { fontSize: 'lg', }, - p: { - margin: '4px', - '.chakra-text': { - fontSize: 'sm', - }, + // p: { + // margin: '4px', + // '.chakra-text': { + // fontSize: 'sm', + // }, + // }, + }, + }, +} + +export const TestStyles = { + parts: ['container', 'requiredIndicator', 'helperText'], + baseStyle: { + container: { + backgroundColor: 'red', + label: { + fontWeight: 'medium', + }, + h5: { + fontSize: 'lg', }, + // p: { + // margin: '4px', + // '.chakra-text': { + // fontSize: 'sm', + // }, + // }, }, }, } @@ -38,11 +62,11 @@ export const themeHiveMQ = extendTheme({ body: `'Roboto', sans-serif`, }, - fontSizes: { - lg: '16px', - md: '14px', - sm: '12px', - }, + // fontSizes: { + // lg: '16px', + // md: '14px', + // sm: '12px', + // }, colors: { status: { @@ -73,6 +97,7 @@ export const themeHiveMQ = extendTheme({ components: { Button, Stat: statTheme, - Form: formStyles, + Drawer: drawerTheme, + Form: formControlTheme, }, }) From 715be1805da51e8140553f979190eed861d45ed4 Mon Sep 17 00:00:00 2001 From: Nicolas Van Labeke Date: Mon, 11 Sep 2023 14:28:00 +0100 Subject: [PATCH 02/24] refactor(93): reorganise HiveMQ theme as a proper module --- hivemq-edge/src/frontend/cypress/support/component.tsx | 2 +- hivemq-edge/src/frontend/src/modules/App/MainApp.tsx | 3 ++- .../src/modules/{App/themes => Theme/styles}/Drawer.ts | 0 .../src/modules/{App/themes => Theme/styles}/FormControl.ts | 0 .../src/modules/{App/themes => Theme/styles}/Stat.ts | 0 .../src/modules/{App/themes => Theme}/themeHiveMQ.ts | 6 +++--- 6 files changed, 6 insertions(+), 5 deletions(-) rename hivemq-edge/src/frontend/src/modules/{App/themes => Theme/styles}/Drawer.ts (100%) rename hivemq-edge/src/frontend/src/modules/{App/themes => Theme/styles}/FormControl.ts (100%) rename hivemq-edge/src/frontend/src/modules/{App/themes => Theme/styles}/Stat.ts (100%) rename hivemq-edge/src/frontend/src/modules/{App/themes => Theme}/themeHiveMQ.ts (93%) diff --git a/hivemq-edge/src/frontend/cypress/support/component.tsx b/hivemq-edge/src/frontend/cypress/support/component.tsx index 900c443bce..481bf42069 100644 --- a/hivemq-edge/src/frontend/cypress/support/component.tsx +++ b/hivemq-edge/src/frontend/cypress/support/component.tsx @@ -27,7 +27,7 @@ import { ChakraProvider, VisuallyHidden } from '@chakra-ui/react' import { QueryClientProvider } from '@tanstack/react-query' import { AuthProvider } from '@/modules/Auth/AuthProvider.tsx' -import { themeHiveMQ } from '@/modules/App/themes/themeHiveMQ.ts' +import { themeHiveMQ } from '@/modules/Theme/themeHiveMQ.ts' import queryClient from '@/api/queryClient.ts' import '@/config/i18n.config.ts' diff --git a/hivemq-edge/src/frontend/src/modules/App/MainApp.tsx b/hivemq-edge/src/frontend/src/modules/App/MainApp.tsx index ab78d27ae1..d4d26784f4 100644 --- a/hivemq-edge/src/frontend/src/modules/App/MainApp.tsx +++ b/hivemq-edge/src/frontend/src/modules/App/MainApp.tsx @@ -2,8 +2,9 @@ import { FC } from 'react' import { RouterProvider } from 'react-router-dom' import { ChakraProvider } from '@chakra-ui/react' +import { themeHiveMQ } from '@/modules/Theme/themeHiveMQ.ts' + import { routes } from './routes.tsx' -import { themeHiveMQ } from './themes/themeHiveMQ.ts' import { AuthProvider } from '../Auth/AuthProvider.tsx' import { QueryClientProvider } from '@tanstack/react-query' import { ReactQueryDevtools } from '@tanstack/react-query-devtools' diff --git a/hivemq-edge/src/frontend/src/modules/App/themes/Drawer.ts b/hivemq-edge/src/frontend/src/modules/Theme/styles/Drawer.ts similarity index 100% rename from hivemq-edge/src/frontend/src/modules/App/themes/Drawer.ts rename to hivemq-edge/src/frontend/src/modules/Theme/styles/Drawer.ts diff --git a/hivemq-edge/src/frontend/src/modules/App/themes/FormControl.ts b/hivemq-edge/src/frontend/src/modules/Theme/styles/FormControl.ts similarity index 100% rename from hivemq-edge/src/frontend/src/modules/App/themes/FormControl.ts rename to hivemq-edge/src/frontend/src/modules/Theme/styles/FormControl.ts diff --git a/hivemq-edge/src/frontend/src/modules/App/themes/Stat.ts b/hivemq-edge/src/frontend/src/modules/Theme/styles/Stat.ts similarity index 100% rename from hivemq-edge/src/frontend/src/modules/App/themes/Stat.ts rename to hivemq-edge/src/frontend/src/modules/Theme/styles/Stat.ts diff --git a/hivemq-edge/src/frontend/src/modules/App/themes/themeHiveMQ.ts b/hivemq-edge/src/frontend/src/modules/Theme/themeHiveMQ.ts similarity index 93% rename from hivemq-edge/src/frontend/src/modules/App/themes/themeHiveMQ.ts rename to hivemq-edge/src/frontend/src/modules/Theme/themeHiveMQ.ts index 3236c9405d..30a0161515 100644 --- a/hivemq-edge/src/frontend/src/modules/App/themes/themeHiveMQ.ts +++ b/hivemq-edge/src/frontend/src/modules/Theme/themeHiveMQ.ts @@ -4,9 +4,9 @@ import { defineStyleConfig, extendTheme, theme as baseTheme } from '@chakra-ui/r import '@fontsource/roboto/400.css' import '@fontsource/roboto/700.css' -import { statTheme } from './Stat' -import { drawerTheme } from './Drawer.ts' -import { formControlTheme } from './FormControl.ts' +import { statTheme } from './styles/Stat' +import { drawerTheme } from './styles/Drawer.ts' +import { formControlTheme } from './styles/FormControl.ts' const Button = defineStyleConfig({ defaultProps: { From c2715ac129e22d69443414e3a3b6f7bcc3f8938e Mon Sep 17 00:00:00 2001 From: Nicolas Van Labeke Date: Mon, 11 Sep 2023 17:03:38 +0100 Subject: [PATCH 03/24] refactor(93): restructure the bridge side panel - add custom variant to drawer - add custom variant panel designed as fieldset --- .../components/panels/BridgeMainDrawer.tsx | 9 +++- .../components/panels/ConnectionPanel.tsx | 47 +++++++++---------- .../Bridges/components/panels/NamePanel.tsx | 2 +- .../components/panels/OptionsPanel.tsx | 5 +- .../components/panels/SecurityPanel.tsx | 6 +-- .../components/panels/SubscriptionsPanel.tsx | 2 +- 6 files changed, 37 insertions(+), 34 deletions(-) diff --git a/hivemq-edge/src/frontend/src/modules/Bridges/components/panels/BridgeMainDrawer.tsx b/hivemq-edge/src/frontend/src/modules/Bridges/components/panels/BridgeMainDrawer.tsx index cb3a469b36..d2f741aae4 100644 --- a/hivemq-edge/src/frontend/src/modules/Bridges/components/panels/BridgeMainDrawer.tsx +++ b/hivemq-edge/src/frontend/src/modules/Bridges/components/panels/BridgeMainDrawer.tsx @@ -61,7 +61,14 @@ const BridgeMainDrawer: FC = ({ return ( <> - + diff --git a/hivemq-edge/src/frontend/src/modules/Bridges/components/panels/ConnectionPanel.tsx b/hivemq-edge/src/frontend/src/modules/Bridges/components/panels/ConnectionPanel.tsx index cd817c5f94..6d665d3880 100644 --- a/hivemq-edge/src/frontend/src/modules/Bridges/components/panels/ConnectionPanel.tsx +++ b/hivemq-edge/src/frontend/src/modules/Bridges/components/panels/ConnectionPanel.tsx @@ -27,31 +27,28 @@ const ConnectionPanel: FC = ({ form }) => { } = form return ( - - - - - {t('bridge.connection.host')} - - {errors.host && errors.host.message} - - - - - {t('bridge.connection.port')} - - - - - - - - {errors.port && errors.port.message} - - - + + + + {t('bridge.connection.host')} + + {errors.host && errors.host.message} + + + + {t('bridge.connection.port')} + + + + + + + + {errors.port && errors.port.message} + + - + {t('bridge.connection.username')} @@ -76,7 +73,7 @@ const ConnectionPanel: FC = ({ form }) => { {errors.password && errors.password.message} - + {/**/} {/*