From 5ac15ff13705d3f54b9ddaa929c36d196a9318b7 Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Wed, 6 Nov 2024 19:55:57 +0100 Subject: [PATCH] refactor: cleanup and fix imports --- .../sectionedForm/SectionedFormLayout.module.css | 4 +--- src/lib/form/sectionedForm/SectionedFormContext.tsx | 9 +++++---- src/lib/form/sectionedForm/types.ts | 2 +- src/pages/dataSets/New.tsx | 3 ++- src/pages/dataSets/form/DataSetFormContents.tsx | 2 +- src/pages/dataSets/form/formDescriptor.tsx | 6 +----- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/components/sectionedForm/SectionedFormLayout.module.css b/src/components/sectionedForm/SectionedFormLayout.module.css index 9ad6a047..ca7abf60 100644 --- a/src/components/sectionedForm/SectionedFormLayout.module.css +++ b/src/components/sectionedForm/SectionedFormLayout.module.css @@ -1,6 +1,5 @@ @value m-medium: (min-width: 768px); -/* The purpose of this wrappper is for the */ .layoutWrapper { display: flex; flex-direction: column; @@ -31,7 +30,6 @@ background-color: #fff; min-width: var(--sidebar-width); height: 100%; - border-radius: 0; border-inline-end: 1px solid var(--colors-grey300); } @@ -39,7 +37,7 @@ grid-area: footer; width: 100%; background: var(--colors-white); - border-top: 1px solid var(--colors-grey300); + border-block-start: 1px solid var(--colors-grey300); display: flex; } diff --git a/src/lib/form/sectionedForm/SectionedFormContext.tsx b/src/lib/form/sectionedForm/SectionedFormContext.tsx index e7876438..5f6b0920 100644 --- a/src/lib/form/sectionedForm/SectionedFormContext.tsx +++ b/src/lib/form/sectionedForm/SectionedFormContext.tsx @@ -1,5 +1,5 @@ import React, { createContext, useState } from 'react' -import { SectionDescriptor, SectionedFormDescriptor } from './formDescriptor' +import { SectionDescriptor, SectionedFormDescriptor } from './types' /* Some of the types in this file may look complex. However they are here to help type-safety and autocommpletion for consumers. @@ -50,6 +50,7 @@ function createContextValue( }, } } + type SectionFormContextValue = ReturnType< typeof createContextValue > @@ -62,12 +63,12 @@ export const SectionedFormDescriptorProvider = < T extends SectionedFormDescriptor >({ children, - initialValue, + formDescriptor, }: { - initialValue: T + formDescriptor: T children: React.ReactNode }) => { - const [contextValue] = useState(() => createContextValue(initialValue)) + const [contextValue] = useState(() => createContextValue(formDescriptor)) return ( diff --git a/src/lib/form/sectionedForm/types.ts b/src/lib/form/sectionedForm/types.ts index d57a6264..e331635d 100644 --- a/src/lib/form/sectionedForm/types.ts +++ b/src/lib/form/sectionedForm/types.ts @@ -5,7 +5,7 @@ export type FieldDescriptor = { name: keyof T | (string & {}) } -export type SectionDescriptor = { +export type SectionDescriptor = { label: string name: string // keyof T | (string & {}) allows auto-completion for fields, while also allowing diff --git a/src/pages/dataSets/New.tsx b/src/pages/dataSets/New.tsx index 043c9bce..70084fa5 100644 --- a/src/pages/dataSets/New.tsx +++ b/src/pages/dataSets/New.tsx @@ -15,9 +15,10 @@ import { initialValues, validate } from './form/dataSetFormSchema' import { DataSetFormDescriptor } from './form/formDescriptor' const section = SECTIONS_MAP.dataSet + export const Component = () => { return ( - +