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

feat: implement ProcessListHeading subcomponent #1162

Merged
merged 37 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0b3c20b
Create subfolders and files, write and pass one test each for Process…
SirenaBorracha Apr 7, 2021
5d493e3
Import ProcessListItem to the stories file and render some text in a …
SirenaBorracha Apr 7, 2021
b360aa1
Add minimum Storybook examples as skeletons, create props interfaces,…
SirenaBorracha Apr 8, 2021
c97724c
Disable anchor is valid check in test files, add test checking for ab…
SirenaBorracha Apr 9, 2021
89f8b4c
Export ProcessList components from index.ts
SirenaBorracha Apr 10, 2021
2beaa1b
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 10, 2021
ccf9db3
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 12, 2021
4d7a45b
Remove unnecessary fragment
SirenaBorracha Apr 12, 2021
a2039b5
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 13, 2021
e1a16c2
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 15, 2021
47e5ff3
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 19, 2021
4799969
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 19, 2021
7a0dc41
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 20, 2021
3aac2a1
Merge branch 'ak-new-component-process-list-979' of github.com:trussw…
SirenaBorracha Apr 20, 2021
becfa75
Add ProcessListHeading to ProcessList test data, use ProcessListHeadi…
SirenaBorracha Apr 20, 2021
315c8f3
Use ProcessListHeading custom component in storybook
SirenaBorracha Apr 20, 2021
47239a6
Remove unnecessary childwithprops from CustomHeadingProps type declar…
SirenaBorracha Apr 20, 2021
1b98a3b
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 20, 2021
eac4cec
Merge branch 'ak-new-component-process-list-979' into ak-process-list…
SirenaBorracha Apr 20, 2021
9c8ad71
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 20, 2021
c6ffe8b
Merge branch 'ak-new-component-process-list-979' into ak-process-list…
SirenaBorracha Apr 20, 2021
6382ab1
Accidentally left off an & T
SirenaBorracha Apr 20, 2021
1c3c0a8
Merge branch 'main' into ak-process-list-subcomponent-1134
SirenaBorracha Apr 22, 2021
b722ccb
Make changes to ProcessListHeading based on PR feedback, update tests…
SirenaBorracha Apr 23, 2021
dae186b
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 23, 2021
13c14c7
Remove whitespace from package.json
SirenaBorracha Apr 23, 2021
1c4736a
Merge branch 'ak-new-component-process-list-979' into ak-process-list…
SirenaBorracha Apr 23, 2021
64e52c5
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 26, 2021
04b6b65
Remove weird whitespace addition to yarn.lock
SirenaBorracha Apr 26, 2021
4e5d5fb
Regenerate yarn.lock
SirenaBorracha Apr 26, 2021
7d54347
Merge changes from ProcessList
SirenaBorracha Apr 26, 2021
8432d6c
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 27, 2021
c87f6f9
Regenerate yarn.lock
SirenaBorracha Apr 27, 2021
3dd5d87
Merge changes from parent branch
SirenaBorracha Apr 27, 2021
e83fec8
Merge branch 'main' into ak-process-list-subcomponent-1134
SirenaBorracha Apr 27, 2021
1742003
Replace mistakenly deleted period from stories file
SirenaBorracha Apr 27, 2021
badf46a
Merge branch 'ak-process-list-subcomponent-1134' of github.com:trussw…
SirenaBorracha Apr 27, 2021
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
35 changes: 19 additions & 16 deletions src/components/ProcessList/ProcessList/ProcessList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'

import { ProcessList } from './ProcessList'
import { ProcessListItem } from '../ProcessListItem/ProcessListItem'
import { ProcessListHeading } from '../ProcessListHeading/ProcessListHeading'

