Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add language menu (resolves #67) #148

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/assets/styles/components/_menu--home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,25 @@
color: $blue-500;
}

&[aria-current] {
&[aria-current="page"] {
color: $white;
}
}

.menu--home .menu-item--languages [aria-current]::before {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%23f9f9f7" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
}

.menu--home .menu-item--languages [aria-current]:hover::before,
.menu--home .menu-item--languages [aria-current]:focus::before {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%2316605d" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
}

.menu--home .menu-item--languages [aria-current]:active::before,
.menu--home .menu-item--languages [aria-current]:active:focus::before {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%2316605d" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
}

.menu--home .menu__submenu {
background: $blue-500;
border-color: $blue-600;
Expand Down
65 changes: 63 additions & 2 deletions src/assets/styles/components/_menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ nav {
padding: rem(13) rem(13) rem(11) rem(16);
}

&[aria-current] {
&[aria-current="page"] {
background-color: $black;
border-left-color: $red-400;

Expand All @@ -146,6 +146,44 @@ nav {
&[aria-expanded="true"] svg {
transform: rotate(180deg);
}

&[aria-expanded="true"] svg.icon--language {
transform: none;
}
}

.menu-item--languages .menu__label {
display: block;
}

.menu-item--languages .icon--language {
display: none;
}

.menu-item--languages [aria-current] {
display: block;
}

.menu-item--languages [aria-current]::before {
background-color: transparent;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%23fff" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
background-position: center;
background-repeat: no-repeat;
content: "";
display: inline-block;
height: 1em;
margin-right: rem(6);
width: 1em;
}

.menu-item--languages [aria-current]:hover::before,
.menu-item--languages [aria-current]:focus::before {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%23203131" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
}

.menu-item--languages [aria-current]:active::before,
.menu-item--languages [aria-current]:active:focus::before {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%231d7c79" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
}

.menu__submenu {
Expand Down Expand Up @@ -253,7 +291,7 @@ nav {
margin-left: rem(12);
}

&[aria-current] {
&[aria-current="page"] {
background: transparent;
border-left-color: transparent;
color: $dark-mint-500;
Expand Down Expand Up @@ -283,6 +321,29 @@ nav {
}
}

.menu-item--languages .menu__label {
display: none;
}

.menu-item--languages .icon--language {
display: block;
margin-left: 0;
}

.menu-item--languages [aria-current]::before {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%2316605d" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
}

.menu-item--languages [aria-current]:hover::before,
.menu-item--languages [aria-current]:focus::before {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%23f9f9f7" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
}

.menu-item--languages [aria-current]:active::before,
.menu-item--languages [aria-current]:active:focus::before {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10.572" height="7.742" viewBox="0 0 10.572 7.742"><path d="M.681 3.812l3.148 2.931L9.864.708" fill="none" stroke="%23f9f9f7" stroke-linejoin="round" class="stroke" stroke-width="2"/></svg>');
}

.menu__submenu {
border:
1px solid
Expand Down
8 changes: 3 additions & 5 deletions src/components/01-atoms/_svg/_svg.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ module.exports = {
context: {
icon: 'filter',
class: false,
attributes: {
ariaHidden: true,
focusable: false,
viewBox: '0 0 20 20'
}
ariaHidden: true,
focusable: false,
viewBox: '0 0 20 20'
}
};
7 changes: 4 additions & 3 deletions src/components/01-atoms/_svg/_svg.njk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<svg
class="icon icon--{{ class if class else svg }}"
{% for attribute, value in attributes %}
{{ attribute | replace('ariaHidden', 'aria-hidden') }}="{{ value }}"
{% endfor %}>
aria-hidden="{{ ariaHidden }}"
viewBox="{{ viewBox }}"
focusable="{{ focusable }}"
>
<use href="/images/{{ svg }}.svg#{{ svg }}"/>
</svg>
2 changes: 1 addition & 1 deletion src/components/02-molecules/00-menu/menu.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = {
label: 'Submenu Item Three'
}
}
},
}
},
},
variants: [
Expand Down
15 changes: 15 additions & 0 deletions src/components/02-molecules/00-menu/menu.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,20 @@
{% endif %}
</li>
{% endfor %}
<li class="menu-item menu-item--languages menu__submenu-wrapper">
<a class="menu__item" href="/en/settings/language/">
<span class="menu__label">Language</span>
{% render '@svg', {svg:'language', class:'language icon--lg', viewBox: '0 0 30 30'}, true %}
</a>
<ul class="menu__submenu">
<li class="menu-item"><a aria-current="true" href="/en/" class="menu__item">English</a></li>
<li class="menu-item"><a href="/pt/" class="menu__item">Português</a></li>
<li class="menu-item"><a href="/sv/" class="menu__item">Svenska</a></li>
<li class="menu-item"><a href="/it/" class="menu__item">Italiano</a></li>
<li class="menu-item"><a href="/es/" class="menu__item">Español</a></li>
<li class="menu-item"><a href="/fr/" class="menu__item">Français</a></li>
<li class="menu-item"><a href="/de/" class="menu__item">Deutsch</a></li>
</ul>
</li>
</ul>
</nav>