diff --git a/packages/ui/src/components/Checkbox/index.tsx b/packages/ui/src/components/Checkbox/index.tsx index 35fec24e12..24592695ac 100644 --- a/packages/ui/src/components/Checkbox/index.tsx +++ b/packages/ui/src/components/Checkbox/index.tsx @@ -400,49 +400,51 @@ export const Checkbox = forwardRef( ) : null} - - - {children ? ( - <> - {typeof children === 'string' ? ( - - {children} - - ) : ( - {children} - )} - + {!!children || required || !!helper || !!error ? ( + + + {children ? ( + <> + {typeof children === 'string' ? ( + + {children} + + ) : ( + {children} + )} + + ) : null} + {required ? ( + + + + ) : null} + + + {helper ? ( + + {helper} + ) : null} - {required ? ( - - - + + {error && typeof error !== 'boolean' ? ( + + {error} + ) : null} - - {helper ? ( - - {helper} - - ) : null} - - {error && typeof error !== 'boolean' ? ( - - {error} - - ) : null} - + ) : null} ) diff --git a/packages/ui/src/components/List/HeaderRow.tsx b/packages/ui/src/components/List/HeaderRow.tsx index 862e5fd7d5..d7094f63ab 100644 --- a/packages/ui/src/components/List/HeaderRow.tsx +++ b/packages/ui/src/components/List/HeaderRow.tsx @@ -3,7 +3,7 @@ import type { ReactNode } from 'react' import { Checkbox } from '../Checkbox' import { HeaderCell } from './HeaderCell' import { useListContext } from './ListContext' -import { SELECTABLE_CHECKBOX_SIZE } from './constants' +import { EXPANDABLE_COLUMN_SIZE, SELECTABLE_CHECKBOX_SIZE } from './constants' const StyledHeaderRow = styled.tr` /* List itself also apply style about common templating between HeaderRow and other Rows */ @@ -27,14 +27,20 @@ const StyledHeaderRow = styled.tr` } ` -const NoPaddingHeaderCell = styled(HeaderCell)` +const SelectRowHeaderCell = styled(HeaderCell)` padding: 0; + padding-left: ${({ theme }) => theme.space['2']}; - &:first-of-type { - padding-left: ${({ theme }) => theme.space['2']}; - } + width: ${({ theme }) => theme.sizing[SELECTABLE_CHECKBOX_SIZE]}; + min-width: ${({ theme }) => theme.sizing[SELECTABLE_CHECKBOX_SIZE]}; +` + +const ExpandableHeaderCell = styled(HeaderCell)` + padding: 0; + padding-left: ${({ theme }) => theme.space['2']}; - max-width: ${({ theme }) => theme.sizing[SELECTABLE_CHECKBOX_SIZE]} + width: ${({ theme }) => theme.sizing[EXPANDABLE_COLUMN_SIZE]}; + min-width: ${({ theme }) => theme.sizing[EXPANDABLE_COLUMN_SIZE]}; ` type RowProps = { @@ -52,7 +58,7 @@ export const HeaderRow = ({ children, hasSelectAllColumn }: RowProps) => { {hasSelectAllColumn ? ( - + { onChange={selectAllHandler} disabled={selectableRowCount === 0} /> - + ) : null} {expandButton ? ( - {null} + {null} ) : null} {children} diff --git a/packages/ui/src/components/List/Row.tsx b/packages/ui/src/components/List/Row.tsx index c82edd3138..a841129bf3 100644 --- a/packages/ui/src/components/List/Row.tsx +++ b/packages/ui/src/components/List/Row.tsx @@ -1,4 +1,3 @@ -import { useTheme } from '@emotion/react' import styled from '@emotion/styled' import type { ReactNode } from 'react' import { @@ -15,7 +14,7 @@ import { Checkbox } from '../Checkbox' import { Tooltip } from '../Tooltip' import { Cell } from './Cell' import { useListContext } from './ListContext' -import { SELECTABLE_CHECKBOX_SIZE } from './constants' +import { EXPANDABLE_COLUMN_SIZE, SELECTABLE_CHECKBOX_SIZE } from './constants' import type { ColumnProps } from './types' const ExpandableWrapper = styled.tr` @@ -167,18 +166,20 @@ const StyledCheckboxContainer = styled.div` display: flex; ` -const NoPaddingCell = styled(Cell, { - shouldForwardProp: prop => !['maxWidth'].includes(prop), -})<{ - maxWidth: string -}>` +const SelectRowCell = styled(Cell)` padding: 0; + padding-left: ${({ theme }) => theme.space['2']}; - &:first-of-type { - padding-left: ${({ theme }) => theme.space['2']}; - } + width: ${({ theme }) => theme.sizing[SELECTABLE_CHECKBOX_SIZE]}; + min-width: ${({ theme }) => theme.sizing[SELECTABLE_CHECKBOX_SIZE]}; +` - max-width: ${({ maxWidth }) => maxWidth}; +const ExpandableButtonCell = styled(Cell)` + padding: 0; + padding-left: ${({ theme }) => theme.space['2']}; + + width: ${({ theme }) => theme.sizing[EXPANDABLE_COLUMN_SIZE]}; + min-width: ${({ theme }) => theme.sizing[EXPANDABLE_COLUMN_SIZE]}; ` const ExpandableCell = styled(Cell, { @@ -236,8 +237,6 @@ export const Row = forwardRef( columns, } = useListContext() - const theme = useTheme() - const expandedRowId = useId() const checkboxRef = useRef(null) @@ -321,10 +320,7 @@ export const Row = forwardRef( columnsStartAt={(selectable ? 1 : 0) + (expandButton ? 1 : 0)} > {selectable ? ( - + ( /> - + ) : null} {expandButton ? ( - +