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: New Component ProcessList MVP #1107

Merged
merged 23 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 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
1b98a3b
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 20, 2021
9c8ad71
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 20, 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
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
8432d6c
Merge branch 'main' into ak-new-component-process-list-979
SirenaBorracha Apr 27, 2021
c87f6f9
Regenerate yarn.lock
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
116 changes: 116 additions & 0 deletions src/components/ProcessList/ProcessList/ProcessList.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import React from 'react'

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

export default {
title: 'Components/ProcessList',
component: ProcessList,
parameters: {
docs: {
description: {
component: `
### USWDS 2.0 ProcessList component

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>
<p className="margin-top-05">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo,
ipsum sed pharetra gravida, orci magna rhoncus neque.
</p>
<ul>
<li>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi
commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id
pulvinar odio lorem non turpis.
</li>
<li>
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat
condimentum.
</li>
<li>Aliquam erat volutpat. Sed quis velit.</li>
</ul>
</ProcessListItem>
<ProcessListItem>
<h4 className="usa-process-list__heading">Proceed to the second step</h4>
<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>
</ProcessListItem>
<ProcessListItem>
<h4 className="usa-process-list__heading">
Complete the step-by-step process
</h4>
<p>
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>
</ProcessListItem>
</ProcessList>
)

export const processListNoTextCustomSizing = (): React.ReactElement => (
<ProcessList>
<ProcessListItem className="padding-bottom-4">
<p className="usa-process-list__heading font-sans-xl line-height-sans-1">
Start a process.
</p>
</ProcessListItem>
<ProcessListItem className="padding-bottom-4">
<p className="usa-process-list__heading font-sans-xl line-height-sans-1">
Proceed to the second step.
</p>
</ProcessListItem>
<ProcessListItem>
<p className="usa-process-list__heading font-sans-xl line-height-sans-1">
Complete the step-by-step process.
</p>
</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">
Start a process.
</h4>
<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">
Proceed to the second step.
</h4>
<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">
Complete the step-by-step process.
</h4>
<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.
</p>
</ProcessListItem>
</ProcessList>
)
56 changes: 56 additions & 0 deletions src/components/ProcessList/ProcessList/ProcessList.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react'
import { render } from '@testing-library/react'

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

const testListItems = [
<li key="one">some text</li>,
<li key="two">some more text</li>,
<li key="three">third item</li>,
]

describe('ProcessList component', () => {
it('renders without errors', () => {
const { getAllByRole, queryByText } = render(
<ProcessList>{testListItems}</ProcessList>
)

expect(queryByText('third item')).toBeInTheDocument()
expect(getAllByRole('listitem')).toHaveLength(3)
})

it('accepts a class name', () => {
const { getByRole } = render(
<ProcessList className="custom-class-name">{testListItems}</ProcessList>
)

expect(getByRole('list')).toHaveClass('usa-process-list custom-class-name')
})

it('accepts attributes passed in as props', () => {
const { getByRole } = render(
<ProcessList aria-label="Process list">{testListItems}</ProcessList>
)

expect(getByRole('list')).toHaveAttribute('aria-label', 'Process list')
})

it('renders when passed ProcessListItem', () => {
const { getAllByRole } = render(
<ProcessList>
<ProcessListItem>item 1</ProcessListItem>
<ProcessListItem>item 2</ProcessListItem>
<ProcessListItem>
<a href="#">item 3</a>
</ProcessListItem>
<ProcessListItem>
<ul>{testListItems}</ul>
</ProcessListItem>
</ProcessList>
)
expect(getAllByRole('list')).toHaveLength(2)
expect(getAllByRole('listitem')).toHaveLength(7)
})
})
23 changes: 23 additions & 0 deletions src/components/ProcessList/ProcessList/ProcessList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react'
import classnames from 'classnames'
import { ProcessListItemProps } from '../ProcessListItem/ProcessListItem'

interface ProcessListProps {
className?: string
children: React.ReactElement<ProcessListItemProps>[]
}

export const ProcessList = ({
className,
children,
...listProps
}: ProcessListProps & JSX.IntrinsicElements['ol']): React.ReactElement => {
const classes = classnames('usa-process-list', className)
return (
<ol className={classes} {...listProps}>
{children}
</ol>
)
}

export default ProcessList
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react'
import { render } from '@testing-library/react'

import { ProcessListItem } from './ProcessListItem'

const testData = (
<>
<h4 className="usa-process-list__heading">Start a process</h4>
<p className="margin-top-05">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo,
ipsum sed pharetra gravida, orci magna rhoncus neque.
</p>
<ul>
<li>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo,
ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio
lorem non turpis.
</li>
<li>
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat
condimentum.
</li>
<li>Aliquam erat volutpat. Sed quis velit.</li>
</ul>
<h4 className="usa-process-list__heading">Proceed to the second step</h4>
<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">
Complete the step-by-step process
</h4>
<p>
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>
</>
)

describe('ProcessListItem component', () => {
it('renders without errors', () => {
const { getByRole } = render(<ProcessListItem>some text</ProcessListItem>)

const listItem = getByRole('listitem')
expect(listItem).toBeInTheDocument()
expect(listItem).toHaveClass('usa-process-list__item')
})

it('renders children passed in', () => {
const { getAllByRole } = render(
<ProcessListItem>{testData}</ProcessListItem>
)

expect(getAllByRole('listitem')).toHaveLength(4)
expect(getAllByRole('heading')).toHaveLength(3)
})

it('accepts a custom className', () => {
const { getByRole } = render(
<ProcessListItem className="custom-class-name">
<a href="#">link text</a>
</ProcessListItem>
)

expect(getByRole('listitem')).toHaveClass(
'usa-process-list__item custom-class-name'
)
})
})
22 changes: 22 additions & 0 deletions src/components/ProcessList/ProcessListItem/ProcessListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import classnames from 'classnames'

export interface ProcessListItemProps {
className?: string
children?: React.ReactNode
}

export const ProcessListItem = ({
className,
children,
...liProps
}: ProcessListItemProps & JSX.IntrinsicElements['li']): React.ReactElement => {
const liClasses = classnames('usa-process-list__item', className)
return (
<li className={liClasses} {...liProps}>
{children}
</li>
)
}

export default ProcessListItem
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export { StepIndicatorStep } from './components/stepindicator/StepIndicatorStep/

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

/** ProcessList components */
export { ProcessList } from './components/ProcessList/ProcessList/ProcessList'
export { ProcessListItem } from './components/ProcessList/ProcessListItem/ProcessListItem'

/** Truss-designed components */
export {
Modal,
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13943,11 +13943,11 @@ use@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==

brandonlenz marked this conversation as resolved.
Show resolved Hide resolved
uswds@2.10.3:
version "2.10.3"
resolved "https://registry.yarnpkg.com/uswds/-/uswds-2.10.3.tgz#16d34cee81897762d6d69d3ac83aa55129826fa6"
integrity sha512-krNRzx1jRzOJpuH/qtmQhd5zxnXTaDVqrPNYT99sJbxzWUqjb1zZHh3jFNo+xKDpNuiO0XMPwZwlaSp2YdZ3Ag==

Copy link
Contributor

Choose a reason for hiding this comment

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

this file shouldn't have any changes

dependencies:
classlist-polyfill "^1.0.3"
del "^6.0.0"
Expand Down