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(ToggleButton): Sbanken styling #2936

Merged
merged 11 commits into from
Nov 29, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: 'ToggleButton'
description: 'The ToggleButton component should be used to toggle on or off a limited number of choices.'
showTabs: true
theme: 'sbanken'
---

import ToggleButtonInfo from 'Docs/uilib/components/toggle-button/info'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
--checkbox-color-border-on: var(--sb-color-violet);
--checkbox-color-border-off: var(--sb-color-violet);
// Disabled state
--checkbox-color-gfx--disabled: var(--sb-color-gray-dark-2-neutral);
--checkbox-color-gfx--disabled: var(--sb-color-gray-dark);
--checkbox-color-background-on--disabled: var(--sb-color-gray-light);
--checkbox-color-background-off-disabled: var(--sb-color-gray-light);
--checkbox-color-border-on--disabled: var(
--sb-color-gray-dark-2-neutral
);
--checkbox-color-border-off--disabled: var(
--sb-color-gray-dark-2-neutral
);
--checkbox-color-background-off--disabled: var(--sb-color-gray-light);
--checkbox-color-border-on--disabled: var(--sb-color-gray-dark);
--checkbox-color-border-off--disabled: var(--sb-color-gray-dark);
// Active state
--checkbox-color-background--active: var(--sb-color-white);
--checkbox-color-border--active: var(--sb-color-gray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2985,6 +2985,7 @@ button .dnb-form-status__text {
--radio-color-background-off: white;
--radio-color-border-off: black;
--radio-color-dot-on--disabled: lightgrey;
--radio-color-background--disabled: white;
--radio-color-border-on--disabled: lightgrey;
--radio-color-border-off--disabled: lightgrey;
--radio-color-dot-on--active: lightgrey;
Expand Down Expand Up @@ -3208,12 +3209,14 @@ html[data-whatinput=keyboard] .dnb-radio__focus {
}
.dnb-radio__input[disabled]:checked ~ .dnb-radio__button, .dnb-radio__input[disabled][data-checked=true] ~ .dnb-radio__button {
border-color: var(--radio-color-border-on--disabled);
background-color: var(--radio-color-background--disabled);
}
.dnb-radio__input[disabled]:checked ~ .dnb-radio__dot, .dnb-radio__input[disabled][data-checked=true] ~ .dnb-radio__dot {
background-color: var(--radio-color-dot-on--disabled);
}
.dnb-radio__input[disabled]:not(:checked):not([data-checked=true]) ~ .dnb-radio__button:not(.dnb-skeleton) {
border-color: var(--radio-color-border-off--disabled);
background-color: var(--radio-color-background--disabled);
}
.dnb-radio__input[disabled] ~ .dnb-radio__button.dnb-skeleton {
border-color: var(--skeleton-color);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ button .dnb-form-status__text {
--radio-color-background-off: white;
--radio-color-border-off: black;
--radio-color-dot-on--disabled: lightgrey;
--radio-color-background--disabled: white;
--radio-color-border-on--disabled: lightgrey;
--radio-color-border-off--disabled: lightgrey;
--radio-color-dot-on--active: lightgrey;
Expand Down Expand Up @@ -382,12 +383,14 @@ html[data-whatinput=keyboard] .dnb-radio__focus {
}
.dnb-radio__input[disabled]:checked ~ .dnb-radio__button, .dnb-radio__input[disabled][data-checked=true] ~ .dnb-radio__button {
border-color: var(--radio-color-border-on--disabled);
background-color: var(--radio-color-background--disabled);
}
.dnb-radio__input[disabled]:checked ~ .dnb-radio__dot, .dnb-radio__input[disabled][data-checked=true] ~ .dnb-radio__dot {
background-color: var(--radio-color-dot-on--disabled);
}
.dnb-radio__input[disabled]:not(:checked):not([data-checked=true]) ~ .dnb-radio__button:not(.dnb-skeleton) {
border-color: var(--radio-color-border-off--disabled);
background-color: var(--radio-color-background--disabled);
}
.dnb-radio__input[disabled] ~ .dnb-radio__button.dnb-skeleton {
border-color: var(--skeleton-color);
Expand Down Expand Up @@ -471,6 +474,7 @@ exports[`Radio scss have to match default theme snapshot 1`] = `
--radio-color-background-off: var(--color-white);
--radio-color-border-off: var(--color-sea-green);
--radio-color-dot-on--disabled: var(--color-sea-green-30);
--radio-color-background--disabled: var(--color-white);
--radio-color-border-on--disabled: var(--color-sea-green-30);
--radio-color-border-off--disabled: var(--color-mint-green-50);
--radio-color-dot-on--active: var(--color-mint-green-50);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
--radio-color-border-off: black;
// Disabled state
--radio-color-dot-on--disabled: lightgrey;
--radio-color-background--disabled: white;
--radio-color-border-on--disabled: lightgrey;
--radio-color-border-off--disabled: lightgrey;
// Active state
Expand Down Expand Up @@ -321,6 +322,7 @@
&__input[disabled]:checked ~ &__button,
&__input[disabled][data-checked='true'] ~ &__button {
border-color: var(--radio-color-border-on--disabled);
background-color: var(--radio-color-background--disabled);
}

&__input[disabled]:checked ~ &__dot,
Expand All @@ -332,6 +334,7 @@
&__input[disabled]:not(:checked):not([data-checked='true'])
~ &__button:not(.dnb-skeleton) {
border-color: var(--radio-color-border-off--disabled);
background-color: var(--radio-color-background--disabled);
}

// Skeleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
--radio-color-background-off: var(--sb-color-white);
--radio-color-border-off: var(--sb-color-violet);
// Disabled state
--radio-color-dot-on--disabled: var(--sb-color-gray-dark-2-neutral);
--radio-color-border-on--disabled: var(--sb-color-gray-dark-2-neutral);
--radio-color-border-off--disabled: var(--sb-color-gray-dark-2-neutral);
--radio-color-dot-on--disabled: var(--sb-color-gray-dark);
--radio-color-background--disabled: var(--sb-color-gray-light);
--radio-color-border-on--disabled: var(--sb-color-gray-dark);
--radio-color-border-off--disabled: var(--sb-color-gray-dark);
// Active state
--radio-color-dot-on--active: var(--sb-color-violet-light);
--radio-color-border-on--active: var(--sb-color-gray-dark-2-neutral);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
--radio-color-border-off: var(--color-sea-green);
// Disabled state
--radio-color-dot-on--disabled: var(--color-sea-green-30);
--radio-color-background--disabled: var(--color-white);
--radio-color-border-on--disabled: var(--color-sea-green-30);
--radio-color-border-off--disabled: var(--color-mint-green-50);
// Active state
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import {
setupPageScreenshot,
} from '../../../core/jest/jestSetupScreenshots'

describe('ToggleButton', () => {
describe.each(['ui', 'sbanken'])('Radio for %s', (themeName) => {
describe('ToggleButton unchecked', () => {
setupPageScreenshot({
themeName,
url: '/uilib/components/toggle-button/demos',
})

Expand Down Expand Up @@ -45,7 +46,10 @@ describe('ToggleButton', () => {
// NB: Because of focus simulation and screenshotElement.press('Tab')
// we have to run the two focus simulations in a separate run each
describe('checked', () => {
setupPageScreenshot({ url: '/uilib/components/toggle-button/demos' })
setupPageScreenshot({
themeName,
url: '/uilib/components/toggle-button/demos',
})

it('have to match toggle-button in checked state', async () => {
const screenshot = await makeScreenshot({
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ button .dnb-form-status__text {
--radio-color-background-off: white;
--radio-color-border-off: black;
--radio-color-dot-on--disabled: lightgrey;
--radio-color-background--disabled: white;
--radio-color-border-on--disabled: lightgrey;
--radio-color-border-off--disabled: lightgrey;
--radio-color-dot-on--active: lightgrey;
Expand Down Expand Up @@ -1391,12 +1392,14 @@ html[data-whatinput=keyboard] .dnb-radio__focus {
}
.dnb-radio__input[disabled]:checked ~ .dnb-radio__button, .dnb-radio__input[disabled][data-checked=true] ~ .dnb-radio__button {
border-color: var(--radio-color-border-on--disabled);
background-color: var(--radio-color-background--disabled);
}
.dnb-radio__input[disabled]:checked ~ .dnb-radio__dot, .dnb-radio__input[disabled][data-checked=true] ~ .dnb-radio__dot {
background-color: var(--radio-color-dot-on--disabled);
}
.dnb-radio__input[disabled]:not(:checked):not([data-checked=true]) ~ .dnb-radio__button:not(.dnb-skeleton) {
border-color: var(--radio-color-border-off--disabled);
background-color: var(--radio-color-background--disabled);
}
.dnb-radio__input[disabled] ~ .dnb-radio__button.dnb-skeleton {
border-color: var(--skeleton-color);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* ToggleButton theme for Sbanken
*
*/

@import '../../../../style/core/utilities.scss';

.dnb-toggle-button {
&__button {
background-color: var(--sb-color-white);
color: var(--sb-color-violet);
@include fakeBorder(var(--sb-color-violet), 0.09375rem);

@include hover() {
background-color: var(--sb-color-violet-light-3);
color: var(--sb-color-violet);
}

@include active() {
@include fakeBorder(var(--sb-color-violet-light-3), 0.125rem);
background-color: var(--sb-color-violet);
color: var(--sb-color-violet-light-3);
}

&[disabled] {
@include fakeBorder(var(--sb-color-gray-light), 0.09375rem, inset);
background-color: var(--sb-color-gray-light);
color: var(--sb-color-gray-dark);
}

html[data-whatinput='keyboard']
&:not([disabled]):not(:active):not(:hover):focus {
.dnb-radio {
&__button {
background-color: transparent;
border-color: var(--focus-ring-color);
box-shadow: 0 0 0 0.0625rem var(--focus-ring-color);
}
&__dot {
background-color: var(--focus-ring-color);
}
}
.dnb-checkbox {
&__button {
background-color: transparent;
border-color: var(--focus-ring-color);
box-shadow: 0 0 0 0.0625rem var(--focus-ring-color);
}
&__gfx {
color: var(--focus-ring-color);
}
}
}
}

/* stylelint-disable no-descending-specificity */
&--checked &__button {
&:not([disabled]):not(:active) {
background-color: var(--sb-color-violet);
color: var(--sb-color-white);
box-shadow: none;
}

@include hover() {
background-color: var(--sb-color-violet);
color: var(--sb-color-white);
@include fakeBorder(var(--sb-color-violet), 0.125rem);
}

@include active() {
@include fakeBorder(var(--sb-color-violet-light-3), 0.125rem, inset);
background-color: var(--sb-color-violet);
color: var(--sb-color-violet-light-3);
}

html[data-whatinput='keyboard']
&:not([disabled]):not(:active):not(:hover):focus {
color: var(--sb-color-blue-dark-2);
background-color: var(--sb-color-blue-light-2);
}
}
/* stylelint-enable no-descending-specificity */
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ $fonts-path: '../../../../assets/fonts/dnb' !default;
@import '../../../components/table/style/themes/dnb-table-theme-sbanken.scss';
@import '../../../components/tabs/style/themes/dnb-tabs-theme-sbanken.scss';
@import '../../../components/textarea/style/themes/dnb-textarea-theme-sbanken.scss';
@import '../../../components/toggle-button/style/themes/dnb-toggle-button-theme-sbanken.scss';
@import '../../../components/tooltip/style/themes/dnb-tooltip-theme-sbanken.scss';
@import '../../../components/upload/style/themes/dnb-upload-theme-sbanken.scss';
@import '../../../fragments/drawer-list/style/themes/dnb-drawer-list-theme-sbanken.scss';
Expand All @@ -56,6 +57,5 @@ $fonts-path: '../../../../assets/fonts/dnb' !default;
@import '../../../components/step-indicator/style/themes/dnb-step-indicator-theme-ui.scss';
@import '../../../components/switch/style/themes/dnb-switch-theme-ui.scss';
@import '../../../components/timeline/style/themes/dnb-timeline-theme-ui.scss';
@import '../../../components/toggle-button/style/themes/dnb-toggle-button-theme-ui.scss';
@import '../../../fragments/scroll-view/style/themes/dnb-scroll-view-theme-ui.scss';
@import './sbanken-theme-forms.scss';
Loading