generated from UNDP-Data/undp-visualization-library
-
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
1 parent
6ced6c2
commit 255c3e8
Showing
4 changed files
with
171 additions
and
1 deletion.
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
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,57 @@ | ||
import styled from 'styled-components'; | ||
|
||
const TableContainer = styled.div` | ||
.programme-totals-table-row { | ||
display: flex; | ||
justify-content: space-between; | ||
border-bottom: 0.06rem solid var(--gray-400); | ||
} | ||
.first-data-point { | ||
border-bottom: 0.06rem solid var(--gray-400); | ||
} | ||
`; | ||
|
||
interface ProgrammeTotalsTableProps { | ||
totals: { | ||
[key: string]: { | ||
label: string; | ||
total: number; | ||
}; | ||
}; | ||
} | ||
|
||
function Summary(props: ProgrammeTotalsTableProps): JSX.Element { | ||
const { totals } = props; | ||
const totalEntries = Object.values(totals); | ||
return ( | ||
<div className='programme-totals-table'> | ||
<TableContainer> | ||
<div className='first-data-point'> | ||
<p className='label padding-bottom-02 margin-bottom-00'> | ||
{totalEntries[0].label} | ||
</p> | ||
<h3 | ||
className='undp-typograhy total margin-00 padding-bottom-04' | ||
style={{ fontWeight: '600' }} | ||
> | ||
{totalEntries[0].total} | ||
</h3> | ||
</div> | ||
<div className='programme-totals-table'> | ||
{totalEntries.slice(1).map(({ label, total }) => ( | ||
<div | ||
key={label} | ||
className='programme-totals-table-row padding-bottom-03 padding-top-03' | ||
> | ||
<div className='label margin-bottom-00'>{label}</div> | ||
<div className='total bold label margin-bottom-00'>{total}</div> | ||
</div> | ||
))} | ||
</div> | ||
</TableContainer> | ||
</div> | ||
); | ||
} | ||
|
||
export default Summary; |
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,88 @@ | ||
import { Check, Search } from 'lucide-react'; | ||
import React, { useState } from 'react'; | ||
import { Input } from 'antd'; | ||
import { ChoroplethMapDataType } from '../Types'; | ||
import { PROGRAMMES } from './Constants'; | ||
|
||
interface Props { | ||
data: ChoroplethMapDataType[]; | ||
} | ||
|
||
function Table(props: Props) { | ||
const { data } = props; | ||
const [searchTerm, setSearchTerm] = useState(''); | ||
|
||
const filteredData = data.filter((rowData: ChoroplethMapDataType) => | ||
rowData.data.country.toLowerCase().includes(searchTerm.toLowerCase()), | ||
); | ||
|
||
return ( | ||
<div className='margin-top-03'> | ||
<Input | ||
placeholder='Search by country' | ||
className='undp-input' | ||
prefix={<Search size={18} strokeWidth={2.5} color='var(--black)' />} | ||
onChange={e => setSearchTerm(e.target.value)} | ||
style={{ width: '100%' }} | ||
/> | ||
<div | ||
className='undp-container margin-top-04 undp-scrollbar' | ||
style={{ | ||
width: '100%', | ||
height: '500px', | ||
}} | ||
> | ||
<div | ||
className='undp-table-head-small' | ||
style={{ | ||
position: 'sticky', | ||
top: '0', | ||
zIndex: '1', | ||
}} | ||
> | ||
<div | ||
style={{ width: '25%' }} | ||
className='undp-table-head-cell undp-sticky-head-column' | ||
> | ||
<div className='padding-left-05 padding-right-05'>Country Name</div> | ||
</div> | ||
{PROGRAMMES.map(field => ( | ||
<div | ||
key={field.label} | ||
style={{ width: '15%' }} | ||
className='undp-table-head-cell undp-sticky-head-column' | ||
> | ||
<div className='padding-left-05 padding-right-05 flex-div flex-hor-align-center'> | ||
{field.label} | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
{filteredData.map((rowData, index) => ( | ||
<div key={index} className='undp-table-row'> | ||
<div style={{ width: '25%' }} className='undp-table-row-cell-small'> | ||
<div className='padding-left-05 padding-right-05'> | ||
{rowData.data.country} | ||
</div> | ||
</div> | ||
{PROGRAMMES.map(field => ( | ||
<div | ||
key={field.value} | ||
style={{ width: '15%' }} | ||
className='undp-table-row-cell-small' | ||
> | ||
<div className='padding-left-05 padding-right-05 padding-top-02 flex-div flex-vert-align-center flex-hor-align-center'> | ||
{rowData.data[field.value] === '1' ? ( | ||
<Check size={18} strokeWidth={3} color='var(--blue-600)' /> | ||
) : null} | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Table; |