Skip to content

Commit

Permalink
Add paragraph component (#867)
Browse files Browse the repository at this point in the history
* add paragraph component

* export paragraph

* text as td

* change tag to p
  • Loading branch information
Cloud11PL authored Oct 4, 2024
1 parent 36499a5 commit ecffb8c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/silent-lamps-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/macaw-ui": patch
---

Macaw-ui now exports new Paragraph component that is Text displayed as block.
18 changes: 18 additions & 0 deletions src/components/Paragraph/Paragraph.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Meta, StoryObj } from "@storybook/react";
import { Paragraph } from "./index";

const meta: Meta<typeof Paragraph> = {
title: "Components / Paragraph",
tags: ["autodocs"],
component: Paragraph,
};

export default meta;
type Story = StoryObj<typeof Paragraph>;

export const Default: Story = {
args: {
size: 4,
children: "Some text displayed as block.",
},
};
10 changes: 10 additions & 0 deletions src/components/Paragraph/Paragraph.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { forwardRef } from "react";
import { TextProps, Text } from "../Text";

export const Paragraph = forwardRef<HTMLSpanElement, TextProps>(
({ ...rest }, ref) => {
return <Text ref={ref} display="block" as="p" {...rest} />;
}
);

Paragraph.displayName = "Paragraph";
1 change: 1 addition & 0 deletions src/components/Paragraph/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Paragraph";
13 changes: 12 additions & 1 deletion src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ import { text, TextVariants } from "./Text.css";

export type TextProps = PropsWithBox<{
children: ReactNode;
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "a" | "strong";
as?:
| "h1"
| "h2"
| "h3"
| "h4"
| "h5"
| "h6"
| "p"
| "span"
| "a"
| "strong"
| "td";
className?: string;
size?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
}> &
Expand Down
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export * from "./Input";
export * from "./List";
export * from "./Modal";
export * from "./Multiselect";
export * from "./Paragraph";
export * from "./Popover";
export * from "./RadioGroup";
export * from "./RangeInput";
Expand Down

0 comments on commit ecffb8c

Please sign in to comment.