export default {
title: 'Components/ProcessList',
Expand All @@ -22,7 +23,7 @@ Source: https://designsystem.digital.gov/components/process-list
export const processListDefault = (): React.ReactElement => (
<ProcessList>
<ProcessListItem>
<h4 className="usa-process-list__heading">Start a process</h4>
<ProcessListHeading type="h4">Start a process</ProcessListHeading>
<p className="margin-top-05">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo,
ipsum sed pharetra gravida, orci magna rhoncus neque.
Expand All @@ -41,7 +42,9 @@ export const processListDefault = (): React.ReactElement => (
</ul>
</ProcessListItem>
<ProcessListItem>
<h4 className="usa-process-list__heading">Proceed to the second step</h4>
<ProcessListHeading type="h4">
Proceed to the second step
</ProcessListHeading>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo,
ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio
Expand All @@ -51,9 +54,9 @@ export const processListDefault = (): React.ReactElement => (
</p>
</ProcessListItem>
<ProcessListItem>
<h4 className="usa-process-list__heading">
<ProcessListHeading type="h4">
Complete the step-by-step process
</h4>
</ProcessListHeading>
<p>
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat
condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi.
Expand All @@ -66,47 +69,47 @@ export const processListDefault = (): React.ReactElement => (
export const processListNoTextCustomSizing = (): React.ReactElement => (
<ProcessList>
<ProcessListItem className="padding-bottom-4">
<p className="usa-process-list__heading font-sans-xl line-height-sans-1">
<ProcessListHeading type="p" className="font-sans-xl line-height-sans-1">
Start a process.
</p>
</ProcessListHeading>
</ProcessListItem>
<ProcessListItem className="padding-bottom-4">
<p className="usa-process-list__heading font-sans-xl line-height-sans-1">
<ProcessListHeading type="p" className="font-sans-xl line-height-sans-1">
Proceed to the second step.
</p>
</ProcessListHeading>
</ProcessListItem>
<ProcessListItem>
<p className="usa-process-list__heading font-sans-xl line-height-sans-1">
<ProcessListHeading type="p" className="font-sans-xl line-height-sans-1">
Complete the step-by-step process.
</p>
</ProcessListHeading>
</ProcessListItem>
</ProcessList>
)

export const processListCustomSizing = (): React.ReactElement => (
<ProcessList>
<ProcessListItem className="padding-bottom-4">
<h4 className="usa-process-list__heading font-sans-xl line-height-sans-1">
<ProcessListHeading type="h4" className="font-sans-xl line-height-sans-1">
Start a process.
</h4>
</ProcessListHeading>
<p className="font-sans-lg margin-top-1 text-light">
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat
condimentum.
</p>
</ProcessListItem>
<ProcessListItem className="padding-bottom-4">
<h4 className="usa-process-list__heading font-sans-xl line-height-sans-1">
<ProcessListHeading type="h4" className="font-sans-xl line-height-sans-1">
Proceed to the second step.
</h4>
</ProcessListHeading>
<p className="font-sans-lg margin-top-1 text-light">
Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat
volutpat.
</p>
</ProcessListItem>
<ProcessListItem>
<h4 className="usa-process-list__heading font-sans-xl line-height-sans-1">
<ProcessListHeading type="h4" className="font-sans-xl line-height-sans-1">
Complete the step-by-step process.
</h4>
</ProcessListHeading>
<p className="font-sans-lg margin-top-1 text-light">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo,
ipsum sed pharetra gravida, orci magna rhoncus neque.
Expand Down
14 changes: 11 additions & 3 deletions src/components/ProcessList/ProcessList/ProcessList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { render } from '@testing-library/react'

import { ProcessList } from '../ProcessList/ProcessList'
import { ProcessListItem } from '../ProcessListItem/ProcessListItem'
import { ProcessListHeading } from '../ProcessListHeading/ProcessListHeading'

const testListItems = [
<li key="one">some text</li>,
Expand Down Expand Up @@ -37,15 +38,22 @@ describe('ProcessList component', () => {
expect(getByRole('list')).toHaveAttribute('aria-label', 'Process list')
})

it('renders when passed ProcessListItem', () => {
it('renders when passed ProcessListItem and ProcessListHeading', () => {
const { getAllByRole } = render(
<ProcessList>
<ProcessListItem>item 1</ProcessListItem>
<ProcessListItem>item 2</ProcessListItem>
<ProcessListItem>
<ProcessListHeading type="h4">item 1</ProcessListHeading>
item 1
</ProcessListItem>
<ProcessListItem>
<ProcessListHeading type="h4">item 2</ProcessListHeading>item 2
</ProcessListItem>
<ProcessListItem>
<ProcessListHeading type="h4">item 3</ProcessListHeading>
<a href="#">item 3</a>
</ProcessListItem>
<ProcessListItem>
<ProcessListHeading type="h4">item 4</ProcessListHeading>
<ul>{testListItems}</ul>
</ProcessListItem>
</ProcessList>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'
import { render } from '@testing-library/react'

import { ProcessListHeading } from './ProcessListHeading'

describe('ProcessListHeading component', () => {
it('renders without errors', () => {
const { queryByTestId } = render(
<ProcessListHeading type="h4">a heading</ProcessListHeading>
)
expect(queryByTestId('processListHeading')).toBeInTheDocument
expect(queryByTestId('processListHeading')).toHaveClass(
'usa-process-list__heading'
)
})
it('renders with a p tag', () => {
const { queryByTestId } = render(
<ProcessListHeading type="p">a heading</ProcessListHeading>
)
expect(queryByTestId('processListHeading')).toBeInTheDocument
expect(queryByTestId('processListHeading')).toHaveClass(
'usa-process-list__heading'
)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react'
import classnames from 'classnames'

interface BaseProcessListHeadingProps {
type: string
className?: string
children?: React.ReactNode
}

interface HeadingProcessListHeadingProps extends BaseProcessListHeadingProps {
type: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
}

interface ParagraphProcessListHeadingProps extends BaseProcessListHeadingProps {
type: 'p'
}

type ProcessListHeadingProps = HeadingProcessListHeadingProps &
React.DetailedHTMLProps<
React.HTMLAttributes<HTMLHeadingElement>,
HTMLHeadingElement
>

type ProcessListParagraphHeadingProps = ParagraphProcessListHeadingProps &
JSX.IntrinsicElements['p']

export const ProcessListHeading = ({
type,
className,
children,
...headingProps
}:
| ProcessListParagraphHeadingProps
| ProcessListHeadingProps): React.ReactElement => {
const classes = classnames('usa-process-list__heading', className)
const Tag = type
return (
<Tag data-testid="processListHeading" className={classes} {...headingProps}>
{children}
</Tag>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import React from 'react'
import { render } from '@testing-library/react'

import { ProcessListItem } from './ProcessListItem'
import { ProcessListHeading } from '../ProcessListHeading/ProcessListHeading'

const testData = (
<>
<h4 className="usa-process-list__heading">Start a process</h4>
<ProcessListHeading type="h4">Start a process</ProcessListHeading>
<p className="margin-top-05">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo,
ipsum sed pharetra gravida, orci magna rhoncus neque.
Expand All @@ -23,17 +24,19 @@ const testData = (
</li>
<li>Aliquam erat volutpat. Sed quis velit.</li>
</ul>
<h4 className="usa-process-list__heading">Proceed to the second step</h4>
<ProcessListHeading type="h4">
Proceed to the second step
</ProcessListHeading>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo,
ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio
lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula
volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla
facilisi. Nulla libero. Vivamus pharetra posuere sapien.
</p>
<h4 className="usa-process-list__heading">
<ProcessListHeading type="h4">
Complete the step-by-step process
</h4>
</ProcessListHeading>
<p>
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat
condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export { Search } from './components/Search/Search'
/** ProcessList components */
export { ProcessList } from './components/ProcessList/ProcessList/ProcessList'
export { ProcessListItem } from './components/ProcessList/ProcessListItem/ProcessListItem'
export { ProcessListHeading } from './components/ProcessList/ProcessListHeading/ProcessListHeading'

export { SiteAlert } from './components/SiteAlert/SiteAlert'

Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1899,8 +1899,13 @@
dependencies:
core-js "^3.8.2"
ts-dedent "^2.0.0"
url-loader "^4.1.1"
util-deprecate "^1.0.2"

webpack "4"
webpack-dev-middleware "^3.7.3"
webpack-filter-warnings-plugin "^1.2.1"
webpack-hot-middleware "^2.25.0"
webpack-virtual-modules "^0.2.2"
"@storybook/[email protected]":
version "6.2.9"
resolved "https://registry.yarnpkg.com/@storybook/client-api/-/client-api-6.2.9.tgz#f0bb44e9b2692adfbf30d7ff751c6dd44bcfe1ce"
Expand Down