-
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.
Add SCSS as export along with Download and Tag components for Dataset…
… page (#2) * Add scss to dist folder for sites to use * Add DatasetDownload and DatasetTag components and tests
- Loading branch information
Showing
11 changed files
with
107 additions
and
13 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,17 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import DatasetDownloads from './index'; | ||
|
||
|
||
describe('<DatasetDownloads />', () => { | ||
test('Renders a download URL link and title', () => { | ||
render( | ||
<DatasetDownloads downloadURL="http://dkan.com/download.csv" />, | ||
); | ||
expect(screen.getByRole('heading', { name: 'Downloads'})).toBeTruthy(); | ||
expect(screen.getByText('Dataset')).toBeTruthy(); | ||
expect(screen.getByRole('link', { name: 'Download this dataset (CSV)'})).toBeTruthy(); | ||
expect(screen.getByRole('link', { name: 'Download this dataset (CSV)'})).toHaveAttribute('href', 'http://dkan.com/download.csv'); | ||
}); | ||
}); |
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,18 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const DatasetDownloads = ({ downloadURL }) => { | ||
return( | ||
<div className="ds-u-margin-bottom--3 ds-u-padding--2 ds-u-border ds-u-border--1"> | ||
<h2 className="ds-u-font-size--h2 ds-u-margin-top--0 ds-u-margin-bottom--2 ds-u-padding-bottom--2 ds-u-border ds-u-border-bottom--1">Downloads</h2> | ||
<p className="ds-u-margin-bottom--0">Dataset</p> | ||
<a href={downloadURL}>Download this dataset (CSV)</a> | ||
</div> | ||
); | ||
} | ||
|
||
DatasetDownloads.propTypes = { | ||
downloadURL: PropTypes.string.isRequired, | ||
} | ||
|
||
export default DatasetDownloads; |
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,23 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import DatasetTags from './index'; | ||
|
||
|
||
describe('<DatasetTags />', () => { | ||
test('Renders a download URL link and title', () => { | ||
const tagList = [ | ||
{ data: 'Tag 1', identifier: '1' }, | ||
{ data: 'Tag 2', identifier: '2' }, | ||
{ data: 'Tag 3', identifier: '3' }, | ||
] | ||
render( | ||
<DatasetTags keywords={tagList} />, | ||
); | ||
expect(screen.getByRole('heading', { name: 'Tags'})).toBeTruthy(); | ||
tagList.forEach(tag => { | ||
expect(screen.getByRole('link', { name: tag.data})).toBeTruthy(); | ||
expect(screen.getByRole('link', { name: tag.data})).toHaveAttribute('href', `/search?keyword=${tag.data}`); | ||
}); | ||
}); | ||
}); |
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,32 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Link } from '@reach/router'; | ||
|
||
const DatasetTags = ({ keywords }) => { | ||
return ( | ||
<div className="dc-c-dataset-tags ds-u-margin-bottom--3 ds-u-padding--2 ds-u-border ds-u-border--1"> | ||
<h2 className="ds-u-font-size--h2 ds-u-margin-bottom--2">Tags</h2> | ||
{keywords | ||
&& keywords.map( | ||
(k) => ( | ||
<Link | ||
key={k.identifier} | ||
to={`/search?keyword=${k.data}`} | ||
className="dc-c-dataset-tags--tag ds-u-color--base ds-u-font-size--small ds-u-text-decoration--none ds-u-margin-right--1 ds-u-margin-bottom--1 ds-u-padding-x--2 ds-u-radius" | ||
> | ||
{k.data} | ||
</Link> | ||
)) | ||
} | ||
</div> | ||
); | ||
} | ||
|
||
DatasetTags.propTypes = { | ||
keywords: PropTypes.arrayOf(PropTypes.shape({ | ||
data: PropTypes.string.isRequired, | ||
identifier: PropTypes.string.isRequired, | ||
})).isRequired, | ||
} | ||
|
||
export default DatasetTags; |
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
Empty file.
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,5 @@ | ||
@import "~@cmsgov/design-system/dist/scss/settings/variables/color"; | ||
.dc-c-dataset-tags--tag { | ||
display: inline-block; | ||
background: $color-primary-alt-lightest; | ||
} |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
@import "./datatable.scss"; | ||
@import "./dataset-tags.scss"; | ||
@import "./dataset-downloads.scss"; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
@import "./templates"; | ||
@import "./components"; | ||
@import "./templates"; |
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