Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Updates types and null to undefined in toolbar-group
  • Loading branch information
margolisj committed Sep 14, 2023
commit 4ab80d2e3820153d8db029eb0a3f18d212b6d696
2 changes: 1 addition & 1 deletion packages/components/src/toolbar/toolbar-group/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function ToolbarGroup( {
containerClassName={
indexOfSet > 0 && indexOfControl === 0
? 'has-left-divider'
: null
: undefined
}
{ ...control }
/>
Expand Down
104 changes: 79 additions & 25 deletions packages/components/src/toolbar/toolbar-group/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import type { ReactNode } from 'react';
/**
* Internal dependencies
*/
import type { DropdownOption } from '../../dropdown-menu/types';
import type {
DropdownMenuProps,
DropdownOption,
} from '../../dropdown-menu/types';

export type ToolbarGroupControls = DropdownOption & {
/**
Expand All @@ -15,44 +18,95 @@ export type ToolbarGroupControls = DropdownOption & {
subscript?: string;
};

export type ToolbarGroupProps = {
type ToolbarGroupPropsBase = {
/**
* The controls to render in this toolbar.
*/
controls?: ToolbarGroupControls[];

/**
* Any other things to render inside the toolbar besides the controls.
*/
children?: ReactNode;
controls?: ToolbarGroupControls[] | ToolbarGroupControls[][];

/**
* Class to set on the container div.
*/
className?: string;

/**
* Turns ToolbarGroup into a dropdown menu.
*/
isCollapsed?: boolean;

/**
* ARIA label for dropdown menu if is collapsed.
* Any other things to render inside the toolbar besides the controls.
*/
title?: string;
children?: ReactNode;
};

export type ToolbarGroupCollapsedProps = Omit< ToolbarGroupProps, 'props' > & {
/**
* Props to be passed to the drop down.
*/
toggleProps?: Record< string, any >;
// export type ToolbarGroupProps = {
// /**
// * The controls to render in this toolbar.
// */
// controls?: ToolbarGroupControls[] | ToolbarGroupControls[][];

/**
* Props to be passed.
*/
props?: any;
};
// /**
// * Any other things to render inside the toolbar besides the controls.
// */
// children?: ReactNode;

// /**
// * Class to set on the container div.
// */
// className?: string;

// /**
// * Turns ToolbarGroup into a dropdown menu.
// */
// isCollapsed?: boolean;

// /**
// * ARIA label for dropdown menu if is collapsed.
// */
// title?: string;

// // TODO: Looks like this was needed, should the group be sharing other props?
// icon?: string;
// };

export type ToolbarGroupProps = ToolbarGroupPropsBase &
(
| {
/**
* When true, turns `ToolbarGroup` into a dropdown menu.
*/
isCollapsed?: false;
/**
* Any other things to render inside the toolbar besides the controls.
*/
children?: ReactNode;
title?: never;
}
| {
/**
* When true, turns `ToolbarGroup` into a dropdown menu.
*/
isCollapsed: true;
/**
* Any other things to render inside the toolbar besides the controls.
*/
children?: ToolbarGroupCollapsedProps[ 'children' ];
/**
* ARIA label for dropdown menu if is collapsed.
*/
title: string;
}
);

// export type ToolbarGroupCollapsedProps = ToolbarGroupProps & {
// /**
// * Props to be passed to the drop down.
// */
// toggleProps?: Record< string, any >;

// /**
// * Props to be passed.
// */
// props?: any;
// };

export type ToolbarGroupCollapsedProps = DropdownMenuProps;

export type ToolbarGroupContainerProps = {
/**
Expand Down