Skip to content

Commit

Permalink
Merge pull request #152 from ClickHouse/pass-properties-to-typography
Browse files Browse the repository at this point in the history
pass properties to typography
  • Loading branch information
serdec authored Sep 27, 2023
2 parents 4f4bb0d + 46ca3ff commit 9d7e9ec
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
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

1 comment on commit 9d7e9ec

@vercel
Copy link

@vercel vercel bot commented on 9d7e9ec Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

click-ui – ./

click-ui-clickhouse.vercel.app
click-ui.vercel.app
click-ui-git-main-clickhouse.vercel.app

Please sign in to comment.