-
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.
- Loading branch information
Showing
51 changed files
with
2,285 additions
and
1,491 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,35 @@ | ||
.dkan-c-cms-topnav { | ||
height: 51px; | ||
} | ||
|
||
.dkan-c-cms-topnav > div { | ||
height: 100%; | ||
} | ||
|
||
.dkan-c-cms-topnav .dkan-c-cms-topnav-menu a { | ||
display: inline-block; | ||
margin: 3px 7px; | ||
} | ||
|
||
.dkan-c-cms-topnav--menu ul { | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.dkan-c-cms-topnav .dkan-c-cms-topnav--tagline { | ||
height: 100%; | ||
margin-left: 16px; | ||
} | ||
|
||
@media screen and (max-width: 544px) { | ||
.dkan-c-cms-topnav { | ||
display: none; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 1024px) { | ||
.dkan-c-cms-topnav { | ||
height: 85px; | ||
} | ||
} |
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,46 @@ | ||
import React from 'react'; | ||
import { NavLink } from 'react-router-dom'; | ||
import HeaderTagline from '../HeaderTagline'; | ||
import HeaderNavIconLink from '../HeaderNavIconLink'; | ||
import { OrgType, NavLinkArray } from '../../types/misc'; | ||
import './cms-topnav.scss'; | ||
|
||
export type CMSTopNavProps = { | ||
org: OrgType | ||
links: NavLinkArray[] | ||
} | ||
|
||
const CMSTopNav = (props: CMSTopNavProps) => { | ||
const { links, org } = props; | ||
const { urlTitle, logoAltText="", logoFilePath="", tagline, url} = org; | ||
return ( | ||
<div className="dkan-c-cms-topnav ds-u-display--flex ds-u-padding-x--5 ds-u-align-items--center ds-u-justify-content--center ds-u-lg-justify-content--start"> | ||
<div className="ds-l-col--12 ds-l-md-col--5 ds-l-lg-col--7 ds-u-display--flex ds-u-align-items--center ds-u-justify-content--center ds-u-md-justify-content--start"> | ||
<HeaderNavIconLink | ||
url={url} | ||
urlTitle={urlTitle} | ||
logoAltText={logoAltText} | ||
logoFilePath={logoFilePath} | ||
/> | ||
<HeaderTagline tagline={tagline} /> | ||
</div> | ||
<div className="ds-l-col--7 ds-l-lg-col--5 ds-u-display--none ds-u-md-display--inline-flex ds-u-align-items--center ds-u-justify-content--end"> | ||
<nav className="dkan-c-cms-topnav--menu"> | ||
<ul className="ds-u-justify-content--end ds-u-md-align-items--center ds-u-flex-direction--column ds-u-md-flex-direction--row"> | ||
{links.map((link: any) => { | ||
return( | ||
<li className="ds-u-margin-x--05 ds-u-font-size--sm"> | ||
<NavLink to={link.url}> | ||
<span>{link.label}</span> | ||
</NavLink> | ||
</li> | ||
) | ||
})} | ||
</ul> | ||
</nav> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default CMSTopNav; |
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
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,40 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import DOMPurify from 'dompurify'; | ||
import { DatasetDescriptionType } from '../../types/dataset'; | ||
|
||
const DatasetDescription = ( | ||
{distribution, dataset, resource, customDescription, updateAriaLive} : DatasetDescriptionType | ||
) => { | ||
const [description, setDescription] = useState(""); | ||
|
||
if(!distribution && !dataset?.identifier) { | ||
return null; | ||
} | ||
useEffect(() => { | ||
let newDescription = ''; | ||
if (customDescription) { | ||
newDescription = customDescription(dataset, distribution, resource); | ||
} else { | ||
if(distribution.data && distribution.data.description) { | ||
newDescription = distribution.data.description; | ||
} else if(dataset.description) { | ||
newDescription = dataset.description; | ||
} | ||
} | ||
if (description !== newDescription && updateAriaLive) { | ||
updateAriaLive(newDescription); | ||
} | ||
setDescription(newDescription); | ||
}, [resource, distribution, dataset, customDescription]); | ||
|
||
return ( | ||
<div className={'ds-u-measure--wide ds-u-margin-bottom--7'}> | ||
<div | ||
className="ds-u-margin-top--0 dc-c-metadata-description" | ||
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(description) }} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default DatasetDescription; |
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
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
This file was deleted.
Oops, something went wrong.
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,69 @@ | ||
import React from 'react'; | ||
import { FAQItemType } from '../../types/misc'; | ||
import { Accordion, AccordionItem, Button } from "@cmsgov/design-system"; | ||
|
||
type FAQProps = { | ||
faqs: FAQItemType[] | ||
} | ||
|
||
const FAQAccordion = (props: FAQProps) => { | ||
const { faqs } = props; | ||
const [expanded, setExpanded] = React.useState(false); | ||
const [faqItems, setFaqItems] = React.useState(faqs); | ||
|
||
function toggleAll() { | ||
if (expanded) { | ||
const newFaqs = faqItems.map((item) => ({...item, open: false})); | ||
setFaqItems(newFaqs); | ||
setExpanded(false); | ||
} else { | ||
const newFaqs = faqItems.map((item) => ({...item, open: true})); | ||
setFaqItems(newFaqs); | ||
setExpanded(true); | ||
} | ||
} | ||
|
||
function toggleAccordionItem(id: string) { | ||
const currentFaqIndex = faqItems.findIndex((item) => item.id === id); | ||
const updatedFaq = { | ||
...faqItems[currentFaqIndex], | ||
open: !faqItems[currentFaqIndex].open | ||
} | ||
|
||
const newFaqs = [ | ||
...faqItems.slice(0, currentFaqIndex), | ||
updatedFaq, | ||
...faqItems.slice(currentFaqIndex + 1) | ||
] | ||
setFaqItems(newFaqs); | ||
|
||
const openCount = newFaqs.filter((item) => item.open === true).length; | ||
if (openCount > 0 && openCount == newFaqs.length) { | ||
setExpanded(true); | ||
} else { | ||
setExpanded(false); | ||
} | ||
} | ||
|
||
return( | ||
<div> | ||
<Button className='ds-u-margin-y--2 ds-u-float--right' type="button" variation='ghost' onClick={() => toggleAll()}> | ||
{`${expanded ? 'Collapse' : 'Expand'} all FAQs`} | ||
</Button> | ||
<Accordion> | ||
{faqItems.map((faq) => ( | ||
<AccordionItem | ||
key={faq.id} | ||
heading={faq.title} | ||
isControlledOpen={faq.open} | ||
onChange={() => toggleAccordionItem(faq.id)} | ||
> | ||
{faq.body} | ||
</AccordionItem> | ||
))} | ||
</Accordion> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FAQAccordion; |
Oops, something went wrong.