Skip to content
Snippets Groups Projects
Commit 1600d549 authored by Olivia206's avatar Olivia206
Browse files

Dropdown

parent aa708fa9
No related branches found
No related tags found
No related merge requests found
const CLASSES = {
DropdownOpened: 'is-opened'
};
class Dropdown {
constructor (selector) {
this.element = document.querySelector(selector);
this.dropdownButton = this.element.querySelector('button');
this.state = {
isOpened: false
};
this.listen();
}
listen () {
this.dropdownButton.addEventListener('click', () => {
this.toggleDropdown();
});
}
toggleDropdown (open = !this.state.isOpened) {
console.log('lalala')
let classAction;
this.state.isOpened = open;
classAction = this.state.isOpened ? 'add' : 'remove';
this.dropdownButton.setAttribute('aria-expanded', this.state.isOpened);
this.element.classList[classAction](CLASSES.DropdownOpened);
}
}
export default new Dropdown('.diplomas-select');
import './body.js';
import './blocks/keyFigures';
import './blocks/timeline';
import './design-system/dropdown';
import './nav/stickyNav';
// import './nav/responsive';
import './nav/mainMenu';
......@@ -27,6 +27,7 @@ ul.diplomas
.dropdown-menu
@include inset(100%, 0, auto, auto)
background-color: black
display: none
position: absolute
@include media-breakpoint-down(md)
// padding-left: $container-gutter-width
......@@ -34,8 +35,8 @@ ul.diplomas
&,
a
color: white
display: block
a
display: block
padding: $spacing0
white-space: normal
&:not(:first-child)
......@@ -45,4 +46,21 @@ ul.diplomas
&:hover
background-color: lighten(black, 3)
&:focus
color: black
\ No newline at end of file
color: black
button[aria-expanded="true"]
@include icon('caret-top', 'after')
+ .dropdown-menu
display: block
// TODO : style de l'icone
// button::after,
// button[aria-expanded="true"]::after
// display: inline-block
// font-family: Icon
// font-size: .375rem
// font-weight: 400
// line-height: 1
// margin-left: 0.3125rem
// vertical-align: middle
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment