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

chore: change default table rowSize #1721

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/components/designSystem/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type ActionItem<T> = {
}

type ContainerSize = 0 | 4 | 16 | 48
type RowSize = 44 | 56
type RowSize = 48 | 72

interface TableProps<T> {
name: string
Expand Down Expand Up @@ -94,7 +94,7 @@ export const Table = <T extends DataItem>({
isLoading,
hasError,
containerSize = 48,
rowSize = 56,
rowSize = 48,
placeholder,
onRowAction,
actionColumn,
Expand Down
54 changes: 52 additions & 2 deletions src/pages/__devOnly/DesignSystem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-alert */
import { InputAdornment, Stack } from '@mui/material'
import { Box, InputAdornment, Stack } from '@mui/material'
import { useFormik } from 'formik'
import { useRef } from 'react'
import { generatePath, Link } from 'react-router-dom'
Expand Down Expand Up @@ -49,7 +49,12 @@ import { addToast } from '~/core/apolloClient'
import { intlFormatNumber } from '~/core/formats/intlFormatNumber'
import { ONLY_DEV_DESIGN_SYSTEM_ROUTE, ONLY_DEV_DESIGN_SYSTEM_TAB_ROUTE } from '~/core/router'
import { CurrencyEnum } from '~/generated/graphql'
import { chargeTableData, POSSIBLE_TOAST, tableData } from '~/pages/__devOnly/fixtures'
import {
chargeTableData,
currentUsageTableData,
POSSIBLE_TOAST,
tableData,
} from '~/pages/__devOnly/fixtures'
import Stripe from '~/public/images/stripe.svg'
import { MenuPopper, PageHeader, theme } from '~/styles'

Expand Down Expand Up @@ -612,6 +617,51 @@ const DesignSystem = () => {
},
]}
/>

<Table
name="display-table"
containerSize={0}
rowSize={72}
data={currentUsageTableData}
isLoading={false}
columns={[
{
key: 'chargeName',
title: 'Customer',
content: (row) => (
<Box display={'grid'}>
<Typography variant="body" color="grey700" noWrap>
{row.chargeName}
</Typography>
<Typography variant="caption" color="grey600" noWrap>
{row.chargeCode}
{row.hasFilterBreakdown ? ' • with breakdown' : ''}
</Typography>
</Box>
),
},
{
key: 'units',
title: 'Units',
content: (row) => (
<Typography variant="body" color="grey700">
{row.units}
</Typography>
),
},
{
key: 'amount',
title: 'Amount',
textAlign: 'right',
content: (row) => (
<Typography variant="body" color="grey700">
{intlFormatNumber(row.amount)}
</Typography>
),
},
]}
onRowAction={(item) => alert(`You clicked on ${item.id}`)}
/>
</Block>
</Container>
),
Expand Down
50 changes: 50 additions & 0 deletions src/pages/__devOnly/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,53 @@ export const chargeTableData: Array<{
icon: 'company',
},
]

export const currentUsageTableData: Array<{
id: string
amount: number
chargeCode: string
chargeName: string
hasFilterBreakdown: boolean
units: number
}> = [
{
id: '0',
chargeName: 'GiB Hours',
chargeCode: 'memory_heartbeat',
hasFilterBreakdown: true,
amount: 1000,
units: 123,
},
{
id: '1',
chargeName: 'CPU Hours',
chargeCode: 'cpu_heartbeat',
hasFilterBreakdown: false,
amount: 1000,
units: 123,
},
{
id: '2',
chargeName: 'SOC2 Compliance',
chargeCode: 'compliance',
hasFilterBreakdown: false,
amount: 1000,
units: 123,
},
{
id: '3',
chargeName: 'Datastores',
chargeCode: 'datastores',
hasFilterBreakdown: false,
amount: 1000,
units: 123,
},
{
id: '4',
chargeName: 'Multi Cluster',
chargeCode: 'multicluster',
hasFilterBreakdown: false,
amount: 1000,
units: 123,
},
]
Loading