refactor: tweak table element styles

This commit is contained in:
Carlos Valente
2024-12-20 09:27:49 +01:00
committed by Carlos Valente
parent fb38d82855
commit ab6765b332
6 changed files with 29 additions and 16 deletions
+2 -2
View File
@@ -43,7 +43,7 @@ export const ontimeInputTransparent = {
...commonStyles, ...commonStyles,
backgroundColor: 'transparent', backgroundColor: 'transparent',
_hover: { _hover: {
backgroundColor: 'rgba(255, 255, 255, 0.10)', // $white-10 backgroundColor: '#2d2d2d', // $gray-1100
}, },
}, },
}; };
@@ -56,6 +56,6 @@ export const ontimeTextAreaTransparent = {
...commonStyles, ...commonStyles,
backgroundColor: 'transparent', backgroundColor: 'transparent',
_hover: { _hover: {
backgroundColor: 'rgba(255, 255, 255, 0.10)', // $white-10 backgroundColor: '#2d2d2d', // $gray-1100
}, },
}; };
@@ -48,7 +48,7 @@ $table-header-font-size: calc(1rem - 2px);
} }
.actionColumn { .actionColumn {
width: calc(1.5rem + 0.5rem); // sm button size (--chakra-sizes-6) + 2 * padding width: calc(2rem + 0.5rem); // sm button size (--chakra-sizes-8) + 2 * padding
} }
} }
@@ -150,10 +150,10 @@ export default function CuesheetTable(props: CuesheetTableProps) {
<td> <td>
<MenuButton <MenuButton
as={IconButton} as={IconButton}
size='xs' size='sm'
aria-label='Options' aria-label='Options'
icon={<IoEllipsisHorizontal />} icon={<IoEllipsisHorizontal />}
variant='ontime-ghosted' variant='ontime-subtle'
/> />
</td> </td>
{row.getVisibleCells().map((cell) => { {row.getVisibleCells().map((cell) => {
@@ -8,7 +8,9 @@ interface MultiLineCellProps {
handleUpdate: (newValue: string) => void; handleUpdate: (newValue: string) => void;
} }
const MultiLineCell = (props: MultiLineCellProps) => { export default memo(MultiLineCell);
function MultiLineCell(props: MultiLineCellProps) {
const { initialValue, handleUpdate } = props; const { initialValue, handleUpdate } = props;
const ref = useRef<HTMLInputElement | null>(null); const ref = useRef<HTMLInputElement | null>(null);
const submitCallback = useCallback((newValue: string) => handleUpdate(newValue), [handleUpdate]); const submitCallback = useCallback((newValue: string) => handleUpdate(newValue), [handleUpdate]);
@@ -22,8 +24,12 @@ const MultiLineCell = (props: MultiLineCellProps) => {
inputref={ref} inputref={ref}
rows={1} rows={1}
size='sm' size='sm'
padding={0} style={{
fontSize='1rem' minHeight: '2rem',
padding: '0',
paddingTop: '0.25rem',
fontSize: '1rem',
}}
transition='none' transition='none'
variant='ontime-transparent' variant='ontime-transparent'
value={value} value={value}
@@ -33,6 +39,4 @@ const MultiLineCell = (props: MultiLineCellProps) => {
spellCheck={false} spellCheck={false}
/> />
); );
}; }
export default memo(MultiLineCell);
@@ -8,7 +8,9 @@ interface SingleLineCellProps {
handleUpdate: (newValue: string) => void; handleUpdate: (newValue: string) => void;
} }
const SingleLineCell = (props: SingleLineCellProps) => { export default memo(SingleLineCell);
function SingleLineCell(props: SingleLineCellProps) {
const { initialValue, handleUpdate } = props; const { initialValue, handleUpdate } = props;
const ref = useRef<HTMLInputElement | null>(null); const ref = useRef<HTMLInputElement | null>(null);
const submitCallback = useCallback((newValue: string) => handleUpdate(newValue), [handleUpdate]); const submitCallback = useCallback((newValue: string) => handleUpdate(newValue), [handleUpdate]);
@@ -20,8 +22,10 @@ const SingleLineCell = (props: SingleLineCellProps) => {
return ( return (
<Input <Input
ref={ref} ref={ref}
size='sx' size='sm'
variant='ontime-transparent' variant='ontime-transparent'
padding={0}
fontSize='md'
value={value} value={value}
onChange={onChange} onChange={onChange}
onBlur={onBlur} onBlur={onBlur}
@@ -30,6 +34,4 @@ const SingleLineCell = (props: SingleLineCellProps) => {
autoComplete='off' autoComplete='off'
/> />
); );
}; }
export default memo(SingleLineCell);
@@ -102,6 +102,7 @@ export function makeCuesheetColumns(customFields: CustomFields): ColumnDef<Ontim
meta: { colour: customFields[key].colour }, meta: { colour: customFields[key].colour },
cell: MakeCustomField, cell: MakeCustomField,
size: 250, size: 250,
minSize: 75,
})); }));
return [ return [
@@ -111,6 +112,7 @@ export function makeCuesheetColumns(customFields: CustomFields): ColumnDef<Ontim
header: 'Cue', header: 'Cue',
cell: MakeSingleLineField, cell: MakeSingleLineField,
size: 75, size: 75,
minSize: 40,
}, },
{ {
accessorKey: 'timeStart', accessorKey: 'timeStart',
@@ -118,6 +120,7 @@ export function makeCuesheetColumns(customFields: CustomFields): ColumnDef<Ontim
header: 'Start', header: 'Start',
cell: MakeTimer, cell: MakeTimer,
size: 75, size: 75,
minSize: 75,
}, },
{ {
accessorKey: 'timeEnd', accessorKey: 'timeEnd',
@@ -125,6 +128,7 @@ export function makeCuesheetColumns(customFields: CustomFields): ColumnDef<Ontim
header: 'End', header: 'End',
cell: MakeTimer, cell: MakeTimer,
size: 75, size: 75,
minSize: 75,
}, },
{ {
accessorKey: 'duration', accessorKey: 'duration',
@@ -132,6 +136,7 @@ export function makeCuesheetColumns(customFields: CustomFields): ColumnDef<Ontim
header: 'Duration', header: 'Duration',
cell: MakeDuration, cell: MakeDuration,
size: 75, size: 75,
minSize: 75,
}, },
{ {
accessorKey: 'title', accessorKey: 'title',
@@ -139,6 +144,7 @@ export function makeCuesheetColumns(customFields: CustomFields): ColumnDef<Ontim
header: 'Title', header: 'Title',
cell: MakeSingleLineField, cell: MakeSingleLineField,
size: 250, size: 250,
minSize: 75,
}, },
{ {
accessorKey: 'note', accessorKey: 'note',
@@ -146,6 +152,7 @@ export function makeCuesheetColumns(customFields: CustomFields): ColumnDef<Ontim
header: 'Note', header: 'Note',
cell: MakeMultiLineField, cell: MakeMultiLineField,
size: 250, size: 250,
minSize: 75,
}, },
...dynamicCustomFields, ...dynamicCustomFields,
]; ];