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

fix(DatatableV2): make header sticky in settings panel #1161

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
183 changes: 95 additions & 88 deletions src/components/DatatableV2/panels/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,102 +157,109 @@ const Settings = <D,>({ table }: { table: DatatableInstance<D> }) => {

return (
<SettingsRoot className="ds-table-settings-panel">
<Padbox
as="header"
paddingSize="mdPlus"
style={{ borderBottom: '1px solid var(--sscds-border-color' }}
>
<Inline align="center" gap="md" justify="space-between">
<Inline align="center" gap="md">
<Icon name="columns-3" />
<Text isBold>{t('sscds|datatable.settings.title')}</Text>
</Inline>
<CloseButton
ariaLabel={t('sscds|datatable.settings.close')}
marginCompensation="md"
onClose={() => setShowColumnSettings(false)}
/>
</Inline>
</Padbox>
<Padbox
paddingSize="md"
<div
style={{
overflow: 'auto',
position: 'sticky',
top: datatable?.settingsOffset ?? 0,
}}
>
<Stack gap="md">
<Inline
gap="sm"
stretch="start"
style={{ paddingRight: 'var(--sscds-space-2x)' }}
>
<div>
<Button
size="sm"
variant="subtle"
onClick={() => {
setColumnPinning(initialState.columnPinning ?? {});
setColumnVisibility(initialState.columnVisibility ?? {});
setColumnOrder(initialState.columnOrder ?? []);
}}
>
{t('sscds|datatable.settings.reset')}
</Button>
</div>
<Inline gap="sm" stretch="all">
{enableHiding && (
<Stack gap="1x" justify="center">
<Icon name="eye" size="md" hasFixedSize />
<div className="ds-table-checkbox-wrapper">
<IndeterminateCheckbox
aria-label={
getColumnsVisibilityInfo().areAllColumnsVisible
? t('sscds|datatable.settings.hiding.hideAll')
: t('sscds|datatable.settings.hiding.showAll')
}
checked={getColumnsVisibilityInfo().areAllColumnsVisible}
indeterminate={
getColumnsVisibilityInfo().areSomeColumnsVisible
}
onChange={(e) =>
handleToggleAllColumnsVisibility(e.target.checked)
}
/>
</div>
</Stack>
)}
{enableColumnPinning && (
<Stack gap="1x" justify="center">
<Icon name="thumbtack" size="md" hasFixedSize />
<div className="ds-table-checkbox-wrapper">
<IndeterminateCheckbox
aria-label={
getColumnsPinnabilityInfo().areAllColumnsPinned
? t('sscds|datatable.settings.pinnig.unpinAll')
: t('sscds|datatable.settings.pinnig.pinAll')
}
checked={getColumnsPinnabilityInfo().areAllColumnsPinned}
indeterminate={
getColumnsPinnabilityInfo().areSomeColumnsPinned
}
onChange={(e) =>
handleToggleAllColumnsPinnability(e.target.checked)
}
/>
</div>
</Stack>
)}
<Padbox
as="header"
paddingSize="mdPlus"
style={{
borderBottom: '1px solid var(--sscds-border-color',
}}
>
<Inline align="center" gap="md" justify="space-between">
<Inline align="center" gap="md">
<Icon name="columns-3" />
<Text isBold>{t('sscds|datatable.settings.title')}</Text>
</Inline>
<CloseButton
ariaLabel={t('sscds|datatable.settings.close')}
marginCompensation="md"
onClose={() => setShowColumnSettings(false)}
/>
</Inline>
<SettingsItems
allColumns={allColumns}
canHideMoreColumns={canHideMoreColumns}
table={table}
/>
</Stack>
</Padbox>
</Padbox>
<Padbox paddingSize="md" style={{}}>
<Stack gap="md">
<Inline
gap="sm"
stretch="start"
style={{ paddingRight: 'var(--sscds-space-2x)' }}
>
<div>
<Button
size="sm"
variant="subtle"
onClick={() => {
setColumnPinning(initialState.columnPinning ?? {});
setColumnVisibility(initialState.columnVisibility ?? {});
setColumnOrder(initialState.columnOrder ?? []);
}}
>
{t('sscds|datatable.settings.reset')}
</Button>
</div>
<Inline gap="sm" stretch="all">
{enableHiding && (
<Stack gap="1x" justify="center">
<Icon name="eye" size="md" hasFixedSize />
<div className="ds-table-checkbox-wrapper">
<IndeterminateCheckbox
aria-label={
getColumnsVisibilityInfo().areAllColumnsVisible
? t('sscds|datatable.settings.hiding.hideAll')
: t('sscds|datatable.settings.hiding.showAll')
}
checked={
getColumnsVisibilityInfo().areAllColumnsVisible
}
indeterminate={
getColumnsVisibilityInfo().areSomeColumnsVisible
}
onChange={(e) =>
handleToggleAllColumnsVisibility(e.target.checked)
}
/>
</div>
</Stack>
)}
{enableColumnPinning && (
<Stack gap="1x" justify="center">
<Icon name="thumbtack" size="md" hasFixedSize />
<div className="ds-table-checkbox-wrapper">
<IndeterminateCheckbox
aria-label={
getColumnsPinnabilityInfo().areAllColumnsPinned
? t('sscds|datatable.settings.pinnig.unpinAll')
: t('sscds|datatable.settings.pinnig.pinAll')
}
checked={
getColumnsPinnabilityInfo().areAllColumnsPinned
}
indeterminate={
getColumnsPinnabilityInfo().areSomeColumnsPinned
}
onChange={(e) =>
handleToggleAllColumnsPinnability(e.target.checked)
}
/>
</div>
</Stack>
)}
</Inline>
</Inline>
<SettingsItems
allColumns={allColumns}
canHideMoreColumns={canHideMoreColumns}
table={table}
/>
</Stack>
</Padbox>
</div>
</SettingsRoot>
);
};
Expand Down
Loading