-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
2897287
commit 83e8bcc
Showing
7 changed files
with
202 additions
and
0 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
13 changes: 13 additions & 0 deletions
13
...iews/CountryNsOverviewContextAndStructure/NsDirectoryInitiatives/InitiativeCard/i18n.json
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,13 @@ | ||
{ | ||
"namespace": "initiativeListItem", | ||
"strings": { | ||
"initiativeFundNameTitle": "Fund Name", | ||
"initiativeYearApprovedTitle": "Year Approved", | ||
"initiativeTitle": "Initiative Title", | ||
"initiativeFundingTypeTitle": "Funding Type", | ||
"initiativeCategoriesTitle": "Categories", | ||
"initiativeAllocationTitle": "Allocation CHF", | ||
"initiativeFundingPeriodTitle": "Funding Period", | ||
"initiativeMonthsSuffix": "months" | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
...iews/CountryNsOverviewContextAndStructure/NsDirectoryInitiatives/InitiativeCard/index.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,99 @@ | ||
import { _cs } from '@togglecorp/fujs'; | ||
|
||
import Container from '#components/Container'; | ||
import TextOutput from '#components/TextOutput'; | ||
import useTranslation from '#hooks/useTranslation'; | ||
|
||
import styles from './styles.module.css'; | ||
import i18n from './i18n.json'; | ||
|
||
interface Props { | ||
className?: string; | ||
id: number; | ||
allocation: number | null | undefined; | ||
categories: string[] | null | undefined; | ||
fund_type: string | null | undefined; | ||
funding_period: number | null | undefined; | ||
title: string | null | undefined; | ||
year: string | null | undefined; | ||
} | ||
|
||
function InitiativeListItem(props: Props) { | ||
const { | ||
className, | ||
id, | ||
allocation, | ||
categories, | ||
fund_type, | ||
funding_period, | ||
title, | ||
year, | ||
} = props; | ||
|
||
const strings = useTranslation(i18n); | ||
const categoriesItem = categories?.join(', '); | ||
|
||
return ( | ||
<Container | ||
className={_cs(styles.initiativeCard, className)} | ||
childrenContainerClassName={styles.figures} | ||
headingLevel={4} | ||
withInternalPadding | ||
withHeaderBorder | ||
withoutWrapInHeading | ||
// TODO: Verify Fund Name and and Fund Type | ||
headerDescription={( | ||
<TextOutput | ||
label={strings.initiativeFundNameTitle} | ||
value={fund_type} | ||
valueType="text" | ||
strongLabel | ||
/> | ||
)} | ||
> | ||
<div | ||
className={styles.figure} | ||
key={id} | ||
> | ||
<TextOutput | ||
label={strings.initiativeYearApprovedTitle} | ||
value={year} | ||
valueType="text" | ||
strongValue | ||
/> | ||
<TextOutput | ||
label={strings.initiativeTitle} | ||
value={title} | ||
valueType="text" | ||
strongValue | ||
/> | ||
<TextOutput | ||
label={strings.initiativeFundingTypeTitle} | ||
value={fund_type} | ||
valueType="text" | ||
strongValue | ||
/> | ||
<TextOutput | ||
label={strings.initiativeCategoriesTitle} | ||
value={categoriesItem} | ||
strongValue | ||
/> | ||
<div className={styles.separator} /> | ||
<TextOutput | ||
label={strings.initiativeAllocationTitle} | ||
value={allocation} | ||
valueType="number" | ||
strongValue | ||
/> | ||
<TextOutput | ||
label={strings.initiativeFundingPeriodTitle} | ||
value={`${funding_period} ${strings.initiativeMonthsSuffix}`} | ||
valueType="text" | ||
strongValue | ||
/> | ||
</div> | ||
</Container> | ||
); | ||
} | ||
|
||
export default InitiativeListItem; |
18 changes: 18 additions & 0 deletions
18
...ntryNsOverviewContextAndStructure/NsDirectoryInitiatives/InitiativeCard/styles.module.css
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 @@ | ||
.initiative-card { | ||
border-radius: var(--go-ui-border-radius-lg); | ||
box-shadow: var(--go-ui-box-shadow-md); | ||
padding: var(--go-ui-spacing-lg); | ||
|
||
.figures { | ||
display: flex; | ||
flex-grow: 1; | ||
gap: var(--go-ui-spacing-lg); | ||
|
||
.separator { | ||
flex-shrink: 0; | ||
margin: var(--go-ui-spacing-md) 0; | ||
background-color: var(--go-ui-color-separator); | ||
height: var(--go-ui-width-separator-sm); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/views/CountryNsOverviewContextAndStructure/NsDirectoryInitiatives/i18n.json
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,7 @@ | ||
{ | ||
"namespace": "countryNSDirectoryInitiatives", | ||
"strings": { | ||
"countryNSDirectoryInitiativesTitle": "NSD Initiatives", | ||
"countryNSDirectoryInitiativesDescription": "The following data displays ongoing and implemented/closed Initiatives funded by the different NSD funding mechanisms within the country, which are reported by the respective fund office. Contacts: CBF Office, NSIA Office, ESF Secretariat." | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/views/CountryNsOverviewContextAndStructure/NsDirectoryInitiatives/index.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,62 @@ | ||
import { useCallback } from 'react'; | ||
import { useOutletContext } from 'react-router-dom'; | ||
|
||
import Container from '#components/Container'; | ||
import Grid from '#components/Grid'; | ||
import useTranslation from '#hooks/useTranslation'; | ||
import { type CountryOutletContext } from '#utils/outletContext'; | ||
|
||
import InitiativeListItem from './InitiativeCard'; | ||
import i18n from './i18n.json'; | ||
|
||
interface Props { | ||
className?: string; | ||
} | ||
|
||
type CountryListItem = NonNullable<NonNullable<CountryOutletContext['countryResponse']>['initiatives']>[number]; | ||
|
||
const keySelector = (country: CountryListItem) => country.id; | ||
|
||
function NationalSocietyDirectoryInitiatives(props: Props) { | ||
const { className } = props; | ||
const strings = useTranslation(i18n); | ||
|
||
const { countryResponse } = useOutletContext<CountryOutletContext>(); | ||
|
||
const rendererParams = useCallback( | ||
(_: number, data: CountryListItem) => ({ | ||
id: data.id, | ||
allocation: data?.allocation, | ||
categories: data?.categories, | ||
fund_type: data?.fund_type, | ||
funding_period: data?.funding_period, | ||
title: data?.title, | ||
year: data?.year, | ||
}), | ||
[], | ||
); | ||
|
||
return ( | ||
<Container | ||
heading={strings.countryNSDirectoryInitiativesTitle} | ||
// TODO: Add Contacts link in description | ||
headerDescription={strings.countryNSDirectoryInitiativesDescription} | ||
withHeaderBorder | ||
withInternalPadding | ||
> | ||
<Grid | ||
className={className} | ||
data={countryResponse?.initiatives} | ||
pending={false} | ||
errored={false} | ||
filtered={false} | ||
keySelector={keySelector} | ||
renderer={InitiativeListItem} | ||
rendererParams={rendererParams} | ||
numPreferredColumns={3} | ||
/> | ||
</Container> | ||
); | ||
} | ||
|
||
export default NationalSocietyDirectoryInitiatives; |
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