-
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.
Merge pull request #44 from Vizzuality/table-design-data
[SKY30-89] Fetch data to use in the table
- Loading branch information
Showing
7 changed files
with
327 additions
and
71 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
7 changes: 7 additions & 0 deletions
7
frontend/src/containers/data-tool/content/details/table/header-item/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,7 @@ | ||
import { PropsWithChildren } from 'react'; | ||
|
||
const HeaderItem: React.FC<PropsWithChildren> = ({ children }) => { | ||
return <span className="flex items-center gap-0">{children}</span>; | ||
}; | ||
|
||
export default HeaderItem; |
19 changes: 19 additions & 0 deletions
19
frontend/src/containers/data-tool/content/details/table/helpers.ts
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,19 @@ | ||
import { format } from 'd3-format'; | ||
|
||
const percentage = (value: number) => { | ||
return format(',.2r')(value) == '0.0' ? '0' : format(',.2r')(value); | ||
}; | ||
|
||
const area = (value: number) => { | ||
return format(',.2r')(value); | ||
}; | ||
|
||
const capitalize = (value: string) => { | ||
return value.charAt(0).toUpperCase() + value.slice(1); | ||
}; | ||
|
||
export const cellFormatter = { | ||
percentage, | ||
area, | ||
capitalize, | ||
}; |
40 changes: 40 additions & 0 deletions
40
frontend/src/containers/data-tool/content/details/table/sorting-button/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,40 @@ | ||
import { Column } from '@tanstack/react-table'; | ||
import { ArrowDownNarrowWide, ArrowUpNarrowWide, ArrowUpDown } from 'lucide-react'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
import { GlobalRegionalTableColumns } from '@/containers/data-tool/content/details/tables/global-regional/columns'; | ||
|
||
const ICON_CLASSNAMES = 'h-4 w-4'; | ||
|
||
type SortingButtonProps = { | ||
column: Column<GlobalRegionalTableColumns, unknown>; | ||
}; | ||
|
||
const SortingButton: React.FC<SortingButtonProps> = ({ column }) => { | ||
const isSorted = column.getIsSorted(); | ||
|
||
return ( | ||
<> | ||
{!isSorted && ( | ||
<Button size="icon" variant="ghost" onClick={() => column.toggleSorting(false)}> | ||
<span className="sr-only">Sort ascending</span> | ||
<ArrowUpDown className={ICON_CLASSNAMES} aria-hidden /> | ||
</Button> | ||
)} | ||
{isSorted === 'asc' && ( | ||
<Button size="icon" variant="ghost" onClick={() => column.toggleSorting(true)}> | ||
<span className="sr-only">Sort descending</span> | ||
<ArrowDownNarrowWide className={ICON_CLASSNAMES} aria-hidden /> | ||
</Button> | ||
)} | ||
{isSorted === 'desc' && ( | ||
<Button size="icon" variant="ghost" onClick={() => column.clearSorting()}> | ||
<span className="sr-only">Clear sorting</span> | ||
<ArrowUpNarrowWide className={ICON_CLASSNAMES} aria-hidden /> | ||
</Button> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default SortingButton; |
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.