MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / MenuButton

Class MenuButton

core/src/components/menu-button/menu-button.tsx:29–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 shadow: true,
28})
29export class MenuButton implements ComponentInterface, ButtonInterface {
30 private inheritedAttributes: Attributes = {};
31
32 @Element() el!: HTMLIonSegmentElement;
33
34 @State() visible = false;
35
36 /**
37 * The color to use from your application's color palette.
38 * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
39 * For more information on colors, see [theming](/docs/theming/basics).
40 */
41 @Prop({ reflect: true }) color?: Color;
42
43 /**
44 * If `true`, the user cannot interact with the menu button.
45 */
46 @Prop() disabled = false;
47
48 /**
49 * Optional property that maps to a Menu's `menuId` prop. Can also be `start` or `end` for the menu side. This is used to find the correct menu to toggle
50 */
51 @Prop() menu?: string;
52
53 /**
54 * Automatically hides the menu button when the corresponding menu is not active
55 */
56 @Prop() autoHide = true;
57
58 /**
59 * The type of the button.
60 */
61 @Prop() type: 'submit' | 'reset' | 'button' = 'button';
62
63 componentWillLoad() {
64 this.inheritedAttributes = inheritAriaAttributes(this.el);
65 }
66
67 componentDidLoad() {
68 this.visibilityChanged();
69 }
70
71 @Listen('ionMenuChange', { target: 'body' })
72 @Listen('ionSplitPaneVisible', { target: 'body' })
73 async visibilityChanged() {
74 this.visible = await updateVisibility(this.menu);
75 }
76
77 private onClick = async () => {
78 return menuController.toggle(this.menu);
79 };
80
81 render() {
82 const { color, disabled, inheritedAttributes } = this;
83 const mode = getIonMode(this);
84 const menuIcon = config.get('menuIcon', mode === 'ios' ? menuOutline : menuSharp);
85 const hidden = this.autoHide && !this.visible;
86

Callers

nothing calls this directly

Calls 1

toggleMethod · 0.65

Tested by

no test coverage detected