Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/implement design reporting tab #1384

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6bb18e6
Refactor Reporting tab
Hornebom Feb 23, 2023
9697988
Design reporting
Hornebom Feb 28, 2023
3b0363c
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Mar 6, 2023
6700b5d
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom May 16, 2023
8f61b26
update to latest loan changes
Hornebom May 16, 2023
a1dbace
Reporting tab
Hornebom May 16, 2023
ecb1ad1
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom May 16, 2023
b2f60c5
removes old Report component
Hornebom May 17, 2023
1b4237e
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom May 18, 2023
000db33
remove period
Hornebom May 19, 2023
7d220cf
extends ReportContext with range
Hornebom May 19, 2023
d450fc7
adds currency symbol
Hornebom May 19, 2023
3fb1dbc
removes dev setting
Hornebom May 19, 2023
f2580ea
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Jun 28, 2023
55c0b77
formatting table data to human readable strings
Hornebom Jun 29, 2023
8706689
adds currency symbol in front of amount
Hornebom Jun 29, 2023
20f3a2d
visual display reporting tables
Hornebom Jun 30, 2023
8db8bc5
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Jun 30, 2023
3a96551
removes developement component rendering
Hornebom Jun 30, 2023
7de8431
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Jul 3, 2023
692a308
manually solve merge conflict
Hornebom Jul 3, 2023
560e055
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Jul 10, 2023
abc568c
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Jul 28, 2023
3a9c4c3
refactor to use correct formatting
Hornebom Jul 28, 2023
fc3e2db
refactor: removes hidden behind feature flag
Hornebom Jul 31, 2023
a811e78
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Aug 1, 2023
d83961d
refactor: set start date on init useState
Hornebom Aug 1, 2023
85e48a7
refactor: pass ref to custom hook
Hornebom Aug 1, 2023
0fefd2b
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Aug 3, 2023
a8ae436
Merge branch 'main' into feat/implement-design-reporting-tab
Hornebom Aug 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions centrifuge-app/src/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BN from 'bn.js'
import * as React from 'react'
import { Link, LinkProps } from 'react-router-dom'
import styled from 'styled-components'
import { useElementScrollSize } from '../utils/useElementScrollSize'

type GroupedProps = {
groupIndex?: number
Expand Down Expand Up @@ -68,6 +69,7 @@ export const DataTable = <T extends Record<string, any>>({
)

const [currentSortKey, setCurrentSortKey] = React.useState(defaultSortKey || '')
const [setNode, { scrollWidth }] = useElementScrollSize()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better API for this would be

const ref = useRef()
const { scrollWidth } = useElementScrollSize(ref)

doing a setState for setting the ref seems like a bad idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored


const updateSortOrder = (sortKey: Column['sortKey']) => {
if (!sortKey) return
Expand All @@ -82,8 +84,13 @@ export const DataTable = <T extends Record<string, any>>({
}, [orderBy, data, currentSortKey, page, pageSize])

const showHeader = groupIndex === 0 || !groupIndex

return (
<Stack as={rounded && !lastGroupIndex ? Card : Stack}>
<Stack
ref={setNode}
as={rounded && !lastGroupIndex ? Card : Stack}
minWidth={scrollWidth > 0 ? scrollWidth : 'auto'}
>
<Shelf>
{showHeader &&
columns.map((col, i) => (
Expand Down Expand Up @@ -189,22 +196,22 @@ const DataCol = styled(Text)<{ align: Column['align'] }>`
white-space: nowrap;

&:first-child {
padding-right: '16px';
padding-right: 16px;
}
${({ align }) => {
switch (align) {
case 'left':
return css({
justifyContent: 'flex-start',
'&:last-child': {
paddingRight: '16px',
paddingRight: 16,
},
})
case 'center':
return css({
justifyContent: 'center',
'&:last-child': {
paddingRight: '16px',
paddingRight: 16,
},
})
case 'right':
Expand All @@ -214,7 +221,7 @@ const DataCol = styled(Text)<{ align: Column['align'] }>`
justifyContent: 'flex-end',

'&:last-child': {
paddingRight: '16px',
paddingRight: 16,
},
})
}
Expand Down
10 changes: 8 additions & 2 deletions centrifuge-app/src/components/DataTableGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import { Card, Stack } from '@centrifuge/fabric'
import * as React from 'react'
import { DataTableProps } from './DataTable'

export function DataTableGroup({ children }: { children: React.ReactElement<DataTableProps>[] }) {
export function DataTableGroup({
children,
rounded = true,
}: {
children: React.ReactElement<DataTableProps>[]
rounded?: boolean
}) {
return (
<Stack as={Card} gap="3">
<Stack as={rounded ? Card : undefined} gap="3">
{React.Children.map(children, (child, index) => {
return React.isValidElement(child)
? React.cloneElement(child, {
Expand Down
Loading
Loading