1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Added deprecatation comment to menu.js file and Add deprecation notice to storybook (#20622)

This commit is contained in:
Subhajit Ghosh 2023-08-29 08:01:19 +05:30 committed by GitHub
parent b6ad074b9a
commit 877e184b29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 12 deletions

View File

@ -4,6 +4,15 @@ import { createPortal } from 'react-dom';
import { usePopper } from 'react-popper'; import { usePopper } from 'react-popper';
import classnames from 'classnames'; import classnames from 'classnames';
/**
* @deprecated The `<Menu />` component has been deprecated in favor of the new `<Popover>` component from the component-library.
* Please update your code to use the new `<Popover>` component instead, which can be found at ui/components/component-library/popover/popover.tsx.
* You can find documentation for the new `Popover` component in the MetaMask Storybook:
* {@link https://metamask.github.io/metamask-storybook/?path=/docs/components-componentlibrary-popover--docs}
* If you would like to help with the replacement of the old `Menu` component, please submit a pull request against this GitHub issue:
* {@link https://github.com/MetaMask/metamask-extension/issues/20498}
*/
const Menu = ({ const Menu = ({
anchorElement, anchorElement,
children, children,

View File

@ -1,23 +1,43 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { action } from '@storybook/addon-actions'; import { action } from '@storybook/addon-actions';
import { IconName } from '../../component-library'; import PropTypes from 'prop-types';
import { IconName, BannerAlert } from '../../component-library';
import { Severity } from '../../../helpers/constants/design-system';
import { Menu, MenuItem } from '.'; import { Menu, MenuItem } from '.';
export default { export default {
title: 'Components/UI/Menu', title: 'Components/UI/Menu',
}; };
const Deprecated = ({ children }) => (
<>
<BannerAlert
severity={Severity.Warning}
title="Deprecated"
description="<Menu/> has been deprecated in favor of <Popover/>"
marginBottom={4}
/>
{children}
</>
);
Deprecated.propTypes = {
children: PropTypes.node,
};
export const DefaultStory = () => { export const DefaultStory = () => {
return ( return (
<Menu onHide={action('Hide')}> <Deprecated>
<MenuItem iconName={IconName.Eye} onClick={action('Menu Item 1')}> <Menu onHide={action('Hide')}>
Menu Item 1 <MenuItem iconName={IconName.Eye} onClick={action('Menu Item 1')}>
</MenuItem> Menu Item 1
<MenuItem onClick={action('Menu Item 2')}>Menu Item 2</MenuItem> </MenuItem>
<MenuItem iconName={IconName.EyeSlash} onClick={action('Menu Item 3')}> <MenuItem onClick={action('Menu Item 2')}>Menu Item 2</MenuItem>
Menu Item 3 <MenuItem iconName={IconName.EyeSlash} onClick={action('Menu Item 3')}>
</MenuItem> Menu Item 3
</Menu> </MenuItem>
</Menu>
</Deprecated>
); );
}; };
@ -26,7 +46,7 @@ DefaultStory.storyName = 'Default';
export const Anchored = () => { export const Anchored = () => {
const [anchorElement, setAnchorElement] = useState(null); const [anchorElement, setAnchorElement] = useState(null);
return ( return (
<> <Deprecated>
<button ref={setAnchorElement}>Menu</button> <button ref={setAnchorElement}>Menu</button>
<Menu anchorElement={anchorElement} onHide={action('Hide')}> <Menu anchorElement={anchorElement} onHide={action('Hide')}>
<MenuItem iconName={IconName.Export} onClick={action('Menu Item 1')}> <MenuItem iconName={IconName.Export} onClick={action('Menu Item 1')}>
@ -43,6 +63,6 @@ export const Anchored = () => {
Disabled Item Disabled Item
</MenuItem> </MenuItem>
</Menu> </Menu>
</> </Deprecated>
); );
}; };