Last active
September 13, 2018 07:29
-
-
Save vasilionjea/b1f94c70709e222102f45b423b2cc4d8 to your computer and use it in GitHub Desktop.
Epxand a11y accordion panel dynamically via DOM event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
isValid: false, | |
actions: { | |
submit() { | |
if (this.get('isValid') === false) { | |
this._openFirstPanel(); | |
} | |
}, | |
}, | |
_openFirstPanel() { | |
Ember.run.scheduleOnce('afterRender', () => { | |
const firstItem = document.querySelector('.first-item'); | |
const firstHeader = document.querySelector('.first-header'); | |
const isOpen = firstItem.classList.contains('a11y-accordion-item--is-expanded'); | |
if (!isOpen) { | |
firstHeader.click(); | |
} | |
}); | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
small { | |
font-size: 1.125rem; | |
vertical-align: middle; | |
} | |
input, | |
textarea { | |
width: 100%; | |
padding: .325rem; | |
} | |
.a11y-accordion-header__trigger, | |
.a11y-accordion-panel-content { | |
padding: 1rem; | |
} | |
.a11y-accordion-header__trigger { | |
border-bottom: 1px dashed lightgray; | |
} | |
.field { margin-top: 1rem; } | |
.field:first-child { margin-top: 0; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.2.2", | |
"ember-template-compiler": "3.2.2", | |
"ember-testing": "3.2.2" | |
}, | |
"addons": { | |
"ember-a11y-accordion": "1.0.7" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment