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

Web 3133 pill nav component #550

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
15 changes: 13 additions & 2 deletions src/components/blocks/toggle-nav/_toggle-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if (toggleNav) {

Array.from(toggleNavBtns, (tog) => {
const tnToggees = document.querySelectorAll(tog.dataset.toggeesSelector);
const isDarkVariation = toggleNav.parentElement.classList.contains('b-toggle-nav--dark');

tog.addEventListener('click', (e) => {
e.preventDefault();
Expand All @@ -29,10 +30,20 @@ if (toggleNav) {
return true;
});
Array.from(toggleNavBtns, (el) => {
el.classList.remove('b-toggle-nav__button--active');
if (isDarkVariation) {
el.classList.add('u-btn--pill-dark');
} else {
el.classList.add('u-btn--pill-light');
el.classList.remove('u-btn--pill-darkest');
}
return true;
});
tog.classList.add('b-toggle-nav__button--active');
if (isDarkVariation) {
tog.classList.remove('u-btn--pill-dark');
} else {
tog.classList.remove('u-btn--pill-light');
tog.classList.add('u-btn--pill-darkest');
}
}, false);

if (tog.dataset.toggleType === qsToggleType) {
Expand Down
64 changes: 19 additions & 45 deletions src/components/blocks/toggle-nav/_toggle-nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
@use "../../base";

.b-toggle-nav {
background-color: base.sitecolors-siteColor("vam-white");
box-shadow: 0 1px 2px base.sitecolors-siteColor("vam-grey-4");
margin: 0 0 32px;
margin: 0 0 32px 5px;
overflow: hidden;
position: relative;

Expand All @@ -16,62 +14,38 @@
padding: 0 40px;
}

&::after {
background: linear-gradient(to right, rgba(255, 255, 255, 0%), #fff 23px);
content: " ";
display: block;
height: 100%;
position: absolute;
right: 0;
top: 0;
width: 40px;
}

&__list {
@include mixins.unstyledelements-unstyledList;

text-align: center;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
padding: 4px 0;
scroll-behavior: smooth;
scroll-snap-type: x mandatory;

@include mixins.breakpoints-bpMinSmall {
justify-content: center;
}

&::-webkit-scrollbar {
display: none;
}
}

.cssscrollbar & {
overflow: auto;
white-space: nowrap;
}
&__button {
margin: 6px 5px;
white-space: nowrap;
}

&__item {
display: inline-block;
margin: 0;
padding: 0 10px;
}

&__button {
@include base.typography-typeSetting(4);
@include mixins.unstyledelements-unstyledInput;

border-bottom: 3px solid transparent;
color: base.sitecolors-siteColor("vam-black");
cursor: pointer;
padding: 15px 10px 12px;

@include mixins.breakpoints-bpMinXSmall {
padding: 25px 15px 22px;
}

&--active,
&:hover {
border-color: base.sitecolors-siteColor("vam-grey-2");
}

&:hover {
color: base.sitecolors-siteColor("vam-grey-2");
}
scroll-snap-align: center;
scroll-snap-stop: normal;

&:focus {
@include mixins.focus-insetFocus;
&:last-child {
margin-right: 5px;
}
}
}
16 changes: 13 additions & 3 deletions src/components/blocks/toggle-nav/toggle-nav.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
title: 'Toggle Nav',
label: 'Toggle Nav',
default: 'on-light',
context: {
previewClass: 'fr-bg--dark',
modifier: ['light'],
toggles: [
'Galleries',
'Periods and styles',
Expand All @@ -11,5 +11,15 @@ module.exports = {
'Materials and techniques',
'Places'
]
}
},
variants: [
{
name: 'on-dark',
label: 'On dark',
context: {
previewClass: 'fr-bg--dark',
modifier: ['dark']
}
}
]
};
4 changes: 2 additions & 2 deletions src/components/blocks/toggle-nav/toggle-nav.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<nav class="b-toggle-nav">
<nav class="b-toggle-nav{% if modifier %} b-toggle-nav--{{ modifier }}{% endif %}">
<ol class="b-toggle-nav__list js-toggle-nav" data-toggle-type-default="type-3">
{% for toggle in toggles %}
<li class="b-toggle-nav__item">
<button class="b-toggle-nav__button js-toggle-nav-btn" data-toggle-type="type-{{ loop.index }}" data-toggees-selector=".my-toggleables-common-class" aria-label="Only show: {{ toggle }}">
<button class="u-btn u-btn--pill {% if modifier %} u-btn--pill-{{ modifier }}{% endif %} b-toggle-nav__button js-toggle-nav-btn" data-toggle-type="type-{{ loop.index }}" data-toggees-selector=".my-toggleables-common-class" aria-label="Only show: {{ toggle }}">
{{ toggle }}
</button>
</li>
Expand Down
20 changes: 19 additions & 1 deletion src/components/units/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
@include base.typography-fontSize(2);
@include base.typography-lineheight(2);

background: base.sitecolors-siteColor("vam-grey-6");
background: base.sitecolors-siteColor("vam-white");
border: none;
border-radius: 30px;
color: base.sitecolors-siteColor("vam-black");
Expand All @@ -131,6 +131,15 @@
background: base.sitecolors-siteColor("vam-grey-5");
}

&-light {
background: base.sitecolors-siteColor("vam-grey-6");
color: base.sitecolors-siteColor("vam-black");

&:hover {
background: base.sitecolors-siteColor("vam-grey-4");
}
}

&-dark {
background: base.sitecolors-siteColor("vam-grey-2");
color: base.sitecolors-siteColor("vam-white");
Expand All @@ -140,6 +149,15 @@
}
}

&-darkest {
background: base.sitecolors-siteColor("vam-black");
color: base.sitecolors-siteColor("vam-white");

&:hover {
background: base.sitecolors-siteColor("vam-grey-0");
}
}

&-close {
display: inline-flex;
gap: 10px;
Expand Down
6 changes: 5 additions & 1 deletion src/components/units/button/button.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ module.exports = {
modifiers: ['pill'],
variants: [
['pill', 'pill-close'],
['pill', 'pill-light'],
['pill', 'pill-light', 'pill-close'],
['pill', 'pill-dark'],
['pill', 'pill-dark', 'pill-close']
['pill', 'pill-dark', 'pill-close'],
['pill', 'pill-darkest'],
['pill', 'pill-darkest', 'pill-close']
]
}
}
Expand Down