Skip to content

Commit

Permalink
feat(Footer): add callback for footer more button click (#239)
Browse files Browse the repository at this point in the history
Co-authored-by: kseniyakuzina <kseniyakuzina@yandex-team.ru>
  • Loading branch information
kseniya57 and kseniyakuzina authored May 16, 2024
1 parent e25e08d commit 9fdf655
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
21 changes: 11 additions & 10 deletions src/components/Footer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ Both components have the same properties.

### PropTypes

| Property | Type | Required | Default | Description |
| :--------------------------------------------------------------------------------------- | :------------------ | :------: | :------ | :---------------------------- |
| className | `String` | | | Footer class name |
| [menuItems](https://github.com/gravity-ui/uikit/tree/main/src/components/Menu) | `FooterMenuItem[]` | | | List of footer menu items |
| withDivider | `Boolean` | | | Show top border on the footer |
| moreButtonTitle | `String` | | | The more items button title |
| [view](#view) | `normal` or `clear` | | | The footer view |
| [logo](https://preview.gravity-ui.com/navigation/?path=/story/components-logo--showcase) | `LogoProps` | | | The service logo properties |
| logoWrapperClassName | `string` | | | The logo wrapper class name |
| copyright | `string` | | | The copyright |
| Property | Type | Required | Default | Description |
| :--------------------------------------------------------------------------------------- | :------------------------------- | :------: | :------ | :---------------------------- |
| className | `String` | | | Footer class name |
| [menuItems](https://github.com/gravity-ui/uikit/tree/main/src/components/Menu) | `FooterMenuItem[]` | | | List of footer menu items |
| withDivider | `Boolean` | | | Show top border on the footer |
| moreButtonTitle | `String` | | | The more items button title |
| onMoreButtonClick | `MouseEventHandler<HTMLElement>` | | | The more button click handler |
| [view](#view) | `normal` or `clear` | | | The footer view |
| [logo](https://preview.gravity-ui.com/navigation/?path=/story/components-logo--showcase) | `LogoProps` | | | The service logo properties |
| logoWrapperClassName | `string` | | | The logo wrapper class name |
| copyright | `string` | | | The copyright |

### view

Expand Down
2 changes: 2 additions & 0 deletions src/components/Footer/desktop/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const Footer: FC<FooterProps> = ({
menuItems: providedMenuItems,
withDivider,
moreButtonTitle,
onMoreButtonClick,
view = 'normal',
logo,
logoWrapperClassName,
Expand Down Expand Up @@ -80,6 +81,7 @@ export const Footer: FC<FooterProps> = ({
switcherWrapperClassName={b('more-button')}
popupProps={moreItemsPopupProps}
defaultSwitcherProps={moreButtonProps}
onSwitcherClick={onMoreButtonClick}
/>
)}
</div>
Expand Down
11 changes: 8 additions & 3 deletions src/components/Footer/mobile/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const MobileFooter: FC<FooterProps> = ({
menuItems: providedMenuItems,
withDivider,
moreButtonTitle,
onMoreButtonClick,
view = 'normal',
logo,
logoWrapperClassName,
Expand All @@ -29,9 +30,13 @@ export const MobileFooter: FC<FooterProps> = ({
const [moreItemsMenuVisible, setMoreItemsMenuVisible] = useState(false);
const menuContainerRef = useRef<HTMLDivElement>(null);

const handleOpenMoreItemsMenu = useCallback(() => {
setMoreItemsMenuVisible(true);
}, []);
const handleOpenMoreItemsMenu = useCallback(
(event) => {
setMoreItemsMenuVisible(true);
onMoreButtonClick?.(event);
},
[onMoreButtonClick],
);

const handleCloseMoreItemsMenu = useCallback(() => {
setMoreItemsMenuVisible(false);
Expand Down
3 changes: 2 additions & 1 deletion src/components/Footer/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ReactNode} from 'react';
import {MouseEventHandler, ReactNode} from 'react';

import {MenuItemProps} from '@gravity-ui/uikit';

Expand All @@ -13,6 +13,7 @@ export type FooterProps = {
menuItems?: FooterMenuItem[];
withDivider?: boolean;
moreButtonTitle?: string;
onMoreButtonClick?: MouseEventHandler<HTMLElement>;
view?: 'normal' | 'clear';
logo?: LogoProps;
logoWrapperClassName?: string;
Expand Down

0 comments on commit 9fdf655

Please sign in to comment.