Skip to content

Commit

Permalink
fix(skip-link): layout
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed Sep 1, 2024
1 parent 154644c commit 6ba0dbc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .changeset/slick-ants-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@rhds/elements": patch
---
`<rh-skip-link>`: ensure link is always at top of the page, per guidelines
17 changes: 14 additions & 3 deletions elements/rh-skip-link/rh-skip-link.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#container {
display: block !important;
position: relative !important;
display: block;
z-index: 1000;
}

a#container {
position: fixed;
}

div#container {
position: relative;
}

a,
Expand Down Expand Up @@ -32,7 +40,6 @@ a,
outline: 0 !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
text-decoration: none !important;
top: -40px !important;
transform: translateX(-50%) !important;
Expand All @@ -41,6 +48,10 @@ a,
width: 1px !important;
}

::slotted(a) {
position: fixed !important;
}

a:is(:active, :focus),
::slotted(a:is(:active, :focus)) {
border-width: var(--rh-border-width-md, 2px) !important;
Expand Down
9 changes: 3 additions & 6 deletions elements/rh-skip-link/rh-skip-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ export class RhSkipLink extends LitElement {
@property({ reflect: true }) href?: string;

render() {
return html`
<div id="container">${this.href ? html`
<a href="${this.href}"><slot></slot></a>` : html`
<slot></slot>`}
</div>
`;
return this.href ?
html`<a id="container" href="${this.href}"><slot></slot></a>`
: html`<div id="container"><slot></slot></div>`;
}
}

Expand Down

0 comments on commit 6ba0dbc

Please sign in to comment.