Skip to content

Commit

Permalink
feat(AsideHeader): add onMenuMoreClick (#320)
Browse files Browse the repository at this point in the history
* feat(AsideHeader): add onMenuMoreClick
  • Loading branch information
yndx-madfriend authored Oct 11, 2024
1 parent 114a0d0 commit d0569a5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
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 @@ -295,6 +295,7 @@ export const AsideHeaderShowcase: React.FC<AsideHeaderShowcaseProps> = ({
onChangeCompact={(v) => {
setCompact(v);
}}
onMenuMoreClick={() => console.log('onMenuMoreClick')}

Check warning on line 298 in src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Unexpected console statement
/>
</div>
);
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 @@ -44,6 +44,7 @@ export interface AsideHeaderGeneralProps extends QAProps {
editMenuProps?: EditMenuProps;
onClosePanel?: () => void;
onChangeCompact?: (compact: boolean) => void;
onMenuMoreClick?: () => void;
openModalSubscriber?: (subscriber: OpenModalSubscriber) => void;
}

Expand Down
5 changes: 5 additions & 0 deletions 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 Down Expand Up @@ -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 d0569a5

Please sign in to comment.