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

Style responsive table #83

Merged
merged 2 commits into from
Sep 8, 2023
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
18 changes: 18 additions & 0 deletions src/components/Table.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import styled from 'styled-components'
import { spacings } from '../tokens/spacings'

export const StyledDiv = styled.div`
overflow-x: auto;
padding-bottom: ${spacings.MEDIUM};

> .table-wrapper {
> table {
width: auto !important;
margin: 0px !important;
}

> div {
max-width: none !important;
}
}
`
101 changes: 52 additions & 49 deletions src/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,64 @@
import { Chip } from '@equinor/eds-core-react'
import { EdsDataGrid } from '@equinor/eds-data-grid-react'
import { useGetAnalogueModels } from '../hooks/useGetAnalogueModels'
import * as Styled from './Table.styled'

export const Table = () => {
const { data: models } = useGetAnalogueModels()

if (!models) return <p>Loading...</p>

return (
<EdsDataGrid
enableSorting
enablePagination
emptyMessage="Empty :("
rows={models}
columns={[
{
accessorKey: 'analogueModelId',
header: 'Model ID',
id: 'analogueModelId',
},
{ accessorKey: 'name', header: 'Name', id: 'name' },
{
accessorKey: 'description',
header: 'Description',
id: 'description',
},
{
accessorKey: 'isApproved',
header: 'Result',
cell: () => <Chip>{'Approved'}</Chip>,
},
{
accessorKey: 'modified',
header: 'Last Modified',
cell: () => <div>{'<Last Modified>'}</div>,
},
{
accessorKey: 'analogue',
header: 'Analogue',
cell: () => <div>{'<Analogue>'}</div>,
},
{
accessorKey: 'formation',
header: 'Formation',
cell: () => <div>{'<Formation>'}</div>,
},
{
accessorKey: 'field',
header: 'Field',
cell: () => <div>{'<Field>'}</div>,
},
{
accessorKey: 'isProcessed',
header: 'Status',
id: 'isProcessed',
},
]}
/>
<Styled.StyledDiv>
<EdsDataGrid
enableSorting
enablePagination
emptyMessage="Empty :("
rows={models}
columns={[
{
accessorKey: 'analogueModelId',
header: 'Model ID',
id: 'analogueModelId',
},
{ accessorKey: 'name', header: 'Name', id: 'name' },
{
accessorKey: 'description',
header: 'Description',
id: 'description',
},
{
accessorKey: 'isApproved',
header: 'Result',
cell: () => <Chip>{'Approved'}</Chip>,
},
{
accessorKey: 'modified',
header: 'Last Modified',
cell: () => <div>{'<Last Modified>'}</div>,
},
{
accessorKey: 'analogue',
header: 'Analogue',
cell: () => <div>{'<Analogue>'}</div>,
},
{
accessorKey: 'formation',
header: 'Formation',
cell: () => <div>{'<Formation>'}</div>,
},
{
accessorKey: 'field',
header: 'Field',
cell: () => <div>{'<Field>'}</div>,
},
{
accessorKey: 'isProcessed',
header: 'Status',
id: 'isProcessed',
},
]}
/>
</Styled.StyledDiv>
)
}