1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

refactor: avoid relative positioning for tbody (#1085)

* refactor: expose vite dev server on local IP

* refactor: avoid relative positioning for tbody

* refactor: avoid height on tbody as well

* refactor: use row height from theme
This commit is contained in:
olav 2022-06-13 09:25:36 +02:00 committed by GitHub
parent d7bc30871f
commit e338319afa
6 changed files with 35 additions and 26 deletions

View File

@ -3,7 +3,9 @@ import { makeStyles } from 'tss-react/mui';
export const useStyles = makeStyles()(theme => ({ export const useStyles = makeStyles()(theme => ({
tableHeader: { tableHeader: {
'& > th': { '& > th': {
height: theme.shape.tableRowHeightCompact,
border: 0, border: 0,
'&:first-of-type': { '&:first-of-type': {
borderTopLeftRadius: theme.shape.borderRadiusMedium, borderTopLeftRadius: theme.shape.borderRadiusMedium,
borderBottomLeftRadius: theme.shape.borderRadiusMedium, borderBottomLeftRadius: theme.shape.borderRadiusMedium,

View File

@ -4,6 +4,8 @@ export const useStyles = makeStyles<{
rowHeight: 'auto' | 'standard' | 'dense' | 'compact' | number; rowHeight: 'auto' | 'standard' | 'dense' | 'compact' | number;
}>()((theme, { rowHeight }) => ({ }>()((theme, { rowHeight }) => ({
table: { table: {
position: 'relative',
'& tbody tr': { '& tbody tr': {
height: height:
{ {

View File

@ -192,6 +192,9 @@ export const FeatureToggleListTable: VFC = () => {
const [firstRenderedIndex, lastRenderedIndex] = const [firstRenderedIndex, lastRenderedIndex] =
useVirtualizedRange(rowHeight); useVirtualizedRange(rowHeight);
const tableHeight =
rowHeight * rows.length + theme.shape.tableRowHeightCompact;
return ( return (
<PageContent <PageContent
isLoading={loading} isLoading={loading}
@ -248,16 +251,18 @@ export const FeatureToggleListTable: VFC = () => {
} }
> >
<SearchHighlightProvider value={getSearchText(searchValue)}> <SearchHighlightProvider value={getSearchText(searchValue)}>
<Table {...getTableProps()} rowHeight={rowHeight}> <Table
{...getTableProps()}
rowHeight={rowHeight}
style={{ height: tableHeight }}
>
<SortableTableHeader headerGroups={headerGroups} flex /> <SortableTableHeader headerGroups={headerGroups} flex />
<TableBody <TableBody {...getTableBodyProps()}>
{...getTableBodyProps()}
style={{
height: `${rowHeight * rows.length}px`,
position: 'relative',
}}
>
{rows.map((row, index) => { {rows.map((row, index) => {
const top =
index * rowHeight +
theme.shape.tableRowHeightCompact;
const isVirtual = const isVirtual =
index < firstRenderedIndex || index < firstRenderedIndex ||
index > lastRenderedIndex; index > lastRenderedIndex;
@ -273,10 +278,7 @@ export const FeatureToggleListTable: VFC = () => {
{...row.getRowProps()} {...row.getRowProps()}
key={row.id} key={row.id}
className={classes.row} className={classes.row}
style={{ style={{ display: 'flex', top }}
top: `${index * rowHeight}px`,
display: 'flex',
}}
> >
{row.cells.map(cell => ( {row.cells.map(cell => (
<TableCell <TableCell

View File

@ -398,6 +398,9 @@ export const ProjectFeatureToggles = ({
const [firstRenderedIndex, lastRenderedIndex] = const [firstRenderedIndex, lastRenderedIndex] =
useVirtualizedRange(rowHeight); useVirtualizedRange(rowHeight);
const tableHeight =
rowHeight * rows.length + theme.shape.tableRowHeightCompact;
return ( return (
<PageContent <PageContent
isLoading={loading} isLoading={loading}
@ -464,21 +467,23 @@ export const ProjectFeatureToggles = ({
} }
> >
<SearchHighlightProvider value={getSearchText(searchValue)}> <SearchHighlightProvider value={getSearchText(searchValue)}>
<Table {...getTableProps()} rowHeight={rowHeight}> <Table
{...getTableProps()}
rowHeight={rowHeight}
style={{ height: tableHeight }}
>
<SortableTableHeader <SortableTableHeader
// @ts-expect-error -- verify after `react-table` v8 // @ts-expect-error -- verify after `react-table` v8
headerGroups={headerGroups} headerGroups={headerGroups}
className={styles.headerClass} className={styles.headerClass}
flex flex
/> />
<TableBody <TableBody {...getTableBodyProps()}>
{...getTableBodyProps()}
style={{
height: `${rowHeight * rows.length}px`,
position: 'relative',
}}
>
{rows.map((row, index) => { {rows.map((row, index) => {
const top =
index * rowHeight +
theme.shape.tableRowHeightCompact;
const isVirtual = const isVirtual =
index < firstRenderedIndex || index < firstRenderedIndex ||
index > lastRenderedIndex; index > lastRenderedIndex;
@ -493,10 +498,7 @@ export const ProjectFeatureToggles = ({
hover hover
{...row.getRowProps()} {...row.getRowProps()}
className={styles.row} className={styles.row}
style={{ style={{ display: 'flex', top }}
top: `${index * rowHeight}px`,
display: 'flex',
}}
> >
{row.cells.map(cell => ( {row.cells.map(cell => (
<TableCell <TableCell

View File

@ -112,7 +112,7 @@ exports[`renders an empty list correctly 1`] = `
className="tss-54jt3w-bodyContainer" className="tss-54jt3w-bodyContainer"
> >
<table <table
className="MuiTable-root tss-z7cn64-table mui-133vm37-MuiTable-root" className="MuiTable-root tss-rjdss1-table mui-133vm37-MuiTable-root"
role="table" role="table"
> >
<thead <thead
@ -120,7 +120,7 @@ exports[`renders an empty list correctly 1`] = `
role={null} role={null}
> >
<tr <tr
className="MuiTableRow-root MuiTableRow-head tss-1an32mz-tableHeader mui-cn4v9y-MuiTableRow-root" className="MuiTableRow-root MuiTableRow-head tss-1sk7xq7-tableHeader mui-cn4v9y-MuiTableRow-root"
role="row" role="row"
> >
<th <th

View File

@ -26,6 +26,7 @@ export default defineConfig({
}, },
server: { server: {
open: true, open: true,
host: true,
proxy: { proxy: {
[`${UNLEASH_BASE_PATH}api`]: { [`${UNLEASH_BASE_PATH}api`]: {
target: UNLEASH_API, target: UNLEASH_API,