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

feat(AsideHeader): add onAllPagesClick callback #329

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/components/AsideHeader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const Aside: FC = () => {
| 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;` | |
| onAllPagesClick | Callback will be called when "All pages" 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 @@ -72,7 +72,7 @@
const openModalCount = data?.meta?.layers?.filter(
({type}) => type === 'modal',
).length;
callback(openModalCount !== 0);

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

View workflow job for this annotation

GitHub Actions / Verify Files

Expected return with your callback function
}
});
};
Expand Down Expand Up @@ -163,7 +163,7 @@
multipleTooltip={multipleTooltip}
openModalSubscriber={openModalSubscriber}
topAlert={topAlert}
renderFooter={({compact, asideRef}) => (

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

View workflow job for this annotation

GitHub Actions / Verify Files

'compact' is already declared in the upper scope on line 62 column 12
<React.Fragment>
<FooterItem
compact={compact}
Expand Down Expand Up @@ -295,7 +295,8 @@
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
onAllPagesClick={() => console.log('onAllPagesClick')}

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

View workflow job for this annotation

GitHub Actions / Verify Files

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const EMPTY_MENU_ITEMS: MenuItem[] = [];
export const useAsideHeaderInnerContextValue = (
props: AsideHeaderProps & {size: number},
): AsideHeaderInnerContextType => {
const {size, onClosePanel, menuItems, panelItems, onMenuItemsChanged} = props;
const {size, onClosePanel, menuItems, panelItems, onMenuItemsChanged, onAllPagesClick} = props;
const [innerVisiblePanel, setInnerVisiblePanel] = useState<InnerPanels | undefined>();
const ALL_PAGES_MENU_ITEM = React.useMemo(() => {
return getAllPagesMenuItem();
Expand Down Expand Up @@ -59,10 +59,11 @@ export const useAsideHeaderInnerContextValue = (
{
...ALL_PAGES_MENU_ITEM,
current: innerVisiblePanel === InnerPanels.AllPages,
onItemClick: onAllPagesClick,
},
]
: menuItems || EMPTY_MENU_ITEMS,
[allPagesIsAvailable, menuItems, innerVisiblePanel, ALL_PAGES_MENU_ITEM],
[allPagesIsAvailable, menuItems, innerVisiblePanel, ALL_PAGES_MENU_ITEM, onAllPagesClick],
);

const innerPanelItems = useMemo(() => {
Expand Down
Loading