From a73d0935330304c58284a8f44c3c31745d012ffa Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Sat, 8 Jul 2023 11:53:41 +0800 Subject: [PATCH] Make components consistent Manage props directly and fix some linting errors across all categories. --- base/src/text-control.ts | 2 + categories/action/react/.eslintrc | 5 + .../src/components/ActionButton/index.tsx | 46 +- categories/choice/react/.eslintrc | 4 + .../react/src/components/ComboBox/index.tsx | 311 ++++++------ .../src/components/DropdownSelect/index.tsx | 26 +- .../react/src/components/MenuSelect/index.tsx | 26 +- .../src/components/RadioButton/index.tsx | 46 +- .../src/components/RadioTickBox/index.tsx | 30 +- categories/color/react/.eslintrc | 3 + .../react/src/components/Swatch/index.tsx | 41 +- categories/formatted/react/.eslintrc | 4 + .../react/src/components/EmailInput/index.tsx | 30 +- .../src/components/PhoneNumberInput/index.tsx | 279 ++++++----- .../react/src/components/UrlInput/index.tsx | 276 ++++++----- categories/freeform/react/.eslintrc | 4 + .../src/components/MaskedTextInput/index.tsx | 277 ++++++----- .../components/MultilineTextInput/index.tsx | 305 ++++++------ .../react/src/components/TextInput/index.tsx | 293 ++++++----- categories/information/react/.eslintrc | 3 + .../react/src/components/Badge/index.tsx | 25 +- .../src/components/KeyValueTable/index.tsx | 18 +- categories/multichoice/react/.eslintrc | 4 + .../src/components/MenuMultiSelect/index.tsx | 311 ++++++------ .../react/src/components/TagInput/index.tsx | 457 ++++++++++-------- .../src/components/ToggleButton/index.tsx | 51 +- .../src/components/ToggleSwitch/index.tsx | 37 +- .../src/components/ToggleTickBox/index.tsx | 33 +- categories/navigation/react/.eslintrc | 3 + .../react/src/components/LinkButton/index.tsx | 50 +- categories/number/react/.eslintrc | 4 + .../react/src/components/Slider/index.tsx | 167 ++++--- .../react/src/components/Spinner/index.tsx | 274 ++++++----- 33 files changed, 1937 insertions(+), 1508 deletions(-) diff --git a/base/src/text-control.ts b/base/src/text-control.ts index 668d8da..d43ea88 100644 --- a/base/src/text-control.ts +++ b/base/src/text-control.ts @@ -3,3 +3,5 @@ export type Size = 'small' | 'medium' | 'large'; export type Variant = 'default' | 'alternate'; export type InputType = 'text' | 'search'; + +export type InputMode = 'none' | 'numeric' | 'decimal' | InputType; diff --git a/categories/action/react/.eslintrc b/categories/action/react/.eslintrc index 7d22244..8a6172f 100644 --- a/categories/action/react/.eslintrc +++ b/categories/action/react/.eslintrc @@ -1,5 +1,10 @@ { "root": true, + "rules": { + "quote-props": "off", + "react/jsx-props-no-spreading": "off", + "react/button-has-type": "off" + }, "extends": [ "lxsmnsyc/typescript/react" ], diff --git a/categories/action/react/src/components/ActionButton/index.tsx b/categories/action/react/src/components/ActionButton/index.tsx index 113fb8e..b72c44d 100644 --- a/categories/action/react/src/components/ActionButton/index.tsx +++ b/categories/action/react/src/components/ActionButton/index.tsx @@ -6,7 +6,7 @@ export type ActionButtonDerivedElement = HTMLButtonElement; export interface ActionButtonProps extends Omit, 'type' | 'size'> { type?: Button.Type; - variant: Button.Variant; + variant?: Button.Variant; block?: boolean; subtext?: React.ReactNode; badge?: React.ReactNode; @@ -15,19 +15,22 @@ export interface ActionButtonProps extends Omit(({ - type = 'button' as const, - variant, - subtext, - badge, - menuItem = false, - children, - size = 'medium' as const, - compact = false, - className, - block = false, - ...etcProps -}, forwardedRef) => ( +export const ActionButton = React.forwardRef(( + { + type = 'button' as const, + variant = 'bare' as const, + subtext, + badge, + menuItem = false, + children, + size = 'medium' as const, + compact = false, + className, + block = false, + ...etcProps + }, + forwardedRef, +) => (