@@ -24,17 +24,18 @@ export interface StoryKnobs {
2424 supportingText : string ;
2525}
2626
27- function clickHandler ( event : Event ) {
27+ function showDialog ( event : Event ) {
2828 ( ( event . target as Element ) . nextElementSibling as MdDialog ) ?. show ( ) ;
2929}
3030
31-
3231const standard : MaterialStoryInit < StoryKnobs > = {
33- name : 'Standard ' ,
32+ name : 'Dialog ' ,
3433 render ( { icon, headline, supportingText} ) {
3534 return html `
36- < md-filled-button @click =${ clickHandler } > Open</ md-filled-button >
37- < md-dialog >
35+ < md-filled-button @click =${ showDialog }
36+ aria-label ="Open a dialog"> Open</ md-filled-button >
37+
38+ < md-dialog aria-label =${ headline ? nothing : 'A simple dialog' } >
3839 ${ icon ? html `< md-icon slot ="icon "> ${ icon } </ md-icon > ` : nothing }
3940 < div slot ="headline "> ${ headline } </ div >
4041 < form id ="form " slot ="content " method ="dialog ">
@@ -53,7 +54,9 @@ const alert: MaterialStoryInit<StoryKnobs> = {
5354 name : 'Alert' ,
5455 render ( ) {
5556 return html `
56- < md-filled-button @click =${ clickHandler } > Open</ md-filled-button >
57+ < md-filled-button @click =${ showDialog }
58+ aria-label ="Open an alert dialog"> Alert</ md-filled-button >
59+
5760 < md-dialog type ="alert ">
5861 < div slot ="headline "> Alert dialog</ div >
5962 < form id ="form " slot ="content " method ="dialog ">
@@ -72,16 +75,20 @@ const confirm: MaterialStoryInit<StoryKnobs> = {
7275 name : 'Confirm' ,
7376 render ( ) {
7477 return html `
75- < md-filled-button @click =${ clickHandler } > Open</ md-filled-button >
78+ < md-filled-button @click =${ showDialog }
79+ aria-label ="Open a confirmation dialog"> Confirm</ md-filled-button >
80+
7681 < md-dialog style ="max-width: 320px; ">
7782 < div slot ="headline "> Permanently delete?</ div >
7883 < md-icon slot ="icon "> delete_outline</ md-icon >
7984 < form id ="form " slot ="content " method ="dialog ">
80- Deleting the selected photos will also remove them from all synced devices.
85+ Deleting the selected photos will also remove them from all synced
86+ devices.
8187 </ form >
8288 < div slot ="actions ">
8389 < md-text-button form ="form " value ="delete "> Delete</ md-text-button >
84- < md-filled-tonal-button autofocus form ="form " value ="cancel "> Cancel</ md-filled-tonal-button >
90+ < md-filled-tonal-button form ="form " value ="cancel "
91+ autofocus > Cancel</ md-filled-tonal-button >
8592 </ div >
8693 </ md-dialog >
8794 ` ;
@@ -93,23 +100,29 @@ const choose: MaterialStoryInit<StoryKnobs> = {
93100 styles : css `
94101 label {
95102 display: flex;
96- gap: 8px;
97103 align-items: center;
98104 }
99- ` ,
105+ ` ,
100106 render ( ) {
101107 return html `
102- < md-filled-button @click =${ clickHandler } > Open</ md-filled-button >
108+ < md-filled-button @click =${ showDialog }
109+ aria-label ="Open a choice dialog"> Choice</ md-filled-button >
110+
103111 < md-dialog >
104112 < div slot ="headline "> Choose your favorite pet</ div >
105113 < form id ="form " slot ="content " method ="dialog ">
106- < div >
107- This is a standard choice dialog. These dialogs give users the ability to make
108- a decision and confirm it. This gives them a chance to change their minds if necessary.
109- </ div >
110- < label > < md-radio name ="pet " value ="cats " touch-target ="wrapper " checked > </ md-radio > Cats</ label >
111- < label > < md-radio name ="pet " value ="dogs " touch-target ="wrapper "> </ md-radio > Dogs</ label >
112- < label > < md-radio name ="pet " value ="birds " touch-target ="wrapper "> </ md-radio > Birds</ label >
114+ < label >
115+ < md-radio name ="pet " value ="cats " aria-label ="Cats " touch-target ="wrapper " checked > </ md-radio >
116+ < span aria-hidden ="true "> Cats</ span >
117+ </ label >
118+ < label >
119+ < md-radio name ="pet " value ="dogs " aria-label ="Dogs " touch-target ="wrapper "> </ md-radio >
120+ < span aria-hidden ="true "> Dogs</ span >
121+ </ label >
122+ < label >
123+ < md-radio name ="pet " value ="birds " aria-label ="Birds " touch-target ="wrapper "> </ md-radio >
124+ < span aria-hidden ="true "> Birds</ span >
125+ </ label >
113126 </ form >
114127 < div slot ="actions ">
115128 < md-text-button form ="form " value ="cancel "> Cancel</ md-text-button >
@@ -121,7 +134,7 @@ const choose: MaterialStoryInit<StoryKnobs> = {
121134} ;
122135
123136const contacts : MaterialStoryInit < StoryKnobs > = {
124- name : 'Contacts ' ,
137+ name : 'Form ' ,
125138 styles : css `
126139 .contacts {
127140 min-width: calc(100vw - 212px);
@@ -148,13 +161,16 @@ const contacts: MaterialStoryInit<StoryKnobs> = {
148161
149162 .contact-row > * {
150163 flex: 1;
151- }` ,
164+ }
165+ ` ,
152166 render ( ) {
153167 return html `
154- < md-filled-button @click =${ clickHandler } > Open</ md-filled-button >
168+ < md-filled-button @click =${ showDialog }
169+ aria-label ="Open a form dialog"> Form</ md-filled-button >
170+
155171 < md-dialog class ="contacts ">
156172 < span slot ="headline ">
157- < md-icon-button form ="form " value ="close ">
173+ < md-icon-button form ="form " value ="close " aria-label =" Close dialog " >
158174 < md-icon > close</ md-icon >
159175 </ md-icon-button >
160176 < span class ="headline "> Create new contact</ span >
@@ -172,6 +188,8 @@ const contacts: MaterialStoryInit<StoryKnobs> = {
172188 < md-filled-text-field label ="Phone "> </ md-filled-text-field >
173189 </ form >
174190 < div slot ="actions ">
191+ < md-text-button form ="form " value ="reset " type ="reset "> Reset</ md-text-button >
192+ < div style ="flex: 1 "> </ div >
175193 < md-text-button form ="form " value ="cancel "> Cancel</ md-text-button >
176194 < md-text-button form ="form " value ="save "> Save</ md-text-button >
177195 </ div >
@@ -184,11 +202,17 @@ const floatingSheet: MaterialStoryInit<StoryKnobs> = {
184202 name : 'Floating sheet' ,
185203 render ( ) {
186204 return html `
187- < md-filled-button @click =${ clickHandler } > Open</ md-filled-button >
205+ < md-filled-button
206+ @click =${ showDialog }
207+ aria-label ="Open a floating sheet"
208+ >
209+ Floating sheet
210+ </ md-filled-button >
211+
188212 < md-dialog >
189213 < span slot ="headline ">
190214 < span style ="flex: 1; "> Floating Sheet</ span >
191- < md-icon-button form ="form " value ="close ">
215+ < md-icon-button form ="form " value ="close " aria-label =" Close dialog " >
192216 < md-icon > close</ md-icon >
193217 </ md-icon-button >
194218 </ span >
0 commit comments