From 34bbbdff41f6df74199022946e112a5580df206b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tha=C3=AFs?= Date: Sat, 21 Oct 2023 13:28:15 +0200 Subject: [PATCH] feat: add New Field Step 2 form (#2138) Closes #2001 Co-authored-by: Charles Bochet --- .../SettingsObjectFieldFormSection.tsx | 64 +++++++++++++ .../SettingsObjectFieldTypeSelectSection.tsx | 32 +++++++ .../components/SettingsObjectFormSection.tsx | 10 +- ...SettingsObjectFieldFormSection.stories.tsx | 24 +++++ ...gsObjectFieldTypeSelectSection.stories.tsx | 28 ++++++ .../data-model/constants/dataTypes.ts | 25 +++++ .../SettingsObjectFieldDataType.tsx | 23 +---- .../data-model/types/ObjectFieldDataType.ts | 1 + front/src/modules/ui/display/icon/index.ts | 1 + .../ui/input/button/components/IconButton.tsx | 1 + .../ui/input/components/IconPicker.tsx | 8 +- .../modules/ui/input/components/Select.tsx | 94 +++++++++++++++++++ .../components/__stories__/Select.stories.tsx | 51 ++++++++++ .../ui/input/types/SelectHotkeyScope.ts | 3 + .../SettingsObjectNewFieldStep2.tsx | 36 ++++++- 15 files changed, 367 insertions(+), 34 deletions(-) create mode 100644 front/src/modules/settings/data-model/components/SettingsObjectFieldFormSection.tsx create mode 100644 front/src/modules/settings/data-model/components/SettingsObjectFieldTypeSelectSection.tsx create mode 100644 front/src/modules/settings/data-model/components/__stories__/SettingsObjectFieldFormSection.stories.tsx create mode 100644 front/src/modules/settings/data-model/components/__stories__/SettingsObjectFieldTypeSelectSection.stories.tsx create mode 100644 front/src/modules/settings/data-model/constants/dataTypes.ts create mode 100644 front/src/modules/ui/input/components/Select.tsx create mode 100644 front/src/modules/ui/input/components/__stories__/Select.stories.tsx create mode 100644 front/src/modules/ui/input/types/SelectHotkeyScope.ts diff --git a/front/src/modules/settings/data-model/components/SettingsObjectFieldFormSection.tsx b/front/src/modules/settings/data-model/components/SettingsObjectFieldFormSection.tsx new file mode 100644 index 000000000..e01117548 --- /dev/null +++ b/front/src/modules/settings/data-model/components/SettingsObjectFieldFormSection.tsx @@ -0,0 +1,64 @@ +import styled from '@emotion/styled'; + +import { H2Title } from '@/ui/display/typography/components/H2Title'; +import { IconPicker } from '@/ui/input/components/IconPicker'; +import { TextArea } from '@/ui/input/components/TextArea'; +import { TextInput } from '@/ui/input/components/TextInput'; +import { Section } from '@/ui/layout/section/components/Section'; + +type SettingsObjectFieldFormSectionProps = { + disabled?: boolean; + name?: string; + description?: string; + iconKey?: string; + onChange?: ( + formValues: Partial<{ + iconKey: string; + name: string; + description: string; + }>, + ) => void; +}; + +const StyledInputsContainer = styled.div` + display: flex; + gap: ${({ theme }) => theme.spacing(2)}; + margin-bottom: ${({ theme }) => theme.spacing(2)}; + width: 100%; +`; + +export const SettingsObjectFieldFormSection = ({ + disabled, + name = '', + description = '', + iconKey = 'IconUsers', + onChange, +}: SettingsObjectFieldFormSectionProps) => ( +
+ + + onChange?.({ iconKey: value.iconKey })} + variant="primary" + /> + onChange?.({ name: value })} + disabled={disabled} + fullWidth + /> + +