Skip to content

Commit b1543d7

Browse files
committed
feat(mdc-menu): remove dependency on menu bar
Each MdcMenu component now functions like the canonical definition of menu in the MDC Web guides If a bar is present, it delegates control, otherwise handles events locally Signed-off-by:Vish Desai <shadyvd@hotmail.com>
1 parent 92492c3 commit b1543d7

File tree

8 files changed

+265
-447
lines changed

8 files changed

+265
-447
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,99 @@
1-
<ul
2-
class='mdc-list emdc-menu'
3-
{{! Ensure id is present - we need it for the events }}
4-
{{requires-id ignore=true}}
5-
{{! React to clicks outside the menu area}}
6-
{{not-on 'click' this.closeSubMenus}}
7-
{{! Store reference to the element for DOM manipulation }}
8-
{{store-element this.storeElement}}
9-
{{! HTML attributes added in the calling template }}
10-
...attributes
11-
>
12-
{{yield
13-
(hash
14-
Item=(component
15-
this.itemComponent
16-
menuControls=this.controls
17-
triggerEvent=this.triggerEvent
18-
xAlign=@xAlign
19-
xOffset=@xOffset
20-
yAlign=@yAlign
21-
yOffset=@yOffset
22-
equalTriggerContentWidth=@equalTriggerContentWidth
23-
palette=@palette
24-
)
25-
)
26-
}}
27-
</ul>
1+
{{! template-lint-disable no-invalid-interactive }}
2+
{{#if (has-block 'items')}}
3+
<MdcAbstractDropdown
4+
@tag='li'
5+
class='mdc-list-item overflow-visible'
6+
@customComponents={{(hash
7+
trigger=(component this.triggerComponent)
8+
content=(component this.listComponent)
9+
)}}
10+
@xAlign='left'
11+
@xOffset='0'
12+
@yAlign='bottom'
13+
@yOffset='0'
14+
@equalTriggerContentWidth={{false}}
15+
@triggerEvent={{@triggerEvent}}
16+
@palette={{@palette}}
17+
{{! Ensure id is present - we need it for the events }}
18+
{{requires-id ignore=true}}
19+
{{! React to clicks outside the menu area}}
20+
{{not-on 'click' this.notOnClick}}
21+
{{! React to trigger events }}
22+
{{on this.triggerEvent this.onTriggerEvent}}
23+
{{! Monitor changes to disabled status }}
24+
{{on-mutation
25+
this.onAttributeMutation
26+
attributeFilter=(array 'disabled')
27+
}}
28+
{{! Attach/detach event handler as necessary }}
29+
{{on-args-change this.listenToClicks this.triggerEvent}}
30+
{{! Re-calculate colours as necessary }}
31+
{{on-args-change this.recalcStyles @palette}}
32+
{{! Store reference to the element for DOM manipulation }}
33+
{{store-element this.storeElement}}
34+
{{! HTML attributes added in the calling template }}
35+
...attributes
36+
>
37+
<:trigger as |Trigger|>
38+
{{yield
39+
(component Trigger itemControls=this.itemControls)
40+
to='trigger'
41+
}}
42+
</:trigger>
43+
44+
<:content as |Content|>
45+
{{yield
46+
(component Content itemControls=this.itemControls)
47+
to='items'
48+
}}
49+
</:content>
50+
</MdcAbstractDropdown>
51+
{{else}}
52+
<li
53+
class='mdc-list-item'
54+
{{! Add styling classes as necessary }}
55+
{{has-class-if this.open 'mdc-list-item--selected'}}
56+
{{! Ensure id is present - we need it for the events }}
57+
{{requires-id ignore=true}}
58+
{{! React to clicks outside the menu area}}
59+
{{not-on 'click' this.notOnClick}}
60+
{{! React to trigger events }}
61+
{{on this.triggerEvent this.onTriggerEvent}}
62+
{{! Monitor changes to disabled status }}
63+
{{on-mutation
64+
this.onAttributeMutation
65+
attributeFilter=(array 'disabled')
66+
}}
67+
{{! Attach/detach event handler as necessary }}
68+
{{on-args-change this.listenToClicks this.triggerEvent}}
69+
{{! Re-calculate colours as necessary }}
70+
{{on-args-change this.recalcStyles @palette}}
71+
{{! Store reference to the element for DOM manipulation }}
72+
{{store-element this.storeElement}}
73+
{{! HTML attributes added in the calling template }}
74+
...attributes
75+
>
76+
<div
77+
class='ripple-container absolute inset-0 pointer-events-none overflow-hidden'
78+
>
79+
<span class='mdc-list-item__ripple'></span>
80+
</div>
81+
82+
{{#if (has-block 'icon')}}
83+
{{yield
84+
(component
85+
this.iconComponent disabled=this.disabled palette=@palette
86+
)
87+
to='icon'
88+
}}
89+
{{/if}}
90+
91+
<span class='mdc-list-item__text'>
92+
{{#if (has-block 'icon')}}
93+
{{yield to='text'}}
94+
{{else}}
95+
{{yield}}
96+
{{/if}}
97+
</span>
98+
</li>
99+
{{/if}}

0 commit comments

Comments
 (0)