Skip to content

Commit

Permalink
feat(Autocomplete): preliminary sbanken colors (#3604)
Browse files Browse the repository at this point in the history
* Fixed sbanken text colors
  • Loading branch information
snorrekim authored May 29, 2024
1 parent c9cae37 commit fe42538
Show file tree
Hide file tree
Showing 31 changed files with 127 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
setupPageScreenshot,
} from '../../../core/jest/jestSetupScreenshots'

describe('Autocomplete', () => {
describe.each(['ui', 'sbanken'])('Autocomplete for %s', (themeName) => {
setupPageScreenshot({
each: true,
themeName,
url: '/uilib/components/autocomplete/demos',
pageViewport: {
width: 1280,
Expand All @@ -25,14 +25,6 @@ describe('Autocomplete', () => {
expect(screenshot).toMatchImageSnapshot()
})

it('have to match disabled state', async () => {
const screenshot = await makeScreenshot({
url: '/uilib/components/autocomplete/visual-tests',
selector: '[data-visual-test="autocomplete-disabled"]',
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match custom input width', async () => {
const screenshot = await makeScreenshot({
selector: '[data-visual-test="autocomplete-input-width"]',
Expand Down Expand Up @@ -70,21 +62,6 @@ describe('Autocomplete', () => {
expect(screenshot).toMatchImageSnapshot()
})

it('have to match autocomplete opened list', async () => {
const screenshot = await makeScreenshot({
url: '/uilib/components/autocomplete/visual-tests',
selector: '[data-visual-test="autocomplete-opened"]',
simulateSelector:
'[data-visual-test="autocomplete-opened"] .focus-trigger .dnb-drawer-list:last-of-type li.first-of-type',
waitAfterSimulate: 200,
simulate: 'click',
style: {
height: '40rem',
},
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match autocomplete with suffix value', async () => {
const screenshot = await makeScreenshot({
selector: '[data-visual-test="autocomplete-suffix"]',
Expand All @@ -106,14 +83,19 @@ describe('Autocomplete', () => {
})
expect(screenshot).toMatchImageSnapshot()
})
})

describe.each(['ui', 'sbanken'])('Autocomplete for %s', (themeName) => {
setupPageScreenshot({
themeName,
url: '/uilib/components/autocomplete/demos',
pageViewport: {
width: 700,
},
})

it('have to match small screen autocomplete with suffix value', async () => {
const screenshot = await makeScreenshot({
url: '/uilib/components/autocomplete/demos',
pageViewport: {
width: 700,
height: 200,
},
selector: '[data-visual-test="autocomplete-suffix"]',
style: {
height: '4rem',
Expand All @@ -122,3 +104,31 @@ describe('Autocomplete', () => {
expect(screenshot).toMatchImageSnapshot()
})
})

describe.each(['ui', 'sbanken'])('Autocomplete for %s', (themeName) => {
setupPageScreenshot({
themeName,
url: '/uilib/components/autocomplete/visual-tests',
})

it('have to match disabled state', async () => {
const screenshot = await makeScreenshot({
selector: '[data-visual-test="autocomplete-disabled"]',
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match autocomplete opened list', async () => {
const screenshot = await makeScreenshot({
selector: '[data-visual-test="autocomplete-opened"]',
simulateSelector:
'[data-visual-test="autocomplete-opened"] .focus-trigger .dnb-drawer-list:last-of-type li.first-of-type',
waitAfterSimulate: 200,
simulate: 'click',
style: {
height: '40rem',
},
})
expect(screenshot).toMatchImageSnapshot()
})
})
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.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,6 @@ html[data-visual-test] .dnb-progress-indicator__bar-transition {
display: flex;
justify-content: center;
align-items: center;
color: var(--color-sea-green);
}
.dnb-autocomplete__show-all .dnb-drawer-list__option__inner .dnb-drawer-list__option__item {
display: flex;
Expand Down Expand Up @@ -2905,6 +2904,9 @@ exports[`Autocomplete scss have to match default theme snapshot 1`] = `
/*
* Utilities
*/
.dnb-autocomplete__show-all .dnb-drawer-list__option__inner {
color: var(--color-sea-green);
}
.dnb-autocomplete--opened .dnb-input .dnb-input__shell .dnb-input__shell, .dnb-autocomplete:not(.dnb-autocomplete__status--error) .dnb-form-label:hover ~ .dnb-autocomplete__inner .dnb-input:not([data-input-state=disabled]) .dnb-input__shell {
--border-color: var(--color-sea-green);
--border-width: 0.125rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@
.dnb-icon {
align-self: center;
}

color: var(--color-sea-green);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Autocomplete theme for sbanken
* TODO: this theme is just a prelimenary fix to avoid dnb colors
*/

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

.dnb-autocomplete {
&__show-all {
.dnb-drawer-list__option__inner {
color: var(--sb-color-violet);
}
}

&--opened .dnb-input .dnb-input__shell,
&:not(#{&}__status--error)
.dnb-form-label:hover
~ &__inner
.dnb-input:not([data-input-state='disabled']) {
.dnb-input__shell {
@include fakeBorder(var(--sb-color-violet), 0.125rem);
}
}

&--show-indicator &__input .dnb-input__icon {
color: transparent;
}

&__shell,
&__input {
border-radius: var(--autocomplete-border-radius);
}

&__status--error:not(#{&}--opened)
.dnb-form-label:hover
~ &__inner
.dnb-input:not([data-input-state='disabled']) {
.dnb-input__shell {
@include fakeBorder(var(--sb-color-red), 0.125rem);
}
}
}

.dnb-autocomplete__root .dnb-drawer-list__option {
&--focus,
&__item:nth-of-type(1) {
font-weight: var(--font-weight-basis);
}

&__item:nth-of-type(n + 2) {
color: var(--sb-color-gray-dark-2);
}

&--selected:not(.dnb-drawer-list__option--focus)
.dnb-drawer-list__option__item:nth-of-type(n + 2) {
&,
& .dnb-anchor {
color: var(--sb-color-white);
}
}

&__item--highlight {
font-weight: var(--font-weight-bold);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
@import '../../../../style/core/utilities.scss';

.dnb-autocomplete {
&__show-all {
.dnb-drawer-list__option__inner {
color: var(--color-sea-green);
}
}

&--opened .dnb-input .dnb-input__shell,
&:not(#{&}__status--error)
.dnb-form-label:hover
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.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

&__option__inner {
overflow: visible;
background-color: transparent;
background-color: inherit;
padding: 1rem 0.75rem;

&::before {
Expand Down Expand Up @@ -64,6 +64,10 @@
background-color: transparent;
z-index: 0;

&__item.item-nr-1 {
font-weight: var(--font-weight-medium);
}

@include hover() {
border-color: var(--sb-color-violet);
z-index: 1;
Expand Down Expand Up @@ -115,6 +119,13 @@
}
}

@include allAbove(small) {
&--selected &__suffix {
z-index: 2; // over check icon
background-color: inherit; // to "hide" the check icon
}
}

&.last-of-type {
border-radius: var(--drawer-list-options-border-radius);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $fonts-path: '../../../../assets/fonts/dnb' !default;

@import '../../../components/accordion/style/themes/dnb-accordion-theme-sbanken.scss';
@import '../../../components/anchor/style/themes/dnb-anchor-theme-sbanken.scss';
@import '../../../components/autocomplete/style/themes/dnb-autocomplete-theme-sbanken.scss';
@import '../../../components/avatar/style/themes/dnb-avatar-theme-sbanken.scss';
@import '../../../components/breadcrumb/style/themes/dnb-breadcrumb-theme-sbanken.scss';
@import '../../../components/button/style/themes/dnb-button-theme-sbanken.scss';
Expand Down Expand Up @@ -48,7 +49,6 @@ $fonts-path: '../../../../assets/fonts/dnb' !default;
@import '../../../components/upload/style/themes/dnb-upload-theme-sbanken.scss';
@import '../../../fragments/drawer-list/style/themes/dnb-drawer-list-theme-sbanken.scss';
@import '../../../fragments/text-counter/style/themes/dnb-text-counter-theme-sbanken.scss';
@import '../../../components/autocomplete/style/themes/dnb-autocomplete-theme-ui.scss';
@import '../../../components/badge/style/themes/dnb-badge-theme-ui.scss';
@import '../../../components/date-picker/style/themes/dnb-date-picker-theme-ui.scss';
@import '../../../components/drawer/style/themes/dnb-drawer-theme-ui.scss';
Expand Down

0 comments on commit fe42538

Please sign in to comment.