-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Anchor): create styles for Sbanken (#2250)
* create theme file for sbanken anchor * create visual test for sbanken acnhors * fix anchor font-weight
- Loading branch information
1 parent
a8c3f72
commit 208e891
Showing
23 changed files
with
236 additions
and
14 deletions.
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
packages/dnb-eufemia/src/elements/anchor/__tests__/themes/Anchor.sbanken.screenshot.test.ts
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,151 @@ | ||
/** | ||
* Screenshot Test | ||
* This file will not run on "test:staged" because we don't require any related files | ||
*/ | ||
|
||
import { | ||
makeScreenshot, | ||
setupPageScreenshot, | ||
} from '../../../../core/jest/jestSetupScreenshots' | ||
|
||
describe('Anchor with sbanken theme', () => { | ||
setupPageScreenshot({ | ||
url: '/uilib/elements/anchor?eufemia-theme=sbanken', | ||
}) | ||
|
||
it('have to match the "default" state', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-default"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match breaking lines', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-newline"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match anchor with skeleton', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-skeleton"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match anchor with icon', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-icon"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match anchor with paragraph', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-paragraph"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match anchor in heading', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-heading"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the "hover" state', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-hover"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the "active" state', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-active"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the "focus" state', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-focus"]', | ||
simulate: 'focus', // should be tested first | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the anchor-contrast "default" state', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-contrast"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the anchor-contrast "focus" state', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-contrast"]', | ||
simulate: 'focus', // should be tested first | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the anchor-contrast "hover" state', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-contrast"]', | ||
simulate: 'hover', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the dnb-anchor--no-underline', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-in-section"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
// "active" simulation is suddenly too unstable – no reason found | ||
// it('have to match the anchor-contrast "active" state', async () => { | ||
// const screenshot = await makeScreenshot({ | ||
// selector: '[data-visual-test="anchor-contrast"]', | ||
// simulate: 'active', | ||
// }) | ||
// expect(screenshot).toMatchImageSnapshot() | ||
// }) | ||
}) | ||
|
||
describe('Anchor target blank with sbanken theme', () => { | ||
setupPageScreenshot({ | ||
url: '/uilib/elements/anchor?eufemia-theme=sbanken', | ||
}) | ||
|
||
it('have to match blank target anchor in heading', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-heading-blank"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the target blank state', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="anchor-blank"] a', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('have to match the target blank with tooltip', async () => { | ||
const screenshot = await makeScreenshot({ | ||
style: { | ||
'padding-top': '2rem', | ||
}, | ||
waitBeforeSimulate: 200, | ||
selector: '[data-visual-test="anchor-blank"]', | ||
simulateSelector: '[data-visual-test="anchor-blank"] a.dnb-anchor', | ||
simulate: 'hover', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
}) |
Binary file added
BIN
+7.07 KB
...-blank-with-sbanken-theme-have-to-match-blank-target-anchor-in-heading.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.77 KB
...r-target-blank-with-sbanken-theme-have-to-match-the-target-blank-state.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.25 KB
...t-blank-with-sbanken-theme-have-to-match-the-target-blank-with-tooltip.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.58 KB
..._snapshots__/anchor-with-sbanken-theme-have-to-match-anchor-in-heading.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.7 KB
...e_snapshots__/anchor-with-sbanken-theme-have-to-match-anchor-with-icon.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.69 KB
...pshots__/anchor-with-sbanken-theme-have-to-match-anchor-with-paragraph.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+524 Bytes
...apshots__/anchor-with-sbanken-theme-have-to-match-anchor-with-skeleton.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.6 KB
...age_snapshots__/anchor-with-sbanken-theme-have-to-match-breaking-lines.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.69 KB
...e_snapshots__/anchor-with-sbanken-theme-have-to-match-the-active-state.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.78 KB
...hor-with-sbanken-theme-have-to-match-the-anchor-contrast-default-state.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.09 KB
...nchor-with-sbanken-theme-have-to-match-the-anchor-contrast-focus-state.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.92 KB
...nchor-with-sbanken-theme-have-to-match-the-anchor-contrast-hover-state.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.32 KB
..._snapshots__/anchor-with-sbanken-theme-have-to-match-the-default-state.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.36 KB
...__/anchor-with-sbanken-theme-have-to-match-the-dnb-anchor-no-underline.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.37 KB
...ge_snapshots__/anchor-with-sbanken-theme-have-to-match-the-focus-state.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.37 KB
...ge_snapshots__/anchor-with-sbanken-theme-have-to-match-the-hover-state.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions
59
packages/dnb-eufemia/src/elements/anchor/style/themes/dnb-anchor-theme-sbanken.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,59 @@ | ||
@use '../anchor-mixins.scss'; | ||
|
||
.dnb-anchor { | ||
// Has to use --sb-font-weight-bold to get correct weighting as --sb-font-weight-medium does nothing at the moment | ||
font-weight: var(--sb-font-weight-bold); | ||
color: var(--sb-color-gray-dark-3); | ||
text-decoration-color: var(--sb-color-green-dark); | ||
|
||
&:hover { | ||
color: var(--sb-color-text); | ||
background-color: var(--sb-color-green-dark); | ||
|
||
border-radius: 0.5rem; | ||
} | ||
|
||
&:active { | ||
color: var(--sb-color-text); | ||
background-color: var(--sb-color-green); | ||
|
||
border-radius: 0.5rem; | ||
} | ||
|
||
&:focus { | ||
&:not(:active) { | ||
color: var(--sb-color-blue-dark); | ||
background-color: var(--sb-color-blue-light-3); | ||
|
||
border-radius: 0.25rem; | ||
} | ||
} | ||
} | ||
|
||
.dnb-anchor--hover { | ||
color: var(--sb-color-text); | ||
background-color: var(--sb-color-green-dark); | ||
|
||
border-radius: 0.5rem; | ||
} | ||
|
||
.dnb-anchor--active { | ||
color: var(--sb-color-text); | ||
background-color: var(--sb-color-green); | ||
|
||
border-radius: 0.5rem; | ||
} | ||
|
||
.dnb-anchor--focus { | ||
&:not(:active) { | ||
color: var(--sb-color-blue-dark); | ||
background-color: var(--sb-color-blue-light-3); | ||
|
||
border-radius: 0.25rem; | ||
} | ||
} | ||
|
||
// TODO: add correct contrast styling when designs are in place | ||
.dnb-anchor--contrast { | ||
@include anchor-mixins.useAnchorContrastStyle(); | ||
} |
Binary file modified
BIN
+357 Bytes
(100%)
...ots__/paragraph-with-sbanken-theme-have-to-match-the-paragraph-example.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+132 Bytes
(100%)
...ith-sbanken-theme-have-to-match-the-paragraph-with-additional-elements.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+482 Bytes
(100%)
...ragraph-with-sbanken-theme-have-to-match-the-paragraph-with-small-text.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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