-
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: new skip style, defined by the UX team (WIP)
- Loading branch information
1 parent
75e1509
commit 0848df2
Showing
6 changed files
with
167 additions
and
104 deletions.
There are no files selected for viewing
41 changes: 27 additions & 14 deletions
41
...nb-design-system-portal/src/pages/uilib/usage/accessibility/examples/skip-link-example.js
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 |
---|---|---|
@@ -1,23 +1,36 @@ | ||
import React from 'react' | ||
import styled from '@emotion/styled' | ||
|
||
// const Example = styled.span | ||
const Example = styled.span` | ||
a.dnb-skip-link { | ||
const ChangeStylesOfSkipLink = styled.span` | ||
a.dnb-show-skip-link { | ||
position: relative; | ||
top: 0; | ||
left: 0; | ||
z-index: 1; | ||
} | ||
a.dnb-skip-link:active, | ||
a.dnb-skip-link:focus { | ||
margin: 0; | ||
&::after { | ||
content: none; | ||
} | ||
} | ||
` | ||
|
||
export default () => ( | ||
<Example> | ||
<a className="dnb-skip-link dnb-anchor--focus" href="#dnb-app-content"> | ||
Skip to content | ||
</a> | ||
</Example> | ||
) | ||
export default () => { | ||
const onClick = e => { | ||
try { | ||
document.querySelector('a.dnb-skip-link').focus() | ||
e.preventDefault() | ||
} catch (e) { | ||
console.log(e) | ||
} | ||
} | ||
return ( | ||
<ChangeStylesOfSkipLink> | ||
<a | ||
className="dnb-show-skip-link" | ||
onClick={onClick} | ||
href="#dnb-app-content" | ||
> | ||
Show Skip-Link | ||
</a> | ||
</ChangeStylesOfSkipLink> | ||
) | ||
} |
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
29 changes: 29 additions & 0 deletions
29
packages/dnb-ui-lib/src/style/core/helper-classes/dnb-section.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,29 @@ | ||
// Wraps content inside a visual section banner. | ||
.dnb-section { | ||
position: relative; | ||
z-index: 1; | ||
|
||
&::after { | ||
content: ''; | ||
position: absolute; | ||
z-index: -1; | ||
left: -50vw; | ||
top: 0; | ||
width: 100vw; | ||
height: 100%; | ||
background-color: var(--color-mint-green-12); | ||
|
||
// we use box-shadow to avoid a horizontal scrollbar | ||
box-shadow: 100vw 0 0 0 var(--color-mint-green-12); | ||
} | ||
} | ||
.dnb-section--spacing { | ||
padding-top: 2rem; | ||
padding-bottom: 2rem; | ||
} | ||
.dnb-section--white { | ||
&::after { | ||
background-color: var(--color-white); | ||
box-shadow: 100vw 0 0 0 var(--color-white); | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
packages/dnb-ui-lib/src/style/core/helper-classes/skip-link.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,102 @@ | ||
@mixin skipLink() { | ||
position: fixed; | ||
z-index: 9999; | ||
top: 35%; | ||
left: 40%; | ||
|
||
margin: 0; | ||
padding: 0.8125rem 1rem 0.6875rem 1rem; | ||
|
||
white-space: nowrap; | ||
|
||
font-size: var(--font-size-default); | ||
color: var(--color-sea-green); | ||
text-decoration: none; | ||
text-align: center; | ||
|
||
user-select: none; | ||
outline: none; | ||
|
||
background-color: transparent; | ||
border-radius: 0; | ||
border: none; | ||
box-shadow: none; | ||
|
||
&::after { | ||
content: ''; | ||
position: absolute; | ||
z-index: -2; | ||
left: -200vw; | ||
top: -200vh; | ||
width: 150vw; | ||
height: 150vh; | ||
|
||
background-color: rgba(255, 255, 255, 0.85); | ||
|
||
// we use box-shadow to avoid a horizontal scrollbar | ||
box-shadow: 150vw 150vh 0 0 rgba(255, 255, 255, 0.85); | ||
} | ||
|
||
&::before { | ||
content: ''; | ||
position: absolute; | ||
z-index: -1; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
border-radius: 1.5rem; //same as anchor | ||
|
||
background-color: var(--color-white); | ||
|
||
@include fakeFocus('mouse'); | ||
} | ||
|
||
&:hover::before { | ||
background-color: var(--color-mint-green-50); | ||
} | ||
&:active::before { | ||
background-color: var(--color-emerald-green); | ||
} | ||
//focus | ||
&:focus:not(:active)::before { | ||
@include fakeFocus(); | ||
} | ||
|
||
//focus | ||
&:focus { | ||
opacity: 1; | ||
} | ||
&:hover, | ||
&:focus:not(:hover):not(:active) { | ||
color: var(--color-sea-green); | ||
background-color: transparent; | ||
box-shadow: none; | ||
} | ||
// stylelint-disable-next-line | ||
&:active { | ||
color: var(--color-white); | ||
background-color: transparent; | ||
} | ||
} | ||
|
||
// How to use the "skip-link" | ||
// 1. Have this on the top of Your App: <a class="dnb-skip-link dnb-button" href="#dnb-app-content">Skip to content</a> | ||
// 2. Place this id="dnb-app-content" on Your main content container | ||
a.dnb-skip-link { | ||
position: fixed; | ||
z-index: -9999; | ||
top: -100vh; | ||
opacity: 0.3; | ||
transition: opacity 0.2s ease-out; | ||
// @include allBelow(medium) { | ||
// display: none; | ||
// } | ||
} | ||
a.dnb-show-skip-link, | ||
a.dnb-skip-link:focus { | ||
@include skipLink(); | ||
} | ||
[dnb-is-touch] a.dnb-skip-link { | ||
display: none; | ||
} |
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