From 951564f1000128aa10e6cb8b7e585cc240339cf2 Mon Sep 17 00:00:00 2001 From: Jordan Koschei <91091570+jordankoschei-okta@users.noreply.github.com> Date: Fri, 7 Jul 2023 09:43:59 -0400 Subject: [PATCH] docs: update docs for Supernova (#1821) * docs: update docs for Supernova * fix: change type of endIcon in controls * refactor: make Button default to primary * feat: switch args back to alphabetical * refactor: move icons into separate file * fix: fix merge conflicts * fix: fix type errors * refactor: apply recommended changes * feat: add docs for CircularProgress * feat: add Link docs * feat: add Icon docs * feat: add Dialog docs * feat: modify ScreenReaderText docs * feat: update Status documentation * feat: add Tooltip docs * feat: add Tag documentation * feat: add Tabs docs * feat: added MenuButton docs * feat: updated Typography docs * refactor: simplify DatePicker docs * feat: update Banner docs * feat: update docs for Infobox * feat: update Toast docs * feat: update Autocomplete docs * feat: update docs for TextField * feat: update Checkbox and CheckboxGroup docs * feat: update Radio and RadioGroup docs * feat: update Form and Fieldset docs * feat: update Select and NativeSelect docs * refactor: abstracted out type enums * fix: fix type errors in Toast stories * fix: remove click on disabled checkbox * refactor: commit KG suggestions * fix: add missing variant to Button * refactor: fix import relativity --- packages/odyssey-react-mui/src/Banner.tsx | 23 ++- packages/odyssey-react-mui/src/Button.tsx | 12 +- packages/odyssey-react-mui/src/Field.tsx | 4 +- packages/odyssey-react-mui/src/Form.tsx | 25 ++- packages/odyssey-react-mui/src/Icon.tsx | 4 +- packages/odyssey-react-mui/src/Infobox.tsx | 13 +- packages/odyssey-react-mui/src/Link.tsx | 6 +- packages/odyssey-react-mui/src/MenuButton.tsx | 6 +- .../src/OdysseyCacheProvider.test.tsx | 2 +- packages/odyssey-react-mui/src/Status.tsx | 12 +- packages/odyssey-react-mui/src/TextField.tsx | 10 +- packages/odyssey-react-mui/src/Toast.tsx | 13 +- .../.storybook/components/iconUtils.tsx | 170 +++++++++++++++ .../odyssey-storybook/.storybook/preview.ts | 6 + .../odyssey-labs/DatePicker/DatePicker.mdx | 20 -- .../DatePicker/DatePicker.stories.tsx | 1 + .../odyssey-mui/Autocomplete/Autocomplete.mdx | 81 -------- .../Autocomplete/Autocomplete.stories.tsx | 110 +++++++++- .../components/odyssey-mui/Banner/Banner.mdx | 166 --------------- .../odyssey-mui/Banner/Banner.stories.tsx | 70 +++++-- .../components/odyssey-mui/Button/Button.mdx | 123 ----------- .../odyssey-mui/Button/Button.stories.tsx | 133 +++++++++++- .../odyssey-mui/Checkbox/Checkbox.mdx | 21 -- .../odyssey-mui/Checkbox/Checkbox.stories.tsx | 162 ++++++++++++++- .../CheckboxGroup/CheckboxGroup.mdx | 88 -------- .../CheckboxGroup/CheckboxGroup.stories.tsx | 125 ++++++------ .../CircularProgress/CircularProgress.mdx | 19 -- .../CircularProgress.stories.tsx | 17 ++ .../DataTable/PaginatedTable.stories.tsx | 1 + .../DataTable/StaticTable.stories.tsx | 1 + .../components/odyssey-mui/Dialog/Dialog.mdx | 87 -------- .../odyssey-mui/Dialog/Dialog.stories.tsx | 65 +++++- .../odyssey-mui/Fieldset/Fieldset.mdx | 37 ---- .../odyssey-mui/Fieldset/Fieldset.stories.tsx | 53 ++++- .../src/components/odyssey-mui/Form/Form.mdx | 87 -------- .../odyssey-mui/Form/Form.stories.tsx | 117 +++++++++-- .../odyssey-mui/Icon/Icon.stories.tsx | 33 ++- .../odyssey-mui/Infobox/Infobox.mdx | 190 ----------------- .../odyssey-mui/Infobox/Infobox.stories.tsx | 40 +++- .../src/components/odyssey-mui/Link/Link.mdx | 52 ++--- .../odyssey-mui/Link/Link.stories.tsx | 55 ++++- .../odyssey-mui/MenuButton/MenuButton.mdx | 108 ---------- .../MenuButton/MenuButton.stories.tsx | 57 +++++- .../odyssey-mui/NativeSelect/NativeSelect.mdx | 63 ------ .../NativeSelect/NativeSelect.stories.tsx | 118 ++++++++++- .../components/odyssey-mui/Radio/Radio.mdx | 13 -- .../odyssey-mui/Radio/Radio.stories.tsx | 40 ++++ .../odyssey-mui/RadioGroup/RadioGroup.mdx | 88 -------- .../RadioGroup/RadioGroup.stories.tsx | 70 ++++++- .../ScreenReaderText/ScreenReaderText.mdx | 8 - .../components/odyssey-mui/Select/Select.mdx | 72 ------- .../odyssey-mui/Select/Select.stories.tsx | 130 +++++++++++- .../components/odyssey-mui/Status/Status.mdx | 79 ------- .../odyssey-mui/Status/Status.stories.tsx | 28 ++- .../src/components/odyssey-mui/Tabs/Tabs.mdx | 57 ++---- .../odyssey-mui/Tabs/Tabs.stories.tsx | 56 ++++- .../src/components/odyssey-mui/Tag/Tag.mdx | 57 ------ .../odyssey-mui/Tag/Tag.stories.tsx | 48 ++++- .../odyssey-mui/TextField/TextField.mdx | 117 ----------- .../TextField/TextField.stories.tsx | 193 ++++++++++++++++-- .../components/odyssey-mui/Toast/Toast.mdx | 190 ----------------- .../odyssey-mui/Toast/Toast.stories.tsx | 99 ++++++++- .../odyssey-mui/Tooltip/Tooltip.mdx | 109 ---------- .../odyssey-mui/Tooltip/Tooltip.stories.tsx | 55 ++--- .../odyssey-mui/Typography/Typography.mdx | 61 ------ .../Typography/Typography.stories.tsx | 1 + 66 files changed, 1965 insertions(+), 2212 deletions(-) create mode 100644 packages/odyssey-storybook/.storybook/components/iconUtils.tsx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-labs/DatePicker/DatePicker.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Autocomplete/Autocomplete.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Banner/Banner.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Button/Button.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Checkbox/Checkbox.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/CheckboxGroup/CheckboxGroup.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/CircularProgress/CircularProgress.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Dialog/Dialog.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Fieldset/Fieldset.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Form/Form.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Infobox/Infobox.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/MenuButton/MenuButton.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/NativeSelect/NativeSelect.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Radio/Radio.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/RadioGroup/RadioGroup.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Select/Select.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Status/Status.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Tag/Tag.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/TextField/TextField.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Toast/Toast.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Tooltip/Tooltip.mdx delete mode 100644 packages/odyssey-storybook/src/components/odyssey-mui/Typography/Typography.mdx diff --git a/packages/odyssey-react-mui/src/Banner.tsx b/packages/odyssey-react-mui/src/Banner.tsx index 590d24d045..e8dbe71732 100644 --- a/packages/odyssey-react-mui/src/Banner.tsx +++ b/packages/odyssey-react-mui/src/Banner.tsx @@ -10,17 +10,20 @@ * See the License for the specific language governing permissions and limitations under the License. */ -import { - Alert, - AlertColor, - AlertTitle, - AlertProps, - Link, - ScreenReaderText, -} from "./"; +import { Alert, AlertColor, AlertTitle, AlertProps } from "@mui/material"; +import { Link } from "./Link"; +import { ScreenReaderText } from "./ScreenReaderText"; import { memo } from "react"; import { useTranslation } from "react-i18next"; +export const bannerRoleValues = ["status", "alert"] as const; +export const bannerSeverityValues: AlertColor[] = [ + "success", + "info", + "warning", + "error", +]; + export type BannerProps = { /** * If linkUrl is not undefined, this is the text of the link. @@ -42,11 +45,11 @@ export type BannerProps = { * ("status" for something that dynamically updates, "alert" for errors, null for something * unchanging) */ - role?: "status" | "alert"; + role?: (typeof bannerRoleValues)[number]; /** * Determine the color and icon of the alert */ - severity: AlertColor; + severity: (typeof bannerSeverityValues)[number]; /** * The text content of the alert */ diff --git a/packages/odyssey-react-mui/src/Button.tsx b/packages/odyssey-react-mui/src/Button.tsx index 3a259d16f7..ddceff5356 100644 --- a/packages/odyssey-react-mui/src/Button.tsx +++ b/packages/odyssey-react-mui/src/Button.tsx @@ -18,20 +18,28 @@ import { Icon } from "./Icon"; import { MuiPropsContext } from "./MuiPropsContext"; import { Tooltip } from "./Tooltip"; +export const buttonSizeValues = ["small", "medium", "large"] as const; +export const buttonVariantValues = [ + "primary", + "secondary", + "danger", + "floating", +] as const; + export type ButtonProps = { endIcon?: ReactElement; id?: string; isDisabled?: boolean; isFullWidth?: boolean; onClick?: MuiButtonProps["onClick"]; - size?: MuiButtonProps["size"]; + size?: (typeof buttonSizeValues)[number]; startIcon?: ReactElement; text?: string; /** * `tooltipText` determines the text of the tooltip that wraps the button if it's icon-only. */ tooltipText?: string; - variant?: "primary" | "secondary" | "danger" | "floating"; + variant: (typeof buttonVariantValues)[number]; ariaLabel?: string; ariaLabelledBy?: string; ariaDescribedBy?: string; diff --git a/packages/odyssey-react-mui/src/Field.tsx b/packages/odyssey-react-mui/src/Field.tsx index 6a660abf38..8816939413 100644 --- a/packages/odyssey-react-mui/src/Field.tsx +++ b/packages/odyssey-react-mui/src/Field.tsx @@ -23,6 +23,8 @@ import { FieldLabel } from "./FieldLabel"; import { useUniqueId } from "./useUniqueId"; import { useTranslation } from "react-i18next"; +export const fieldTypeValues = ["single", "group"] as const; + export type FieldProps = { /** * If `error` is not undefined, the `input` will indicate an error. @@ -31,7 +33,7 @@ export type FieldProps = { /** * The field type determines how ARIA components are setup. It's important to use this to denote if you expect only one component (like a text field) or multiple (like a radio group). */ - fieldType: "single" | "group"; + fieldType: (typeof fieldTypeValues)[number]; hasVisibleLabel: boolean; /** * The helper text content. diff --git a/packages/odyssey-react-mui/src/Form.tsx b/packages/odyssey-react-mui/src/Form.tsx index 65e9a3cc84..d28e11cceb 100644 --- a/packages/odyssey-react-mui/src/Form.tsx +++ b/packages/odyssey-react-mui/src/Form.tsx @@ -17,6 +17,15 @@ import { Button } from "./Button"; import { Infobox } from "./Infobox"; import { useUniqueId } from "./useUniqueId"; +export const formEncodingTypeValues = [ + "application/x-www-form-urlencoded", + "application/json", + "multipart/form-data", + "text/plain", +] as const; +export const formAutoCompleteTypeValues = ["on", "off"] as const; +export const formMethodValues = ["post", "get", "dialog"] as const; + export type FormProps = { /** * The title of the Form @@ -38,7 +47,7 @@ export type FormProps = { * Indicates whether input elements can by default have their values automatically completed by the browser. * `autocomplete` attributes on form elements override it on
*/ - hasAutoComplete?: "on" | "off" | undefined; + autoCompleteType?: (typeof formAutoCompleteTypeValues)[number]; /** * The name of the form. The value must not be the empty string, and must be unique among the form elements in the forms collection that it is in, if any. */ @@ -53,21 +62,17 @@ export type FormProps = { * If the value of the method attribute is post, enctype is the MIME type of the form submission. * This value can be overridden by formenctype attributes on