Skip to content

Commit

Permalink
feat(AsideHeader): add onMenuMoreClick
Browse files Browse the repository at this point in the history
  • Loading branch information
yndx-madfriend committed Oct 8, 2024
1 parent ec47a35 commit aafc3cb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/AsideHeader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export const Aside: FC = () => {
| onChangeCompact | Callback will be called when changing navigation visual state | `(compact: boolean) => void;` | |
| onClosePanel | Callback will be called when closing panel. You can add panels via `PanelItems` prop | `() => void;` | |
| onMenuItemsChanged | Callback will be called when updating list of the menuItems in `AllPagesPanel` | `(items: Array<MenuItem>) => void` | |
| onMenuMoreClick | Callback will be called when some items don't fit and "more" button is clicked | `() => void;` | |
| openModalSubscriber | Function notifies `AsideHeader` about Modals visibility changes | `( (open: boolean) => void) => void` | |
| panelItems | Items for `Drawer` component. Used for show additional information over main content | [`Array<DrawerItem>`](./../Drawer/README.md#draweritem-props) | `[]` |
| renderContent | Function rendering the main content at the right of the `AsideHeader` | `(data: {size: number}) => React.ReactNode` | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const AdvancedUsageTemplate: StoryFn = (args) => {
'aria-label': 'Service',
}}
onChangeCompact={setCompact}
onMenuMoreClick={() => alert('onMenuMoreClick')}
qa={'pl-aside'}
{...args}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/AsideHeader/components/FirstPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const FirstPanel = React.forwardRef<HTMLDivElement>((_props, ref) => {
headerDecoration,
multipleTooltip,
menuMoreTitle,
onMenuMoreClick,
renderFooter,
compact,
customBackground,
Expand Down Expand Up @@ -53,6 +54,7 @@ export const FirstPanel = React.forwardRef<HTMLDivElement>((_props, ref) => {
items={visibleMenuItems}
menuMoreTitle={menuMoreTitle ?? i18n('label_more')}
onItemClick={onItemClick}
onMoreClick={onMenuMoreClick}
multipleTooltip={multipleTooltip}
/>
) : (
Expand Down
1 change: 1 addition & 0 deletions src/components/AsideHeader/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface AsideHeaderGeneralProps extends QAProps {
}) => React.ReactNode;
onClosePanel?: () => void;
onChangeCompact?: (compact: boolean) => void;
onMenuMoreClick?: () => void;
openModalSubscriber?: (subscriber: OpenModalSubscriber) => void;
}

Expand Down
7 changes: 6 additions & 1 deletion src/components/CompositeBar/CompositeBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type CompositeBarProps = CompositeBarItems & {
) => void;
multipleTooltip?: boolean;
menuMoreTitle?: string;
onMoreClick?: () => void;
};

type CompositeBarViewProps = CompositeBarProps & {
Expand All @@ -49,6 +50,7 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
type,
items,
onItemClick,
onMoreClick,
collapseItems,
multipleTooltip = false,
}) => {
Expand Down Expand Up @@ -215,6 +217,7 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
onMouseEnter={onMouseEnterByIndex(itemIndex)}
onMouseLeave={onMouseLeave}
onItemClick={onItemClickByIndex(itemIndex)}
onCollapseItemClick={onMoreClick}
collapseItems={collapseItems}
/>
);
Expand All @@ -238,6 +241,7 @@ export const CompositeBar: FC<CompositeBarProps> = ({
items,
menuMoreTitle,
onItemClick,
onMoreClick,
multipleTooltip = false,
}) => {
if (items.length === 0) {
Expand All @@ -247,7 +251,7 @@ export const CompositeBar: FC<CompositeBarProps> = ({

if (type === 'menu') {
const minHeight = getItemsMinHeight(items);
const collapseItem = getMoreButtonItem(menuMoreTitle);
const collapseItem = getMoreButtonItem(menuMoreTitle, onMoreClick);
node = (
<div className={b({autosizer: true})} style={{minHeight}}>
{items.length !== 0 && (
Expand All @@ -267,6 +271,7 @@ export const CompositeBar: FC<CompositeBarProps> = ({
type="menu"
items={listItems}
onItemClick={onItemClick}
onMoreClick={onMoreClick}
collapseItems={collapseItems}
multipleTooltip={multipleTooltip}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/components/CompositeBar/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface ItemProps extends ItemPopup {
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
) => void;
onItemClickCapture?: (event: React.SyntheticEvent) => void;
onCollapseItemClick?: () => void;
bringForward?: boolean;
}

Expand Down Expand Up @@ -85,6 +86,7 @@ export const Item: React.FC<ItemInnerProps> = (props) => {
onClosePopup,
onItemClick,
onItemClickCapture,
onCollapseItemClick,
bringForward,
} = props;

Expand Down Expand Up @@ -172,6 +174,7 @@ export const Item: React.FC<ItemInnerProps> = (props) => {
* - onClosePanel calls twice for each popuped item, as result it will prevent opening of panelItems
*/
toggleOpen(!open);
onCollapseItemClick?.();
} else {
onItemClick?.(item, false, event);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface MenuItem extends QAProps {
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
) => void;
onItemClickCapture?: (event: React.SyntheticEvent) => void;
onCollapseItemClick?: () => void;
itemWrapper?: (
p: MakeItemParams,
makeItem: (p: MakeItemParams) => React.ReactNode,
Expand Down

0 comments on commit aafc3cb

Please sign in to comment.