-
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.
Port details page to ts, part 1 (#2679)
* All but featured-resources have test coverage * Get featured resources test coverage * Use .nvmrc in build.yml
- Loading branch information
1 parent
c875d12
commit d6b22d0
Showing
25 changed files
with
731 additions
and
494 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.
64 changes: 64 additions & 0 deletions
64
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,64 @@ | ||
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 | ||
// There was an onClick defined here that nothing used | ||
}, | ||
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.