-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All but featured-resources have test coverage
- Loading branch information
1 parent
097a0de
commit 8087a42
Showing
24 changed files
with
670 additions
and
493 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
51 changes: 0 additions & 51 deletions
51
src/app/pages/details/common/featured-resources/featured-resources.js
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
src/app/pages/details/common/featured-resources/featured-resources.tsx
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,67 @@ | ||
import React from 'react'; | ||
import ResourceBoxes, {ResourceModel} from '../resource-box/resource-boxes'; | ||
import {FormattedMessage} from 'react-intl'; | ||
import './featured-resources.scss'; | ||
|
||
type ResourcesProps = { | ||
header: string; | ||
models: ResourceModel[]; | ||
'data-analytics-content-list': string; | ||
}; | ||
|
||
function FeaturedResources({header, models, ...props}: ResourcesProps) { | ||
const modResources = models.map((res) => { | ||
const storageKey = `featured-resource-${res.heading}`; | ||
const seenTimes = 1 + Number(window.localStorage[storageKey] || 0); | ||
const model = Object.assign( | ||
{ | ||
isNew: seenTimes <= 3, | ||
onClick: () => { | ||
window.localStorage[storageKey] = 5; | ||
model.isNew = false; | ||
} | ||
}, | ||
res | ||
); | ||
|
||
window.localStorage[storageKey] = seenTimes; | ||
|
||
return model; | ||
}); | ||
|
||
return ( | ||
<div className="card"> | ||
<div className="headline">{header}</div> | ||
<div | ||
data-analytics-content-list={ | ||
props['data-analytics-content-list'] | ||
} | ||
className="resources" | ||
> | ||
<ResourceBoxes models={modResources} /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function FeaturedResourcesSection({ | ||
header, | ||
models, | ||
...props | ||
}: ResourcesProps) { | ||
return ( | ||
<div> | ||
<div className="featured-resources"> | ||
<FeaturedResources header={header} models={models} {...props} /> | ||
</div> | ||
<div className="divider"> | ||
<div className="line"></div> | ||
<FormattedMessage | ||
id="resources.additional" | ||
defaultMessage="see additional resources below" | ||
/> | ||
<div className="line"></div> | ||
</div> | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.