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

pass properties to typography #152

Merged
merged 1 commit into from
Sep 27, 2023
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
7 changes: 7 additions & 0 deletions src/components/Typography/Text/Text.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ describe("Text", () => {

expect(rendered.getByText(text).textContent).toEqual(text);
});

test("it should pass properties to the Text component ", () => {
const text = "text to render";
const rendered = renderCUI(<Text data-testid={"test-testid"}>{text}</Text>);

expect(rendered.getAllByTestId("test-testid").length).toEqual(1);
});
});
3 changes: 2 additions & 1 deletion src/components/Typography/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ export interface TextProps {
}

/** Component for writing blocks of body copy */
const _Text = ({ color, size, weight, className, children }: TextProps) => (
const _Text = ({ color, size, weight, className, children, ...props }: TextProps) => (
<CuiText
$color={color}
$size={size}
$weight={weight}
className={className}
{...props}
>
{children}
</CuiText>
Expand Down
14 changes: 14 additions & 0 deletions src/components/Typography/Title/Title.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@ describe("Title", () => {

expect(rendered.getByRole("heading", { level: 1 }).textContent).toEqual(text);
});

test("it should pass properties to the Title component ", () => {
const text = "text to render";
const rendered = renderCUI(
<Title
type="h1"
data-testid={"test-testid"}
>
{text}
</Title>
);

expect(rendered.getAllByTestId("test-testid").length).toEqual(1);
});
});
3 changes: 2 additions & 1 deletion src/components/Typography/Title/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ export interface TitleProps {
}

/** The `title` component allows you to easily add headings to your pages. They do not include built in margins. */
export const Title = ({ size, family, type, color, children }: TitleProps) => (
export const Title = ({ size, family, type, color, children, ...props }: TitleProps) => (
<CuiTitle
$color={color}
$size={size}
$family={family}
as={type}
{...props}
>
{children}
</CuiTitle>
Expand Down