From 8e1e3bea17e31a707ede18cfaf8399c84c668caf Mon Sep 17 00:00:00 2001 From: Sonny Date: Sun, 2 Jun 2024 01:22:53 +0200 Subject: [PATCH] feat: create tab and selector components --- inertia/components/common/form/selector.tsx | 79 ++++++++++++ .../components/common/modal/_modal_body.tsx | 1 - .../common/modal/_modal_container.tsx | 2 +- inertia/components/common/tabs/tab_item.tsx | 24 ++++ inertia/components/common/tabs/tab_list.tsx | 10 ++ inertia/components/common/tabs/tab_panel.tsx | 12 ++ inertia/components/common/tabs/tabs.tsx | 42 +++++++ inertia/components/form/form_link.tsx | 24 ++-- inertia/components/lang_selector.tsx | 61 +++++++--- inertia/components/layouts/_theme_layout.tsx | 3 +- package-lock.json | 114 ++++++++++++++++-- package.json | 4 +- public/icons/en.svg | 1 + public/icons/fr.svg | 1 + 14 files changed, 335 insertions(+), 43 deletions(-) create mode 100644 inertia/components/common/form/selector.tsx create mode 100644 inertia/components/common/tabs/tab_item.tsx create mode 100644 inertia/components/common/tabs/tab_list.tsx create mode 100644 inertia/components/common/tabs/tab_panel.tsx create mode 100644 inertia/components/common/tabs/tabs.tsx create mode 100644 public/icons/en.svg create mode 100644 public/icons/fr.svg diff --git a/inertia/components/common/form/selector.tsx b/inertia/components/common/form/selector.tsx new file mode 100644 index 0000000..49c9f80 --- /dev/null +++ b/inertia/components/common/form/selector.tsx @@ -0,0 +1,79 @@ +import { useTheme } from '@emotion/react'; +import { InputHTMLAttributes, ReactNode, useEffect, useState } from 'react'; +import Select, { + FormatOptionLabelMeta, + GroupBase, + OptionsOrGroups, +} from 'react-select'; +import FormField from '~/components/common/form/_form_field'; + +type Option = { label: string | number; value: string | number }; + +interface SelectorProps + extends Omit, 'onChange'> { + label: string; + name: string; + errors?: string[]; + options: OptionsOrGroups>; + value: number | string; + onChangeCallback?: (value: number | string) => void; + formatOptionLabel?: ( + data: Option, + formatOptionLabelMeta: FormatOptionLabelMeta