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

fix(Anchor): use text-decoration instead of box-shadow for chromium breaking underline support #1841

Merged
merged 3 commits into from
Dec 21, 2022
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 @@ -111,6 +111,16 @@ To force a specific state of style, use the following classes to do so:
I'm a Button!
</button>
</li>
<li>
<Anchor href="/uilib/elements/anchor" data-visual-test="anchor-newline">
Newline <br /> Newline
</Anchor>
</li>
<li>
<Anchor skeleton href="/uilib/elements/anchor" data-visual-test="anchor-skeleton">
Skeleton
</Anchor>
</li>
</ul>
`}
</ComponentBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('Autocomplete screenshot', () => {
'[data-visual-test="autocomplete-suffix"] .dnb-autocomplete .dnb-input',
simulate: 'click',
style: {
height: '35rem',
height: '31rem',
},
})
expect(screenshot).toMatchImageSnapshot()
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.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {
setupPageScreenshot,
} from '../../../core/jest/jestSetupScreenshots'

const style = { width: '25rem' }

describe('GlobalStatus screenshot', () => {
const style = { width: '20rem' }
setupPageScreenshot({ url: '/uilib/components/global-status/demos' })

it('have to match the default state with custom content', async () => {
Expand All @@ -20,6 +21,15 @@ describe('GlobalStatus screenshot', () => {
expect(screenshot).toMatchImageSnapshot()
})

it('have to match the info state and custom content', async () => {
const screenshot = await testPageScreenshot({
style,
selector:
'[data-visual-test="global-status-info"] .dnb-global-status',
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match the close button in focus state', async () => {
const screenshot = await testPageScreenshot({
style,
Expand All @@ -41,19 +51,4 @@ describe('GlobalStatus screenshot', () => {
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match the info state and custom content', async () => {
const screenshot = await testPageScreenshot({
style,
selector:
'[data-visual-test="global-status-info"] .dnb-global-status',
})
expect(screenshot).toMatchImageSnapshot()
})
// it.skip('have to match custom content', async () => {
// const screenshot = await testPageScreenshot({
// selector: '[data-visual-test="global-status-custom"]'
// })
// 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.
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,15 @@ exports[`Section scss have to match default theme snapshot 1`] = `
.dnb-section--fire-red .dnb-anchor,
.dnb-section--emerald-green .dnb-anchor,
.dnb-section--sea-green .dnb-anchor {
color: var(--color-white);
box-shadow: 0 0.09375rem 0 0 var(--color-white); }
color: var(--color-white); }
.dnb-section--fire-red .dnb-anchor:hover, .dnb-section--fire-red .dnb-anchor:active,
.dnb-section--emerald-green .dnb-anchor:hover,
.dnb-section--emerald-green .dnb-anchor:active,
.dnb-section--sea-green .dnb-anchor:hover,
.dnb-section--sea-green .dnb-anchor:active {
color: var(--color-emerald-green);
background-color: var(--color-white);
box-shadow: none; }
text-decoration: none; }
.dnb-section--fire-red .dnb-anchor:active,
.dnb-section--emerald-green .dnb-anchor:active,
.dnb-section--sea-green .dnb-anchor:active {
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.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,28 @@ describe('Anchor screenshot', () => {
setupPageScreenshot({
url: '/uilib/elements/anchor',
})
// the first one is on 5.54%

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

it('have to match breaking lines', async () => {
const screenshot = await testPageScreenshot({
selector: '[data-visual-test="anchor-newline"]',
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match anchor with skeleton', async () => {
const screenshot = await testPageScreenshot({
selector: '[data-visual-test="anchor-skeleton"]',
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match anchor with icon', async () => {
const screenshot = await testPageScreenshot({
selector: '[data-visual-test="anchor-icon"]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ button.dnb-anchor {
display: inline;
padding: 0.05575em 0.125em 0.05575em;
font-size: var(--font-size-basis);
text-decoration: none;
text-decoration: underline;
text-decoration-color: currentColor;
text-decoration-thickness: 0.0938rem;
text-underline-offset: 0.25em;
border-radius: 0;
box-shadow: 0 0.09375rem 0 0 currentColor;
color: var(--color-sea-green);
transition: background-color 200ms ease-in-out, box-shadow 180ms ease-in-out, border-radius 200ms ease-in-out; }
transition: background-color 200ms ease-in-out, border-radius 200ms ease-in-out; }
sup .dnb-anchor,
sub .dnb-anchor {
padding: 0 0.025em 0; }
Expand All @@ -62,7 +64,6 @@ button.dnb-anchor {
transition: none; }
.dnb-anchor:focus:not(:active),
.dnb-section .dnb-anchor:focus:not(:active).dnb-anchor {
box-shadow: none;
text-decoration: none; }
html[data-whatinput='keyboard'] .dnb-anchor:focus {
--border-color: var(--color-emerald-green);
Expand All @@ -78,15 +79,13 @@ button.dnb-anchor {
.dnb-anchor:hover,
.dnb-section .dnb-anchor:hover.dnb-anchor, .dnb-anchor:active,
.dnb-section .dnb-anchor:active.dnb-anchor {
box-shadow: none;
text-decoration: none; }
.dnb-anchor:active {
color: var(--color-mint-green);
background-color: var(--color-emerald-green);
border-radius: 0.25em; }
.dnb-anchor:active,
.dnb-section .dnb-anchor:active.dnb-anchor {
box-shadow: none;
text-decoration: none; }
.dnb-anchor[target='_blank']:not(:empty):not(.dnb-anchor--no-icon) {
position: relative;
Expand Down Expand Up @@ -121,7 +120,6 @@ button.dnb-anchor {
border-radius: 0.25em; }
.dnb-anchor--hover,
.dnb-section .dnb-anchor--hover.dnb-anchor {
box-shadow: none;
text-decoration: none; }

.dnb-anchor--active {
Expand All @@ -130,7 +128,6 @@ button.dnb-anchor {
border-radius: 0.25em; }
.dnb-anchor--active,
.dnb-section .dnb-anchor--active.dnb-anchor {
box-shadow: none;
text-decoration: none; }

.dnb-anchor--focus {
Expand All @@ -142,7 +139,6 @@ button.dnb-anchor {
transition: none; }
.dnb-anchor--focus:not(:active),
.dnb-section .dnb-anchor--focus:not(:active).dnb-anchor {
box-shadow: none;
text-decoration: none; }
html[data-whatinput='mouse'] .dnb-anchor--focus {
--border-color: var(--color-emerald-green);
Expand All @@ -157,15 +153,13 @@ button.dnb-anchor {
transition: none; }
.dnb-anchor--no-style,
.dnb-section .dnb-anchor--no-style.dnb-anchor {
box-shadow: none;
text-decoration: none; }
.dnb-anchor--no-style:hover {
color: inherit;
background-color: transparent; }

.dnb-anchor--no-underline,
.dnb-section .dnb-anchor--no-underline.dnb-anchor {
box-shadow: none;
text-decoration: none; }

.dnb-anchor--no-hover:hover {
Expand All @@ -179,12 +173,11 @@ button.dnb-anchor {
transition: none; }

.dnb-anchor--contrast {
color: var(--color-white);
box-shadow: 0 0.09375rem 0 0 var(--color-white); }
color: var(--color-white); }
.dnb-anchor--contrast:hover, .dnb-anchor--contrast:active {
color: var(--color-emerald-green);
background-color: var(--color-white);
box-shadow: none; }
text-decoration: none; }
.dnb-anchor--contrast:active {
color: var(--color-emerald-green);
background-color: var(--color-white); }
Expand All @@ -205,7 +198,7 @@ a.dnb-button {

.dnb-skeleton > .dnb-anchor,
.dnb-anchor.dnb-skeleton {
box-shadow: none; }
text-decoration: none; }
.dnb-skeleton > .dnb-anchor::after,
.dnb-anchor.dnb-skeleton::after {
filter: grayscale(100%) opacity(0.3); }
Expand Down Expand Up @@ -557,14 +550,13 @@ sub {
font-size: inherit; }
.dnb-blockquote:not(.dnb-blockquote--no-background) .dnb-anchor,
.dnb-blockquote:not(.dnb-blockquote--no-background) a {
color: var(--color-white);
box-shadow: 0 0.09375rem 0 0 var(--color-white); }
color: var(--color-white); }
.dnb-blockquote:not(.dnb-blockquote--no-background) .dnb-anchor:hover, .dnb-blockquote:not(.dnb-blockquote--no-background) .dnb-anchor:active,
.dnb-blockquote:not(.dnb-blockquote--no-background) a:hover,
.dnb-blockquote:not(.dnb-blockquote--no-background) a:active {
color: var(--color-emerald-green);
background-color: var(--color-white);
box-shadow: none; }
text-decoration: none; }
.dnb-blockquote:not(.dnb-blockquote--no-background) .dnb-anchor:active,
.dnb-blockquote:not(.dnb-blockquote--no-background) a:active {
color: var(--color-emerald-green);
Expand Down
23 changes: 9 additions & 14 deletions packages/dnb-eufemia/src/style/elements/_anchor-mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@

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

$anchorBorderBottomWidth: 0.09375rem; // we can use 1.5px incase we use box-shadow instead of border-bottom
$anchorBorderRadius: 0.25em;

@mixin anchorDefaultStyle($theme: null) {
// make sure we have always `display: inline;` as inline-block is breaking the border-bottom
display: inline;

padding: 0.05575em 0.125em 0.05575em; // the total body height will then be 24px if font-size is 18px

font-size: var(--font-size-basis);
text-decoration: none;
text-decoration: underline;
text-decoration-color: currentColor;
text-decoration-thickness: 0.0938rem;
text-underline-offset: 0.25em;
border-radius: 0;
box-shadow: 0 $anchorBorderBottomWidth 0 0 currentColor;

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

Expand Down Expand Up @@ -51,9 +50,6 @@ $anchorBorderRadius: 0.25em;
@mixin resetUnderlineStyle() {
&,
.dnb-section &.dnb-anchor {
box-shadow: none;

// legacy reset
text-decoration: none;
}
}
Expand All @@ -80,7 +76,7 @@ $anchorBorderRadius: 0.25em;
@mixin anchorHoverStyle() {
color: var(--color-sea-green);
background-color: var(--color-mint-green-50);
border-radius: $anchorBorderRadius;
border-radius: 0.25em;
@include resetUnderlineStyle();
@if mixin-exists('anchorHoverStyleCustomisation') {
@include anchorHoverStyleCustomisation();
Expand All @@ -89,7 +85,7 @@ $anchorBorderRadius: 0.25em;
@mixin anchorActiveStyle() {
color: var(--color-mint-green);
background-color: var(--color-emerald-green);
border-radius: $anchorBorderRadius;
border-radius: 0.25em;
@include resetUnderlineStyle();
@if mixin-exists('anchorActiveStyleCustomisation') {
@include anchorActiveStyleCustomisation();
Expand All @@ -107,19 +103,18 @@ $anchorBorderRadius: 0.25em;
} @else {
@include fakeFocus();
}
border-radius: $anchorBorderRadius;
border-radius: 0.25em;
}

// other styles
@mixin useAnchorContrastStyle($contrastColor: var(--color-emerald-green)) {
color: var(--color-white);
box-shadow: 0 $anchorBorderBottomWidth 0 0 var(--color-white);

&:hover,
&:active {
color: $contrastColor;
background-color: var(--color-white);
box-shadow: none;
text-decoration: none;
}
&:active {
color: $contrastColor;
Expand Down Expand Up @@ -193,7 +188,7 @@ $anchorBorderRadius: 0.25em;
}

transition: background-color 200ms ease-in-out,
box-shadow 180ms ease-in-out, border-radius 200ms ease-in-out;
border-radius 200ms ease-in-out;
[data-visual-test-wrapper] & {
transition: none;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/style/elements/anchor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ a.dnb-button {
// because of the underline, we hide anchors
.dnb-skeleton > .dnb-anchor,
.dnb-anchor.dnb-skeleton {
box-shadow: none;
text-decoration: none;
&::after {
filter: grayscale(100%) opacity(0.3);
}
Expand Down