Skip to content

Commit

Permalink
v1.14 updates (#89)
Browse files Browse the repository at this point in the history
* Add whitespace: preline to metadata descriptions
* Add hook for scroll to top after pathname update (#90)
* Pass defaultSort to datatable in resource preview
  • Loading branch information
dgading authored Jun 24, 2022
1 parent 79fd71a commit 536aecc
Show file tree
Hide file tree
Showing 8 changed files with 859 additions and 5,152 deletions.
5,983 changes: 835 additions & 5,148 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@civicactions/cmsds-open-data-components",
"version": "1.13.0",
"version": "1.14.0",
"description": "Components for the open data catalog frontend using CMS Design System",
"main": "lib/index.js",
"scripts": {
Expand All @@ -15,7 +15,7 @@
"author": "",
"license": "GPL-3.0",
"dependencies": {
"@civicactions/data-catalog-components": "2.0.0-beta.5",
"@civicactions/data-catalog-components": "2.0.1",
"@civicactions/data-catalog-services": "~1.5.0",
"@cmsgov/design-system": "~3.3.0",
"@popperjs/core": "^2.11.4",
Expand All @@ -24,6 +24,7 @@
"react-datepicker": "^4.2.1",
"react-popper": "^2.2.5",
"react-responsive": "^8.2.0",
"react-router-dom": "^6.2.2",
"react-table": "^7.6.2",
"react-text-truncate": "^0.18.0",
"swagger-ui-react": "^4.1.3"
Expand Down
3 changes: 3 additions & 0 deletions src/components/ResourcePreview/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const ResourcePreview = ({
id,
options,
resource,
defaultSort,
customColumns,
truncateCellHeader,
columnSettings,
Expand Down Expand Up @@ -84,6 +85,7 @@ const ResourcePreview = ({
<DataTable
filterTitle="Filter columns"
data={resource.values}
sortDefaults={defaultSort}
columns={
customColumns ? customColumns : prepareColumns(resource.columns, resource.schema[id])
}
Expand Down Expand Up @@ -129,6 +131,7 @@ ResourcePreview.defaultProps = {
columnResize: true,
},
truncateCellHeader: true,
defaultSort: [],
};

export default ResourcePreview;
11 changes: 11 additions & 0 deletions src/components/useScrollToTop/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const useScrollToTop = () => {
const { pathname } = useLocation();
useEffect(() => {
window.scrollTo(0, 0);
}, [pathname])
}

export default useScrollToTop;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export { default as APIPage } from './templates/APIPage';

// Hooks
export { default as useAddLoginLink } from './components/useAddLoginLink';
export { default as useScrollToTop } from './components/useScrollToTop';

// Assets
export { default as frequencyMap } from './assets/frequencyMap';
4 changes: 4 additions & 0 deletions src/styles/scss/templates/dataset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
background-color: $color-primary;
}
}

.dc-c-metadata-description {
white-space: pre-line;
}
2 changes: 1 addition & 1 deletion src/templates/Dataset/DatasetBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const DatasetBody = ({
</p>
)}
</div>
<p dangerouslySetInnerHTML={{ __html: dataset.description }} />
<p className="dc-c-metadata-description" dangerouslySetInnerHTML={{ __html: dataset.description }} />
{resource.columns && Object.keys(resource.schema).length ? (
<>
<h2 className="dc-resource-header">Resource Preview</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/FilteredResource/FilteredResourceBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const FilteredResourceBody = ({
</Link>
<h1 className="ds-title">{customTitle ? customTitle : pageTitle}</h1>
<p
className="ds-u-margin-top--0"
className="ds-u-margin-top--0 dc-c-metadata-description"
dangerouslySetInnerHTML={{ __html: distribution.data.description }}
/>
{resource.columns && Object.keys(resource.schema).length && (
Expand Down

0 comments on commit 536aecc

Please sign in to comment.