Skip to content

Commit

Permalink
feat(DataTableControls): add number of hidden columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnau-mnau committed Jul 25, 2023
1 parent 3b284d5 commit dc684da
Show file tree
Hide file tree
Showing 41 changed files with 32 additions and 15 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/Datatable/BatchModule/BatchModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const BatchModule: React.FC<BatchModuleProps> = ({
}}
>
<ControlButton
iconName={SSCIconNames.reorder}
label="Columns"
iconName={SSCIconNames.table}
label="Toggle columns"
onClick={() => {
setIsColumnsActive((prev) => !prev);
}}
Expand Down
23 changes: 13 additions & 10 deletions src/components/Datatable/ControlsModule/ControlsModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,19 @@ function ControlsModule<D extends Record<string, unknown>>({
)
}
>
<ControlButton
iconName={SSCIconNames.table}
label="Columns"
onClick={() =>
handleControlOnClick(
ControlTypes.columns,
controlsState[ControlTypes.columns].isActive,
)
}
/>
{(props) => (
<ControlButton
iconName={SSCIconNames.table}
label="Toggle columns"
onClick={() =>
handleControlOnClick(
ControlTypes.columns,
controlsState[ControlTypes.columns].isActive,
)
}
{...props}
/>
)}
</ColumnsControls>
)}
{shouldShowFiltering && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ const ColumnsControls: React.FC<ColumnsControlsProps> = ({

return (
<span ref={parentRef}>
{children}
{typeof children === 'function'
? children({ hiddenColumns: hiddenColumns.length })
: children}
<ControlDropdown
isOpen={isOpen}
parentRef={parentRef}
title="Columns"
title="Toggle columns"
onClose={handleCloseColumnsControl}
onReset={handleResetColumnsControl}
onSubmit={handleApplyColumnsControl}
Expand Down Expand Up @@ -103,6 +105,7 @@ const ColumnsControls: React.FC<ColumnsControlsProps> = ({
};

ColumnsControls.propTypes = {
children: PropTypes.oneOf(PropTypes.func, PropTypes.node).isRequired,
onClose: PropTypes.func.isRequired,
onApply: PropTypes.func.isRequired,
isOpen: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
interface RenderProps {
hiddenColumns: number;
}

export interface ColumnsControlsProps {
isOpen?: boolean;
onOpen: () => void;
onClose: () => void;
onApply: (shouldApply: boolean) => void;
onReset?: () => void;
children: React.ReactNode | ((obj: RenderProps) => React.ReactNode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Default: Story<ControlButtonProps> = (args) => (
<Padbox paddingSize="sm">
<Inline align="center" gap="mdPlus">
<ControlButton {...args} />
<ControlButton {...args} appliedFilters={4} />
<ControlButton {...args} hiddenColumns={4} />
</Inline>
</Padbox>
<Padbox paddingSize="sm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ControlButton: React.FC<ControlButtonProps> = ({
appliedFilters = 0,
className = '',
onClick,
hiddenColumns = 0,
}) => (
<Button
className={className}
Expand All @@ -26,6 +27,9 @@ const ControlButton: React.FC<ControlButtonProps> = ({
<Inline align="center" gap="sm">
<span>{label}</span>
{appliedFilters > 0 && <Badge count={appliedFilters} variant="neutral" />}
{hiddenColumns > 0 && (
<Badge text={`${hiddenColumns} hidden`} variant="neutral" />
)}
</Inline>
</Button>
);
Expand All @@ -35,6 +39,7 @@ ControlButton.propTypes = {
iconName: PropTypes.oneOf<SSCIcons>(Object.values(SSCIconNames)).isRequired,
onClick: PropTypes.func.isRequired,
appliedFilters: PropTypes.number,
hiddenColumns: PropTypes.number,
className: PropTypes.string,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface ControlButtonProps {
label: string;
iconName: SSCIcons;
appliedFilters?: number;
hiddenColumns?: number;
onClick: () => void;
className?: string;
}

0 comments on commit dc684da

Please sign in to comment.