Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add paragraph component #867

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading