mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-01 08:06:49 +03:00
Merge pull request #72 from twentyhq/cbo-horizontal-scroll
Add horizontal scroll on tables
This commit is contained in:
commit
6284677fca
@ -21,7 +21,8 @@ type OwnProps<TData> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const StyledTable = styled.table`
|
const StyledTable = styled.table`
|
||||||
min-width: calc(100% - ${(props) => props.theme.spacing(4)});
|
min-width: 1000px;
|
||||||
|
width: calc(100% - ${(props) => props.theme.spacing(4)});
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
@ -61,6 +62,13 @@ const StyledTableWithHeader = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledTableScrollableContainer = styled.div`
|
||||||
|
overflow: auto;
|
||||||
|
height: 100%;
|
||||||
|
flex: 1;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function Table<TData>({
|
function Table<TData>({
|
||||||
@ -85,58 +93,64 @@ function Table<TData>({
|
|||||||
onSortsUpdate={onSortsUpdate}
|
onSortsUpdate={onSortsUpdate}
|
||||||
sortsAvailable={sortsAvailable || []}
|
sortsAvailable={sortsAvailable || []}
|
||||||
/>
|
/>
|
||||||
<StyledTable>
|
<StyledTableScrollableContainer>
|
||||||
<thead>
|
<StyledTable>
|
||||||
{table.getHeaderGroups().map((headerGroup) => (
|
<thead>
|
||||||
<tr key={headerGroup.id}>
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
{headerGroup.headers.map((header) => (
|
<tr key={headerGroup.id}>
|
||||||
<th key={header.id}>
|
{headerGroup.headers.map((header) => (
|
||||||
{header.isPlaceholder
|
|
||||||
? null
|
|
||||||
: flexRender(
|
|
||||||
header.column.columnDef.header,
|
|
||||||
header.getContext(),
|
|
||||||
)}
|
|
||||||
</th>
|
|
||||||
))}
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{table.getRowModel().rows.map((row, index) => (
|
|
||||||
<tr key={row.id} data-testid={`row-id-${row.index}`}>
|
|
||||||
{row.getVisibleCells().map((cell) => {
|
|
||||||
return (
|
|
||||||
<td key={cell.id}>
|
|
||||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
||||||
</td>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
{table
|
|
||||||
.getFooterGroups()
|
|
||||||
.flatMap((group) => group.headers)
|
|
||||||
.filter((header) => !!header.column.columnDef.footer).length > 0 && (
|
|
||||||
<tfoot>
|
|
||||||
{table.getFooterGroups().map((footerGroup) => (
|
|
||||||
<tr key={footerGroup.id}>
|
|
||||||
{footerGroup.headers.map((header) => (
|
|
||||||
<th key={header.id}>
|
<th key={header.id}>
|
||||||
{header.isPlaceholder
|
{header.isPlaceholder
|
||||||
? null
|
? null
|
||||||
: flexRender(
|
: flexRender(
|
||||||
header.column.columnDef.footer,
|
header.column.columnDef.header,
|
||||||
header.getContext(),
|
header.getContext(),
|
||||||
)}
|
)}
|
||||||
</th>
|
</th>
|
||||||
))}
|
))}
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tfoot>
|
</thead>
|
||||||
)}
|
<tbody>
|
||||||
</StyledTable>
|
{table.getRowModel().rows.map((row, index) => (
|
||||||
|
<tr key={row.id} data-testid={`row-id-${row.index}`}>
|
||||||
|
{row.getVisibleCells().map((cell) => {
|
||||||
|
return (
|
||||||
|
<td key={cell.id}>
|
||||||
|
{flexRender(
|
||||||
|
cell.column.columnDef.cell,
|
||||||
|
cell.getContext(),
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
{table
|
||||||
|
.getFooterGroups()
|
||||||
|
.flatMap((group) => group.headers)
|
||||||
|
.filter((header) => !!header.column.columnDef.footer).length >
|
||||||
|
0 && (
|
||||||
|
<tfoot>
|
||||||
|
{table.getFooterGroups().map((footerGroup) => (
|
||||||
|
<tr key={footerGroup.id}>
|
||||||
|
{footerGroup.headers.map((header) => (
|
||||||
|
<th key={header.id}>
|
||||||
|
{header.isPlaceholder
|
||||||
|
? null
|
||||||
|
: flexRender(
|
||||||
|
header.column.columnDef.footer,
|
||||||
|
header.getContext(),
|
||||||
|
)}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tfoot>
|
||||||
|
)}
|
||||||
|
</StyledTable>
|
||||||
|
</StyledTableScrollableContainer>
|
||||||
</StyledTableWithHeader>
|
</StyledTableWithHeader>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ const StyledRightContainer = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
|
@ -12,6 +12,7 @@ const StyledContainer = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ContentContainer = styled.div`
|
const ContentContainer = styled.div`
|
||||||
@ -21,6 +22,7 @@ const ContentContainer = styled.div`
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
padding-right: ${(props) => props.theme.spacing(3)};
|
padding-right: ${(props) => props.theme.spacing(3)};
|
||||||
padding-bottom: ${(props) => props.theme.spacing(3)};
|
padding-bottom: ${(props) => props.theme.spacing(3)};
|
||||||
|
width: calc(100% - ${(props) => props.theme.spacing(3)});
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ContentSubContainer = styled.div`
|
const ContentSubContainer = styled.div`
|
||||||
|
Loading…
Reference in New Issue
Block a user