From b85a95b282af090454aeee8cea4620b930d5b8fe Mon Sep 17 00:00:00 2001 From: Lukas Weiss Date: Mon, 1 Aug 2022 15:41:50 +0200 Subject: [PATCH] Adapt section components to new design * adapt sections to new design * adapt section filters and search to new design * remove the section filter dialog component and add it as an example * move the section filter component into the section/header * add row and group components for section header * add section-header-spacer component * make id only required for form fields if label is set * remove section-action component, use button components instead --- .eslintignore | 2 - .gitignore | 2 - package.json | 2 - src/components/action/theme.ts | 2 +- src/components/button/index.ts | 2 + .../dialog/DialogSectionContainer.tsx | 20 + src/components/dialog/index.ts | 1 + .../dialog/select/SelectDialog.stories.mdx | 19 +- src/components/dialog/theme.ts | 3 + src/components/form/Input.tsx | 29 +- src/components/form/Select.tsx | 37 +- src/components/form/SelectMonth.tsx | 18 +- src/components/form/SelectYear.tsx | 12 +- src/components/form/TextArea.tsx | 29 +- .../form/async/SelectItem.stories.mdx | 5 +- .../form/async/SelectItemDialogWithSearch.tsx | 87 +-- src/components/form/index.ts | 1 + src/components/form/theme.ts | 5 +- src/components/loading/LoadingDetails.tsx | 17 +- src/components/loading/LoadingEdit.tsx | 17 +- src/components/loading/LoadingList.tsx | 17 +- src/components/pagination/theme.ts | 2 +- .../Section/SectionContainer.stories.mdx | 34 ++ .../section/Section/SectionContainer.tsx | 15 + .../Section/SectionContentTwoColumn.tsx | 7 +- .../Section/SubsectionTitle.stories.mdx | 26 + .../section/Section/SubsectionTitle.tsx | 16 + .../SectionFooter/SectionFooter.stories.mdx | 4 +- .../SectionHeader/SectionAction.stories.mdx | 31 - .../section/SectionHeader/SectionAction.tsx | 44 -- .../SectionHeader/SectionFilter.stories.mdx | 125 ++++ .../section/SectionHeader/SectionFilter.tsx | 28 + .../SectionHeader/SectionHeader.stories.mdx | 6 +- .../SectionHeaderGroup.stories.mdx | 51 ++ .../SectionHeader/SectionHeaderGroup.tsx | 32 + .../SectionHeaderRow.stories.mdx | 52 ++ .../SectionHeader/SectionHeaderRow.tsx | 35 ++ .../SectionHeaderSpacer.stories.mdx | 47 ++ .../SectionHeader/SectionHeaderSpacer.tsx | 24 + .../SectionHeader/SectionSearch.stories.mdx | 32 +- .../section/SectionHeader/SectionSearch.tsx | 85 +-- .../SectionDescriptionItem.stories.mdx | 18 +- .../section/SectionItem/SectionItem.tsx | 14 +- .../SectionItem/SectionListItem.stories.mdx | 22 +- .../SectionListItemButton.stories.mdx | 23 +- .../SectionListItemLink.stories.mdx | 24 +- .../SectionListItemWithAction.stories.mdx | 52 +- src/components/section/index.ts | 7 +- src/components/section/theme.ts | 74 ++- src/components/sectionFilter/FilterDialog.tsx | 43 -- .../sectionFilter/SectionFilter.stories.mdx | 133 ----- .../sectionFilter/SectionFilter.tsx | 103 ---- .../sectionFilter/SectionFilterAction.tsx | 32 - src/components/sectionFilter/index.ts | 2 - src/examples/details.stories.mdx | 78 ++- src/examples/form.stories.mdx | 121 ++-- src/examples/list.stories.mdx | 557 +++++++++++++++--- src/sectionFilter.ts | 1 - src/translations/shared.en.json | 2 - tailwind.config.js | 1 + 60 files changed, 1489 insertions(+), 841 deletions(-) create mode 100644 src/components/dialog/DialogSectionContainer.tsx create mode 100644 src/components/section/Section/SectionContainer.stories.mdx create mode 100644 src/components/section/Section/SectionContainer.tsx create mode 100644 src/components/section/Section/SubsectionTitle.stories.mdx create mode 100644 src/components/section/Section/SubsectionTitle.tsx delete mode 100644 src/components/section/SectionHeader/SectionAction.stories.mdx delete mode 100644 src/components/section/SectionHeader/SectionAction.tsx create mode 100644 src/components/section/SectionHeader/SectionFilter.stories.mdx create mode 100644 src/components/section/SectionHeader/SectionFilter.tsx create mode 100644 src/components/section/SectionHeader/SectionHeaderGroup.stories.mdx create mode 100644 src/components/section/SectionHeader/SectionHeaderGroup.tsx create mode 100644 src/components/section/SectionHeader/SectionHeaderRow.stories.mdx create mode 100644 src/components/section/SectionHeader/SectionHeaderRow.tsx create mode 100644 src/components/section/SectionHeader/SectionHeaderSpacer.stories.mdx create mode 100644 src/components/section/SectionHeader/SectionHeaderSpacer.tsx delete mode 100644 src/components/sectionFilter/FilterDialog.tsx delete mode 100644 src/components/sectionFilter/SectionFilter.stories.mdx delete mode 100644 src/components/sectionFilter/SectionFilter.tsx delete mode 100644 src/components/sectionFilter/SectionFilterAction.tsx delete mode 100644 src/components/sectionFilter/index.ts delete mode 100644 src/sectionFilter.ts diff --git a/.eslintignore b/.eslintignore index 217980f5..ae69b43b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -35,8 +35,6 @@ pagination.js pagination.d.ts section.js section.d.ts -sectionFilter.js -sectionFilter.d.ts selectDialog.js selectDialog.d.ts submitButton.js diff --git a/.gitignore b/.gitignore index 509e6b7c..e3e7997f 100644 --- a/.gitignore +++ b/.gitignore @@ -66,8 +66,6 @@ pagination.js pagination.d.ts section.js section.d.ts -sectionFilter.js -sectionFilter.d.ts selectDialog.js selectDialog.d.ts submitButton.js diff --git a/package.json b/package.json index 6d416eb2..de920b2b 100644 --- a/package.json +++ b/package.json @@ -123,8 +123,6 @@ "pagination.d.ts", "section.js", "section.d.ts", - "sectionFilter.js", - "sectionFilter.d.ts", "selectDialog.js", "selectDialog.d.ts", "submitButton.js", diff --git a/src/components/action/theme.ts b/src/components/action/theme.ts index ad36d9ef..9061402d 100644 --- a/src/components/action/theme.ts +++ b/src/components/action/theme.ts @@ -1,6 +1,6 @@ export default { action: { - base: 'flex flex-col lg:flex-row space-y-4 lg:space-y-0 lg:space-x-4 mx-4 lg:mx-0', + base: 'flex flex-col lg:flex-row gap-4', variant: { start: 'lg:justify-start', center: 'lg:justify-center', diff --git a/src/components/button/index.ts b/src/components/button/index.ts index 46fa7621..908fcd87 100644 --- a/src/components/button/index.ts +++ b/src/components/button/index.ts @@ -1,4 +1,6 @@ +export * from './types' export * from './Button' export * from './ButtonLink' export * from './ButtonIcon' export * from './ButtonIconLink' +export * from './SubmitButton' diff --git a/src/components/dialog/DialogSectionContainer.tsx b/src/components/dialog/DialogSectionContainer.tsx new file mode 100644 index 00000000..326e8ffe --- /dev/null +++ b/src/components/dialog/DialogSectionContainer.tsx @@ -0,0 +1,20 @@ +import classNames from 'classnames' +import { ReactElement } from 'react' +import { useTheme } from '../../framework' +import { ClassNameProps } from '../types' + +type Props = { + children?: ReactElement +} & ClassNameProps + +export function DialogSectionContainer({ + className, + children, +}: Props): ReactElement { + const { dialog } = useTheme() + return ( +
+ {children} +
+ ) +} diff --git a/src/components/dialog/index.ts b/src/components/dialog/index.ts index 431abe3c..0f7b47be 100644 --- a/src/components/dialog/index.ts +++ b/src/components/dialog/index.ts @@ -1,2 +1,3 @@ export * from './confirmation/ConfirmationDialog' export * from './DialogHeader' +export * from './DialogSectionContainer' diff --git a/src/components/dialog/select/SelectDialog.stories.mdx b/src/components/dialog/select/SelectDialog.stories.mdx index f346e8be..c8e038e5 100644 --- a/src/components/dialog/select/SelectDialog.stories.mdx +++ b/src/components/dialog/select/SelectDialog.stories.mdx @@ -4,6 +4,7 @@ import { Button } from '../../button/Button' import { Tone } from '../../types' import { NavigationProvider } from '../../navigation/NavigationContext' import { SectionContentList, SectionListItem } from '../../section' +import { DialogSectionContainer } from '../DialogSectionContainer' import { SelectDialog } from './SelectDialog' @@ -38,13 +39,17 @@ export const Template = ({ onDismiss={() => setToggle(!toggle)} dialogLabel={dialogLabel} > - - {userList - .filter((user) => user.toLowerCase().includes(text.toLowerCase())) - .map((user, index) => ( - {user} - ))} - + + + {userList + .filter((user) => + user.toLowerCase().includes(text.toLowerCase()) + ) + .map((user, index) => ( + {user} + ))} + + ) : (