Skip to content

Commit

Permalink
feat: as suggested by Line Marie, use hover style on focus as well
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Jan 22, 2019
1 parent b05457e commit e94878f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Beside that the Anchor Tag gets assigned by default - or let's say, by only impo
- `.dnb-active-style` <a href="/" class="dnb-active-style">Active Style</a>
- `.dnb-focus-style` <a href="/" class="dnb-focus-style">Focus Style</a>
- `.dnb-with-animation` <a href="/" class="dnb-with-animation">With a special animation Style</a>
- <a>No href</a> results in `user-select: none;`

## With Icon

Expand Down
27 changes: 18 additions & 9 deletions packages/dnb-ui-lib/src/style/core/anchor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
border-bottom: none;
}
@mixin focusStyle($whatinput: null) {
@include fakeFocus($whatinput);
border-bottom: none;
&:not(:active) {
@include hoverStyle();
transition: none;
border-bottom: none;
}
@if $whatinput {
@include fakeFocus($whatinput);
} @else {
@include fakeFocus();
}
}

a {
Expand Down Expand Up @@ -42,8 +50,8 @@ a {
text-decoration: none;
border-bottom: 1px solid var(--color-sea-green);

&:active,
&:hover {
&:hover,
&:active {
@include hoverStyle();

// margins are not needed as long as we go for "inline"
Expand All @@ -53,7 +61,7 @@ a {
@include activeStyle();
}
&:focus {
@include fakeFocus();
@include focusStyle();
}

transition: background-color 0.2s ease;
Expand Down Expand Up @@ -121,7 +129,7 @@ a {
}
}
&:focus {
@include fakeFocus();
@include focusStyle();
// border
&::after {
border-bottom: none;
Expand All @@ -141,6 +149,8 @@ a {
@mixin resetHoverStyle() {
&:hover {
color: inherit;
// in case we dont want to change the color to the body color
// color: var(--color-sea-green);
background-color: inherit;
border-bottom-width: 1px;
}
Expand All @@ -159,8 +169,6 @@ a {
}
}
.dnb-no-anchor-style {
padding: 0;
margin: 0;
white-space: normal;
border-bottom: none;
color: inherit;
Expand All @@ -186,7 +194,8 @@ a {
.dnb-no-anchor-animation {
@include resetAnimationStyle();
}
a:not([href]) {
// If a link don't contains a / or http(s)
a:not([href^='/']):not([href^='http']) {
cursor: pointer;
user-select: none;
}

0 comments on commit e94878f

Please sign in to comment.