Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <p>A collapsible is a component to mark expandable and collapsible regions. |
| 2 | It has states, roles, attributes and behavior in accordance with guidelines given in |
| 3 | <a href="https://www.w3.org/WAI/GL/wiki/Using_the_WAI-ARIA_aria-expanded_state_to_mark_expandable_and_collapsible_regions"> |
| 4 | Using the WAI-ARIA aria-expanded state to mark expandable and collapsible regions |
| 5 | </a>. |
| 6 | </p> |
| 7 | <article> |
| 8 | <button class="mdlext-js-collapsible" style="padding: 8px;"> |
| 9 | <span>Click to toggle (button)</span> |
| 10 | <i class="mdlext-aria-expanded-more-less"></i> |
| 11 | </button> |
| 12 | <div class="mdlext-collapsible-group"><p>A collapsible region #1.1</p></div> |
| 13 | <div class="mdlext-collapsible-group"><p>A collapsible region #1.2</p></div> |
| 14 | <div class="mdlext-collapsible-group"><p>A collapsible region #1.3</p></div> |
| 15 | </article> |
| 16 | |
| 17 | <article style="margin-top: 16px;"> |
| 18 | <div class="mdlext-js-collapsible mdlext-collapsible" style="padding: 8px;"> |
| 19 | <span>Click to toggle (div)</span> |
| 20 | <i class="mdlext-aria-expanded-more-less"></i> |
| 21 | </div> |
| 22 | <div class="mdlext-collapsible-region"><p>A collapsible region #2.1</p></div> |
| 23 | <div class="mdlext-collapsible-region"><p>A collapsible region #2.2</p></div> |
| 24 | <div class="mdlext-collapsible-region"><p>A collapsible region #2.3</p></div> |
| 25 | </article> |
| 26 | |
| 27 | |
| 28 | <style> |
| 29 | .mdl-card.demo-card, |
| 30 | .mdl-card.welcome-card { |
| 31 | min-height: 0; |
| 32 | width: auto; |
| 33 | margin-top: 16px; |
| 34 | margin-bottom: 16px; |
| 35 | max-width: 640px; |
| 36 | } |
| 37 | .mdl-card.demo-card .mdl-card__media, |
| 38 | .mdl-card.welcome-card .mdl-card__media { |
| 39 | margin: 0; |
| 40 | text-align: center; |
| 41 | } |
| 42 | .mdl-card.demo-card .mdl-card__media > img, |
| 43 | .mdl-card.welcome-card .mdl-card__media > img { |
| 44 | max-width: 100%; |
| 45 | height: auto; |
| 46 | } |
| 47 | .mdl-card.demo-card .mdl-card__title, |
| 48 | .mdl-card.welcome-card .mdl-card__title { |
| 49 | /* Fix bug in _card.scss */ |
| 50 | -webkit-box-pack: start; |
| 51 | -webkit-justify-content: flex-start; |
| 52 | -ms-flex-pack: start; |
| 53 | justify-content: flex-start; |
| 54 | /* end fix */ |
| 55 | |
| 56 | padding-top: 0; |
| 57 | padding-bottom: 0; |
| 58 | min-height: 64px; |
| 59 | } |
| 60 | .mdl-card.demo-card .mdl-card__title:focus, |
| 61 | .mdl-card.welcome-card .mdl-card__title:focus { |
| 62 | /* Must focus ring must be inside title since mdl-card has overflow:hidden */ |
| 63 | outline-offset: -4px; |
| 64 | } |
| 65 | .mdl-card.demo-card .mdl-card__title > *, |
| 66 | .mdl-card.welcome-card .mdl-card__title > * { |
| 67 | -webkit-align-self: center; |
| 68 | -ms-flex-item-align: center; |
| 69 | align-self: center; |
| 70 | } |
| 71 | .mdl-card.demo-card .mdl-card__supporting-text, |
| 72 | .mdl-card.welcome-card .mdl-card__supporting-text { |
| 73 | width: auto; |
| 74 | } |
| 75 | .mdl-card.demo-card .mdl-card__actions, |
| 76 | .mdl-card.welcome-card .mdl-card__actions { |
| 77 | display: -webkit-box; |
| 78 | display: -webkit-flex; |
| 79 | display: -ms-flexbox; |
| 80 | display: flex; |
| 81 | } |
| 82 | .welcome-card > .mdl-card__title { |
| 83 | color: #fff; |
| 84 | height: 176px; |
| 85 | background: url('./assets/welcome_card.jpg') top / cover; |
| 86 | } |
| 87 | .welcome-card > .mdl-card__title[aria-expanded='false'] { |
| 88 | height: 64px; |
| 89 | } |
| 90 | .welcome-card > .mdl-card__title .mdl-card__title-text { |
| 91 | -webkit-align-self: flex-end; |
| 92 | -ms-flex-item-align: end; |
| 93 | align-self: flex-end; |
| 94 | padding-bottom: 16px; |
| 95 | } |
| 96 | .welcome-card > .mdl-card__title[aria-expanded='false'] .mdl-card__title-text { |
| 97 | -webkit-align-self: center; |
| 98 | -ms-flex-item-align: center; |
| 99 | align-self: center; |
| 100 | padding-bottom: 0; |
| 101 | } |
| 102 | .welcome-card > .mdl-card__menu { |
| 103 | color: #fff; |
| 104 | } |
| 105 | |
| 106 | table.info { |
| 107 | width: 100% |
| 108 | } |
| 109 | table.info th { |
| 110 | padding-right: 40px; |
| 111 | vertical-align: middle; |
| 112 | text-align: left; |
| 113 | width: 120px; |
| 114 | } |
| 115 | </style> |
| 116 | |
| 117 | <div class="welcome-card mdl-card mdl-shadow--2dp"> |
| 118 | <header class="mdl-card__title mdlext-js-collapsible mdlext-collapsible" aria-expanded="true"> |
| 119 | <h2 class="mdl-card__title-text">A Collapsible Card</h2> |
| 120 | </header> |
| 121 | <section class="mdl-card__supporting-text mdlext-collapsible-group"> |
| 122 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. |
| 123 | Mauris sagittis pellentesque lacus eleifend lacinia... |
| 124 | </section> |
| 125 | <footer class="mdl-card__actions mdl-card--border mdlext-collapsible-group"> |
| 126 | <button class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect"> |
| 127 | Get Started |
| 128 | </button> |
| 129 | </footer> |
| 130 | <div class="mdl-card__menu"> |
| 131 | <button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"> |
| 132 | <i class="material-icons">share</i> |
| 133 | </button> |
| 134 | </div> |
| 135 | </div> |
| 136 | |
| 137 | |
| 138 | <style> |
| 139 | .mdlext-collapsible-group .mdlext-js-collapsible, |
| 140 | .mdlext-collapsible-group .mdlext-collapsible-group { |
| 141 | margin-left: 16px; |
| 142 | } |
| 143 | </style> |
| 144 | |
| 145 | <button class="mdlext-js-collapsible mdl-button mdl-button--colored mdl-button--raised">Click to toggle</button> |
| 146 | <div class="mdlext-collapsible-group"> |
| 147 | <p>A collapsible region</p> |
| 148 | |
| 149 | <button class="mdlext-js-collapsible mdl-button mdl-button--accent mdl-button--raised">Click to toggle nested #1</button> |
| 150 | <div class="mdlext-collapsible-group"> |
| 151 | <p>A nested collapsible region</p> |
| 152 | |
| 153 | <button class="mdlext-js-collapsible mdl-button mdl-button--colored mdl-color--deep-orange-100 mdl-button--raised">Click to toggle nested #2</button> |
| 154 | <div class="mdlext-collapsible-group"> |
| 155 | <p>Last region</p> |
| 156 | </div> |
| 157 | </div> |
| 158 | </div> |
| 159 | |
| 160 | |
| 161 | <div id="another-card" class="mdl-card demo-card mdl-shadow--2dp mdlext-dark-color-theme"> |
| 162 | <header class="mdl-card__title mdl-color--primary mdl-color-text--primary-contrast mdlext-js-collapsible mdlext-collapsible"> |
| 163 | <button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"> |
| 164 | <i class="material-icons">view_headline</i> |
| 165 | </button> |
| 166 | <h2 class="mdl-card__title-text">Another collapsible card</h2> |
| 167 | <div class="mdl-layout-spacer"></div> |
| 168 | <i class="material-icons md-36 mdlext-aria-expanded-more-less"></i> |
| 169 | </header> |
| 170 | <figure class="mdl-card__media mdlext-collapsible-region"> |
| 171 | <img src="./images/_DSC7535-2.jpg" alt=""> |
| 172 | </figure> |
| 173 | <section style="margin-top:16px" class="mdl-card__supporting-text mdlext-collapsible-region"> |
| 174 | <table class="info"> |
| 175 | <tr> |
| 176 | <th class="mdl-typography--caption-color-contrast">primary-dark</th> |
| 177 | <td class="mdl-color--primary-dark mdl-color-text--primary-contrast">primary dark</td> |
| 178 | </tr> |
| 179 | <tr> |
| 180 | <th class="mdl-typography--caption-color-contrast">primary</th> |
| 181 | <td class="mdl-color--primary mdl-color-text--primary-contrast">primary</td> |
| 182 | </tr> |
| 183 | <tr> |
| 184 | <th class="mdl-typography--caption-color-contrast">accent</th> |
| 185 | <td class="mdl-color--accent mdl-color-text--accent-contrast">accent</td> |
| 186 | </tr> |
| 187 | <tr> |
| 188 | <th class="mdl-typography--caption-color-contrast">primary-dark</th> |
| 189 | <td class="mdl-color--primary-contrast mdl-color-text--primary-dark">primary dark, inverted</td> |
| 190 | </tr> |
| 191 | <tr> |
| 192 | <th class="mdl-typography--caption-color-contrast">primary</th> |
| 193 | <td class="mdl-color--primary-contrast mdl-color-text--primary">primary, inverted</td> |
| 194 | </tr> |
| 195 | <tr> |
| 196 | <th class="mdl-typography--caption-color-contrast">accent</th> |
| 197 | <td class="mdl-color--accent-contrast mdl-color-text--accent">accent, inverted</td> |
| 198 | </tr> |
| 199 | </table> |
| 200 | </section> |
| 201 | |
| 202 | <div class="mdl-card__supporting-text mdlext-collapsible-region"> |
| 203 | Card Supporting Text |
| 204 | </div> |
| 205 | |
| 206 | <footer class="mdl-card__actions mdl-card--border"> |
| 207 | <button id="read-more" class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect"> |
| 208 | Read more |
| 209 | </button> |
| 210 | <div class="mdl-layout-spacer"></div> |
| 211 | <button class="mdl-button mdl-button--icon"><i class="material-icons">radio</i></button> |
| 212 | <button class="mdl-button mdl-button--icon mdl-button--colored"><i class="material-icons">favorite</i></button> |
| 213 | <button class="mdl-button mdl-button--icon mdl-button--colored"><i class="material-icons">share</i></button> |
| 214 | </footer> |
| 215 | </div> |
| 216 | |
| 217 | |
| 218 | |
| 219 | <script> |
| 220 | (function() { |
| 221 | 'use strict'; |
| 222 | window.addEventListener('load', function() { |
| 223 | |
| 224 | document.querySelector('#read-more').addEventListener('click', function (e) { |
| 225 | var collapsible = document.querySelector('#another-card .mdlext-js-collapsible'); |
| 226 | collapsible.MaterialExtCollapsible.expand(); |
| 227 | }); |
| 228 | |
| 229 | document.querySelector('#another-card').addEventListener('toggle', function (e) { |
| 230 | console.log('Toggle action:', e.detail.action); |
| 231 | }); |
| 232 | |
| 233 | }); |
| 234 | |
| 235 | }()); |
| 236 | |
| 237 | </script> |