-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assets/userindicator: update template, add styles and js functionalit…
…y for new user indicator
- Loading branch information
Showing
12 changed files
with
166 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### Added | ||
|
||
- new user indicator for user side pages with custom js functionality mimicing the language dropdown functionality from the BO stylguide useing our own vanilla js #7840 |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
function init () { | ||
const userIndicator = document.querySelectorAll('#js-user-indicator') | ||
if (userIndicator) { | ||
let closeTimeout | ||
const trigger = document.querySelector('#js-user-indicator-trigger') | ||
const dropdown = document.querySelector('#js-user-indicator-dropdown') | ||
const close = document.querySelector('#js-user-indicator-close') | ||
const container = document.querySelector('#js-user-indicator') | ||
|
||
function closeDropdown () { | ||
document.removeEventListener('click', outsideClickListener) | ||
dropdown.style.display = 'none' | ||
container.classList.remove('is-open') | ||
trigger.setAttribute('aria-expanded', false) | ||
clearTimeout(closeTimeout) | ||
} | ||
|
||
function openDropdown () { | ||
if (container.classList.contains('is-open')) { | ||
closeDropdown() | ||
} else { | ||
dropdown.style.display = 'block' | ||
container.classList.add('is-open') | ||
trigger.setAttribute('aria-expanded', true) | ||
|
||
document.addEventListener('click', outsideClickListener) | ||
} | ||
} | ||
|
||
function outsideClickListener (e) { | ||
if (!container.contains(e.target) && e.target !== close) { | ||
closeDropdown() | ||
} | ||
} | ||
|
||
trigger.addEventListener('click', function (event) { | ||
event.preventDefault() | ||
openDropdown() | ||
}) | ||
|
||
close.addEventListener('click', function (event) { | ||
event.stopPropagation() // Prevent the event from bubbling up to the document | ||
closeDropdown() | ||
}) | ||
|
||
dropdown.addEventListener('keyup', function (e) { | ||
if (e.keyCode === 27) { | ||
closeDropdown() | ||
trigger.focus() | ||
} | ||
}) | ||
|
||
dropdown.addEventListener('focusout', function (e) { | ||
closeTimeout = setTimeout(function () { | ||
if (!dropdown.contains(e.relatedTarget)) { | ||
closeDropdown() | ||
} | ||
}, 10) | ||
}) | ||
} | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', init, false) |
This file contains 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
This file contains 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
File renamed without changes.
62 changes: 62 additions & 0 deletions
62
meinberlin/assets/scss/components_user_facing/_user_indicator.scss
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// styles copied from their stylguide from #layout-grid__area--contentheader | ||
.user-indicator__container { | ||
grid-area: contentheader; | ||
grid-column: mainbar; | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
z-index: 1; | ||
|
||
&:before { | ||
position: absolute; | ||
background-color: $secondary; | ||
inset: 0 0 0 -9999px; | ||
display: block; | ||
content: ""; | ||
z-index: -1; | ||
box-shadow: 9999px 0 0 $secondary; | ||
border-left: 9999px solid $secondary; | ||
} | ||
|
||
button { | ||
padding: .5em 0; | ||
} | ||
|
||
[role="menu"] { | ||
display: none; | ||
} | ||
|
||
[aria-expanded="true"] + [role="menu"] { | ||
display: block; | ||
} | ||
|
||
// end of copied styling | ||
|
||
.user-indicator__wrapper { | ||
@extend .content-language-select; | ||
|
||
color: var(--color-white); | ||
|
||
> .dropdown .button { | ||
width: 100%; | ||
} | ||
|
||
// copied styles | ||
@media print, (width <= 73.8125rem) { | ||
margin-left: -12px; | ||
margin-right: -12px; | ||
width: auto; | ||
padding-left: 12px; | ||
padding-right: 12px | ||
} | ||
} | ||
} | ||
|
||
.button--close.user-indicator__close { | ||
text-align: end; | ||
min-height: auto; | ||
|
||
&:after { | ||
font-size: 1em; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
{% block header %} | ||
{% endblock %} | ||
{% block menu %}{% endblock %} | ||
|
||
{% block content %} | ||
|
||
|
This file contains 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