-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add EPubsCard component * Update styles * Add test for EPubsCard * Update query url and tests
- Loading branch information
Showing
7 changed files
with
148 additions
and
28 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
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,24 @@ | ||
@import 'styles/uswdsDependencies'; | ||
|
||
.epubs { | ||
border: 1px solid #929292; | ||
border-radius: 8px; | ||
padding: units(2); | ||
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.15); | ||
|
||
> h3 { | ||
margin: 0; | ||
} | ||
|
||
h3 + p { | ||
margin-top: units('105'); | ||
} | ||
|
||
p { | ||
font-family: 'Sharp Sans'; | ||
font-size: 18px; | ||
font-weight: 400; | ||
line-height: 1.35; | ||
text-overflow: wrap; | ||
} | ||
} |
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,17 @@ | ||
import React from 'react' | ||
import type { Meta } from '@storybook/react' | ||
import EPubsCard from './EPubsCard' | ||
|
||
export default { | ||
title: 'Components/EPubsCard', | ||
component: EPubsCard, | ||
decorators: [ | ||
(Story) => ( | ||
<div className="sfds"> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
} as Meta | ||
|
||
export const DefaultEPubsCard = () => <EPubsCard query="my test query" /> |
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,27 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
import { render, screen } from '@testing-library/react' | ||
|
||
import React from 'react' | ||
|
||
import EPubsCard from './EPubsCard' | ||
|
||
describe('EPubsCard component', () => { | ||
it('renders the card', () => { | ||
render(<EPubsCard query="test" />) | ||
|
||
expect(screen.getAllByText('Looking for a form?')).toHaveLength(1) | ||
|
||
const link = screen.getByRole('link', { | ||
name: 'Search ePubs', | ||
}) | ||
|
||
expect(link).toHaveAttribute( | ||
'href', | ||
'https://search.usa.gov/search?affiliate=afpw_epubs&query=test' | ||
) | ||
expect(link).toBeInstanceOf(HTMLAnchorElement) | ||
}) | ||
}) |
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,27 @@ | ||
import React from 'react' | ||
import styles from './EPubsCard.module.scss' | ||
import LinkTo from 'components/util/LinkTo/LinkTo' | ||
|
||
type PropTypes = { | ||
query: string | ||
} | ||
|
||
const EPubsCard = ({ query }: PropTypes) => { | ||
const ePubsSearch = `https://search.usa.gov/search?affiliate=afpw_epubs&query=${query}` | ||
|
||
return ( | ||
<div className={styles.epubs}> | ||
<h3>Looking for a form?</h3> | ||
<p>Launch your query on ePubs!</p> | ||
<LinkTo | ||
href={ePubsSearch} | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
className="usa-button"> | ||
Search ePubs | ||
</LinkTo> | ||
</div> | ||
) | ||
} | ||
|
||
export default EPubsCard |
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
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 |
---|---|---|
|
@@ -23,3 +23,7 @@ | |
margin-bottom: units(6); | ||
} | ||
} | ||
|
||
.noResults { | ||
display: flex; | ||
} |