From 07df7f029a1acf9be0fb434c2021917ebaa17ae3 Mon Sep 17 00:00:00 2001 From: andrealouisestanderen Date: Wed, 3 Jan 2024 15:19:51 +0100 Subject: [PATCH] Revert "Use PascalCase for viewSize enums" This reverts commit bdf872ee703b4cb39d3fdd9a24cd21f8075bb9ca. --- .../config/editModal/EditGrid/EditGrid.tsx | 22 +++++------ .../EditGridForGivenViewSize.test.tsx | 4 +- .../editModal/EditGrid/types/ViewSize.ts | 10 ++--- .../config/editModal/EditGrid/utils.test.ts | 28 +++++++------- .../config/editModal/EditGrid/utils.ts | 38 +++++++++---------- 5 files changed, 49 insertions(+), 53 deletions(-) diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/EditGrid.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/EditGrid.tsx index a40adde727d..b9518dfb630 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/EditGrid.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/EditGrid.tsx @@ -25,7 +25,7 @@ const setGridOnComponent = (gridValues: GridSizes, component: FormComponent) => export const EditGrid = ({ handleComponentChange, component }: IGenericEditComponent) => { const [gridValues, setGridValues] = useState(component.grid ?? {}); const [selectedViewSizeForGridProp, setSelectedViewSizeForGridProp] = useState( - ViewSize.Xs, + ViewSize.xs, ); const { t } = useTranslation(); @@ -36,11 +36,11 @@ export const EditGrid = ({ handleComponentChange, component }: IGenericEditCompo }; const iconMapping: Record = { - [ViewSize.Xs]: , - [ViewSize.Sm]: , - [ViewSize.Md]: , - [ViewSize.Lg]: , - [ViewSize.Xl]: , + [ViewSize.xs]: , + [ViewSize.sm]: , + [ViewSize.md]: , + [ViewSize.lg]: , + [ViewSize.xl]: , }; return ( @@ -54,19 +54,15 @@ export const EditGrid = ({ handleComponentChange, component }: IGenericEditCompo {Object.keys(ViewSize).map((viewSize: ViewSize) => { return ( - - {t(`ux_editor.modal_properties_grid_size_${viewSize.toLowerCase()}`)} + + {t(`ux_editor.modal_properties_grid_size_${viewSize}`)} ); })} {Object.keys(ViewSize).map((viewSize: ViewSize) => { return ( - + handleUpdateGrid(newGridValues)} gridValues={gridValues} diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/EditGridForGivenViewSize.test.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/EditGridForGivenViewSize.test.tsx index 1ce21b71663..84f7a16ad63 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/EditGridForGivenViewSize.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/EditGridForGivenViewSize.test.tsx @@ -21,7 +21,7 @@ type RenderProps = { const render = async ({ gridValues = { xs: 3, md: 10 }, - viewSize = ViewSize.Md, + viewSize = ViewSize.md, handleUpdateGrid = jest.fn(), }: RenderProps = {}) => { await waitForData(); @@ -55,7 +55,7 @@ describe('EditGridForGivenViewSize', () => { }); it('should show that default value, 12, is set for grid when gridValue is not set for mobile viewSize', async () => { - await render({ gridValues: { md: 3 }, viewSize: ViewSize.Sm }); + await render({ gridValues: { md: 3 }, viewSize: ViewSize.sm }); const lockIconMobile = screen.getByRole('img', { name: 'lockIcon' }); expect(lockIconMobile).toBeInTheDocument(); diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/types/ViewSize.ts b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/types/ViewSize.ts index 82da5a52120..f51e1869551 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/types/ViewSize.ts +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/types/ViewSize.ts @@ -1,7 +1,7 @@ export enum ViewSize { - Xs = 'xs', - Sm = 'sm', - Md = 'md', - Lg = 'lg', - Xl = 'xl', + xs = 'xs', + sm = 'sm', + md = 'md', + lg = 'lg', + xl = 'xl', } diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/utils.test.ts b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/utils.test.ts index 4196f1dbc85..132d2658fd0 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/utils.test.ts +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/utils.test.ts @@ -6,30 +6,30 @@ describe('utils', () => { describe('findEffectiveGridSize', () => { it('Returns correct value', () => { const gridSizes: GridSizes = { - [ViewSize.Xs]: 12, - [ViewSize.Md]: 6, + [ViewSize.xs]: 12, + [ViewSize.md]: 6, }; - expect(findEffectiveGridSize(gridSizes, ViewSize.Xs)).toBe(12); - expect(findEffectiveGridSize(gridSizes, ViewSize.Sm)).toBe(12); - expect(findEffectiveGridSize(gridSizes, ViewSize.Md)).toBe(6); - expect(findEffectiveGridSize(gridSizes, ViewSize.Lg)).toBe(6); - expect(findEffectiveGridSize(gridSizes, ViewSize.Xl)).toBe(6); + expect(findEffectiveGridSize(gridSizes, ViewSize.xs)).toBe(12); + expect(findEffectiveGridSize(gridSizes, ViewSize.sm)).toBe(12); + expect(findEffectiveGridSize(gridSizes, ViewSize.md)).toBe(6); + expect(findEffectiveGridSize(gridSizes, ViewSize.lg)).toBe(6); + expect(findEffectiveGridSize(gridSizes, ViewSize.xl)).toBe(6); }); it('Returns 12 when no grid values are set', () => { const gridSizes: GridSizes = {}; - expect(findEffectiveGridSize(gridSizes, ViewSize.Xs)).toBe(12); - expect(findEffectiveGridSize(gridSizes, ViewSize.Sm)).toBe(12); - expect(findEffectiveGridSize(gridSizes, ViewSize.Md)).toBe(12); - expect(findEffectiveGridSize(gridSizes, ViewSize.Lg)).toBe(12); - expect(findEffectiveGridSize(gridSizes, ViewSize.Xl)).toBe(12); + expect(findEffectiveGridSize(gridSizes, ViewSize.xs)).toBe(12); + expect(findEffectiveGridSize(gridSizes, ViewSize.sm)).toBe(12); + expect(findEffectiveGridSize(gridSizes, ViewSize.md)).toBe(12); + expect(findEffectiveGridSize(gridSizes, ViewSize.lg)).toBe(12); + expect(findEffectiveGridSize(gridSizes, ViewSize.xl)).toBe(12); }); it('Returns 12 when no grid values on view sizes below the current one are set', () => { const gridSizes: GridSizes = { - [ViewSize.Xl]: 6, + [ViewSize.xl]: 6, }; - expect(findEffectiveGridSize(gridSizes, ViewSize.Xs)).toBe(12); + expect(findEffectiveGridSize(gridSizes, ViewSize.xs)).toBe(12); }); }); }); diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/utils.ts b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/utils.ts index 697c7448c8e..52322fa555e 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/utils.ts +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditGrid/utils.ts @@ -7,32 +7,32 @@ export const findEffectiveGridSize = ( currentViewSize: ViewSize, ): GridSize => { switch (currentViewSize) { - case ViewSize.Xs: - return selectedViewSizes[ViewSize.Xs] || 12; - case ViewSize.Sm: - return selectedViewSizes[ViewSize.Sm] || selectedViewSizes[ViewSize.Xs] || 12; - case ViewSize.Md: + case ViewSize.xs: + return selectedViewSizes[ViewSize.xs] || 12; + case ViewSize.sm: + return selectedViewSizes[ViewSize.sm] || selectedViewSizes[ViewSize.xs] || 12; + case ViewSize.md: return ( - selectedViewSizes[ViewSize.Md] || - selectedViewSizes[ViewSize.Sm] || - selectedViewSizes[ViewSize.Xs] || + selectedViewSizes[ViewSize.md] || + selectedViewSizes[ViewSize.sm] || + selectedViewSizes[ViewSize.xs] || 12 ); - case ViewSize.Lg: + case ViewSize.lg: return ( - selectedViewSizes[ViewSize.Lg] || - selectedViewSizes[ViewSize.Md] || - selectedViewSizes[ViewSize.Sm] || - selectedViewSizes[ViewSize.Xs] || + selectedViewSizes[ViewSize.lg] || + selectedViewSizes[ViewSize.md] || + selectedViewSizes[ViewSize.sm] || + selectedViewSizes[ViewSize.xs] || 12 ); - case ViewSize.Xl: + case ViewSize.xl: return ( - selectedViewSizes[ViewSize.Xl] || - selectedViewSizes[ViewSize.Lg] || - selectedViewSizes[ViewSize.Md] || - selectedViewSizes[ViewSize.Sm] || - selectedViewSizes[ViewSize.Xs] || + selectedViewSizes[ViewSize.xl] || + selectedViewSizes[ViewSize.lg] || + selectedViewSizes[ViewSize.md] || + selectedViewSizes[ViewSize.sm] || + selectedViewSizes[ViewSize.xs] || 12 ); }