Skip to content

Commit

Permalink
Wrap Typography (#1886)
Browse files Browse the repository at this point in the history
* feat: wrap Typography

* feat: add ARIA props to Typography

* refactor: switch Typography to internal and add color

* fix: update types

* refactor: abstract component list into type

* refactor: encapsulate component

* refactor: update aliases

* fix: modify vestigial Typogrpahy components
  • Loading branch information
jordankoschei-okta authored Jul 21, 2023
1 parent da92331 commit 5f747a9
Show file tree
Hide file tree
Showing 13 changed files with 555 additions and 73 deletions.
2 changes: 1 addition & 1 deletion packages/odyssey-react-mui/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
Checkbox as MuiCheckbox,
CheckboxProps as MuiCheckboxProps,
FormControlLabel,
Typography,
} from "@mui/material";
import { Typography } from "./Typography";
import { memo, useCallback, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";

Expand Down
2 changes: 1 addition & 1 deletion packages/odyssey-react-mui/src/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import { memo, ReactElement, useMemo } from "react";
import {
FormControl as MuiFormControl,
FormLabel as MuiFormLabel,
Typography,
} from "@mui/material";
import { FieldError } from "./FieldError";
import { FieldHint } from "./FieldHint";
import { FieldLabel } from "./FieldLabel";
import { Typography } from "./Typography";
import { useUniqueId } from "./useUniqueId";
import { useTranslation } from "react-i18next";

Expand Down
6 changes: 2 additions & 4 deletions packages/odyssey-react-mui/src/FieldLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { memo, useMemo } from "react";

import { useTranslation } from "react-i18next";
import { ScreenReaderText } from "./ScreenReaderText";
import { Typography } from "@mui/material";
import { Subordinate } from "./Typography";

export type FieldLabelProps = {
hasVisibleLabel: boolean;
Expand All @@ -39,9 +39,7 @@ const FieldLabel = ({
<MuiInputLabel htmlFor={inputId} id={id}>
<span>{text}</span>
{isOptional && (
<Typography variant="subtitle1">
{t("fieldlabel.optional.text")}
</Typography>
<Subordinate>{t("fieldlabel.optional.text")}</Subordinate>
)}
</MuiInputLabel>
),
Expand Down
13 changes: 4 additions & 9 deletions packages/odyssey-react-mui/src/Fieldset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

import { memo, ReactElement } from "react";

import { Box, Typography } from "@mui/material";
import { Box } from "@mui/material";
import { Infobox } from "./Infobox";
import { Legend, Subordinate } from "./Typography";
import { useUniqueId } from "./useUniqueId";

export type FieldsetProps = {
Expand Down Expand Up @@ -71,14 +72,8 @@ const Fieldset = ({
},
}}
>
<Typography variant="legend" component="legend">
{legend}
</Typography>
{description && (
<Typography component="p" variant="subtitle2">
{description}
</Typography>
)}
<Legend>{legend}</Legend>
{description && <Subordinate component="p">{description}</Subordinate>}
{alert}
{children}
</Box>
Expand Down
15 changes: 4 additions & 11 deletions packages/odyssey-react-mui/src/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

import { memo, ReactElement } from "react";

import { Box, Typography } from "@mui/material";
import { Box } from "@mui/material";
import { Button } from "./Button";
import { Infobox } from "./Infobox";
import { Heading4, Support } from "./Typography";
import { useUniqueId } from "./useUniqueId";

export const formEncodingTypeValues = [
Expand Down Expand Up @@ -123,16 +124,8 @@ const Form = ({
marginBlockEnd: (theme) => theme.spacing(4),
}}
>
{title && (
<Typography variant="h4" component="h1">
{title}
</Typography>
)}
{description && (
<Typography component="p" variant="subtitle2">
{description}
</Typography>
)}
{title && <Heading4 component="h1">{title}</Heading4>}
{description && <Support>{description}</Support>}
{alert}
</Box>
<Box component="div">{children}</Box>
Expand Down
Loading

0 comments on commit 5f747a9

Please sign in to comment.