Skip to content

Commit

Permalink
feat: add also new class for anchor styling .dnb-anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Feb 14, 2019
1 parent c40509f commit 8f3ce5c
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/dnb-design-system-portal/src/shared/menu/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default class Card extends PureComponent {
>
<Link
css={[linkStyle, customStyle]}
className="dnb-no-anchor-style"
className="dnb-anchor-no-style"
to={url}
onClick={closeMenu}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class ListItem extends PureComponent {
<StyledListItem
className={classnames(
`l-${level}`,
active && 'is-active dnb-hover-style', // use anchor hover style
active && 'is-active dnb-anchor--hover', // use anchor hover style
inside && 'is-inside',
status ? `status-${status}` : null,
className
Expand All @@ -581,8 +581,8 @@ class ListItem extends PureComponent {
<Link
to={to}
className={classnames(
'dnb-no-anchor-underline',
'dnb-no-anchor-hover',
'dnb-anchor-no-underline',
'dnb-anchor-no-hover',
icon && graphics[icon] ? 'has-icon' : null
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const Footer = () => (
<Logo height="40" color="white" />
<small>
Last Portal update: {buildVersion}
<Link to="/license" className="dnb-no-anchor-underline">
<Link to="/license" className="dnb-anchor-no-underline">
Copyright (c) 2018-present DNB.no
</Link>
</small>
Expand Down
2 changes: 1 addition & 1 deletion packages/dnb-ui-lib/src/components/button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default class Button extends PureComponent {
id,
class_name,
className,
href ? '' : null // dnb-no-anchor-underline dnb-no-anchor-hover
href ? '' : null // dnb-anchor-no-underline dnb-anchor-no-hover
)

const params = {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/dnb-ui-lib/src/style/themes/theme-ui/anchor-mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,16 @@
transition: max-height 0.01s linear;
}
}
@mixin useAnchorContrastStyle() {
color: var(--color-white);
border-bottom-color: var(--color-white);
&:hover {
color: var(--color-emerald-green);
}
&:active {
color: var(--color-mint-green);
}
&:focus {
color: var(--color-emerald-green);
}
}
30 changes: 17 additions & 13 deletions packages/dnb-ui-lib/src/style/themes/theme-ui/anchor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

@import './anchor-mixins.scss';

a {
a,
.dnb-anchor {
@include defaultAnchorStyle();

// have focus before :active, because of border-radius
Expand All @@ -29,16 +30,16 @@ a {
transform: translateY(-1px);
}
}
.dnb-hover-style {
.dnb-anchor--hover {
@include hoverStyle();
}
.dnb-active-style {
.dnb-anchor--active {
@include activeStyle();
}
.dnb-focus-style {
.dnb-anchor--focus {
@include focusStyle('mouse');
}
.dnb-with-animation {
.dnb-anchor--animation {
position: relative; // because of z-index and underline/hover sudo classes
z-index: 1; // because of focus handling

Expand Down Expand Up @@ -91,12 +92,17 @@ a {
border-bottom: none;
}
}
// If a link don't contains a / or http(s)
&:not([href^='/']):not([href^='http']) {
cursor: pointer;
user-select: none;
}
}

.dnb-anchor-style {
@include defaultAnchorStyle();
}
.dnb-no-anchor-style {
.dnb-anchor-no-style {
white-space: normal;
border-bottom: none;
color: inherit;
Expand All @@ -113,17 +119,15 @@ a {
@include resetUnderlineStyle();
@include resetHoverStyle();
}
.dnb-no-anchor-underline {
.dnb-anchor-no-underline {
@include resetUnderlineStyle();
}
.dnb-no-anchor-hover {
.dnb-anchor-no-hover {
@include resetHoverStyle();
}
.dnb-no-anchor-animation {
.dnb-anchor-no-animation {
@include resetAnimationStyle();
}
// If a link don't contains a / or http(s)
a:not([href^='/']):not([href^='http']) {
cursor: pointer;
user-select: none;
.dnb-anchor-contrast {
@include useAnchorContrastStyle();
}
4 changes: 4 additions & 0 deletions packages/dnb-ui-lib/src/style/themes/theme-ui/blockquote.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ blockquote,
padding-bottom: 3rem;
}

a {
@include useAnchorContrastStyle();
}

cite,
footer,
figcaption {
Expand Down
16 changes: 8 additions & 8 deletions packages/dnb-ui-lib/stories/elementsStories.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ stories.push([
<a href="#sort">Column 3</a>
</th>
<th>
<a href="#sort" className="dnb-no-anchor-underline">
<a href="#sort" className="dnb-anchor-no-underline">
Column 4 <IconPrimary icon="chevron-down" />
</a>
</th>
Expand Down Expand Up @@ -331,22 +331,22 @@ stories.push([
</a>
</Box>
<Box>
<a href="/" className="dnb-hover-style">
<a href="/" className="dnb-anchor--hover">
Hover Style
</a>
</Box>
<Box>
<a href="/" className="dnb-active-style">
<a href="/" className="dnb-anchor--active">
Active Style
</a>
</Box>
<Box>
<a href="/" className="dnb-focus-style">
<a href="/" className="dnb-anchor--focus">
Focus Style
</a>
</Box>
<Box>
<a href="/" className="dnb-with-animation">
<a href="/" className="dnb-anchor--animation">
With a special
</a>
</Box>
Expand All @@ -359,12 +359,12 @@ stories.push([
</a>
</Box>
<Box>
<a href="http://dnb.no" className="dnb-with-animation">
<a href="http://dnb.no" className="dnb-anchor--animation">
Anchor with Animation <IconPrimary icon="chevron_right" />
</a>
</Box>
<Box>
<a href="http://dnb.no" className="dnb-with-animation">
<a href="http://dnb.no" className="dnb-anchor--animation">
Anchor with Animation - Adipiscing per egestas duis feugiat
dignissim quam cras eget non est ante purus taciti volutpat mi
phasellus rhoncus ridiculus diam at proin fusce bibendum netus
Expand All @@ -374,7 +374,7 @@ stories.push([
<Box>
<a
href="http://dnb.no"
className="dnb-with-animation"
className="dnb-anchor--animation"
style={{ whiteSpace: 'normal' }}
>
Anchor with Animation and no `white-space: pre;` - Adipiscing per
Expand Down

0 comments on commit 8f3ce5c

Please sign in to comment.