Skip to content

Commit

Permalink
Merge pull request #128 from vector-im/florianduros/fix-heading-size
Browse files Browse the repository at this point in the history
Fix `Typography` > `Heading` and `Text` size
  • Loading branch information
florianduros authored Nov 8, 2023
2 parents 5a703b4 + 8c56e90 commit 8f38c6b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/Typography/Heading.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
component: HeadingComponent,
argTypes: {
size: {
options: ["xs", "sm", "md", "lg"],
options: ["sm", "md", "lg", "xl"],
control: { type: "inline-radio" },
},
weight: {
Expand Down
7 changes: 6 additions & 1 deletion src/components/Typography/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ import React from "react";
import { Typography } from "./Typography";
import { Text } from "./Text";

type TypographyProps = React.ComponentProps<typeof Typography>;

/**
* A heading component.
*/
export const Heading: React.FC<
Omit<React.ComponentProps<typeof Typography>, "type">
Omit<TypographyProps, "type"> & {
// xs is not a valid heading size
size?: Exclude<TypographyProps["size"], "xs">;
}
> = ({ as = "h1", children, ...props }) => {
return (
<Typography as={as} type="heading" {...props}>
Expand Down
7 changes: 6 additions & 1 deletion src/components/Typography/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ limitations under the License.
import React from "react";
import { Typography } from "./Typography";

type TypographyProps = React.ComponentProps<typeof Typography>;

/**
* A text component. Underlying HTML element can be changed using the `as`
* property. Will default to be a paragraph.
*/
export const Text: React.FC<
Omit<React.ComponentProps<typeof Typography>, "type">
Omit<TypographyProps, "type"> & {
// xl is not a valid text size
size?: Exclude<TypographyProps["size"], "xl">;
}
> = ({ as = "p", children, ...props }) => {
return (
<Typography as={as} type="body" {...props}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Typography/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type TypographyProps<C extends React.ElementType> = {
/**
* The t-shirt size of the content.
*/
size?: "xs" | "sm" | "md" | "lg";
size?: "xs" | "sm" | "md" | "lg" | "xl";
/**
* The CSS class name.
*/
Expand Down

0 comments on commit 8f38c6b

Please sign in to comment.