-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c883fda
commit 7372ae1
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Heading } from "rebass/styled-components"; | ||
|
||
function Header({ children, ...props }) { | ||
return ( | ||
<Heading color="text" fontFamily="heading" {...props}> | ||
{children} | ||
</Heading> | ||
); | ||
} | ||
|
||
const withPrimary = (Component) => (props) => ( | ||
<Component as="h1" fontSize={[4,5,6]} {...props}/> | ||
) | ||
|
||
const withSecondary = (Component) => (props) => ( | ||
<Component as="h1" fontSize={[3,4,5]} {...props}/> | ||
) | ||
|
||
const PrimaryHeader = withPrimary(Header); | ||
const SecondaryHeader = withSecondary(Header); | ||
|
||
export { PrimaryHeader, SecondaryHeader }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { PrimaryHeader, SecondaryHeader } from "components/heading"; | ||
|
||
export default { | ||
title: 'Components/Heading', | ||
}; | ||
|
||
export const PrimaryHeadingStory = (props) => <PrimaryHeader {...props} /> | ||
PrimaryHeadingStory.args = { | ||
children: "Lorem ipsum de lorum col a suld icus a puentus aleetum", | ||
}; | ||
|
||
export const SecondaryHeadingStory = (props) => <SecondaryHeader {...props} /> | ||
SecondaryHeadingStory.args = { | ||
children: "Lorem ipsum de lorum col a suld icus a puentus aleetum", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { PrimaryHeader, SecondaryHeader } from "./index"; | ||
import { render } from "@testing-library/react"; | ||
|
||
describe("Headings", () => { | ||
test("primary header renders contents", () => { | ||
const { queryByText } = render(<PrimaryHeader>Hello world</PrimaryHeader>); | ||
expect(queryByText("Hello world")).toBeInTheDocument(); | ||
}) | ||
|
||
test("secondary header renders contents", () => { | ||
const { queryByText } = render(<SecondaryHeader>Hello world</SecondaryHeader>); | ||
expect(queryByText("Hello world")).toBeInTheDocument(); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { PrimaryHeader, SecondaryHeader } from "./Heading"; | ||
export default PrimaryHeader; | ||
export { PrimaryHeader, SecondaryHeader }; |