style: align with the ep-corporate-design skill
This commit is contained in:
1 parent
50ef662dd3
commit
ebad54e989
162 files changed
+768
-640
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
|
||||
/*
|
||||
* The sidebar as a drawer on small screens: a modal <dialog> (target "dialog"), so focus stays inside
|
||||
* and Escape closes it. A click on the dimmed page beside it closes it too, and so does widening the
|
||||
* window until the sidebar shows (lg).
|
||||
*/
|
||||
export default class extends Controller {
|
||||
static targets = ['dialog']
|
||||
|
||||
connect () {
|
||||
this.wide = window.matchMedia('(min-width: 64rem)')
|
||||
this.onWide = (event) => event.matches && this.close()
|
||||
this.wide.addEventListener('change', this.onWide)
|
||||
}
|
||||
|
||||
disconnect () {
|
||||
this.wide.removeEventListener('change', this.onWide)
|
||||
}
|
||||
|
||||
open () {
|
||||
this.dialogTarget.showModal()
|
||||
}
|
||||
|
||||
close () {
|
||||
this.dialogTarget.close()
|
||||
}
|
||||
|
||||
// a click on the dialog element itself, not on its content, is a click on the backdrop
|
||||
closeOnBackdrop (event) {
|
||||
if (event.target === this.dialogTarget) {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
|
||||
export default class extends Controller {
|
||||
static outlets = [ 'mobilenav' ]
|
||||
static classes = [ 'closed' ]
|
||||
|
||||
trigger({ params: { mode } }) {
|
||||
this.mobilenavOutlet.toggle(mode)
|
||||
}
|
||||
|
||||
toggle(mode) {
|
||||
// Add animation classes only now to avoid fouc
|
||||
this.element.classList.add('transition-transform', 'duration-300')
|
||||
this.element.classList.toggle(this.closedClass, 'close' === mode)
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
|
||||
export default class extends Controller {
|
||||
|
||||
static classes = ['closed', 'iconClosed', 'iconExpanded']
|
||||
static targets = ['submenu', 'button', 'icon']
|
||||
static values = { expanded: Boolean }
|
||||
|
||||
toggleSubmenu() {
|
||||
this.expandedValue = !this.expandedValue
|
||||
}
|
||||
|
||||
expandedValueChanged(expanded) {
|
||||
this.submenuTarget.classList.toggle(this.closedClass, false === expanded)
|
||||
if (false === this.hasButtonTarget) {
|
||||
return
|
||||
}
|
||||
this.buttonTarget.setAttribute('aria-expanded', expanded)
|
||||
if (false === this.hasIconTarget) {
|
||||
return
|
||||
}
|
||||
if (true === expanded) {
|
||||
this.iconTarget.classList.add(...this.iconExpandedClasses)
|
||||
this.iconTarget.classList.remove(...this.iconClosedClasses)
|
||||
} else {
|
||||
this.iconTarget.classList.add(...this.iconClosedClasses)
|
||||
this.iconTarget.classList.remove(...this.iconExpandedClasses)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user