Skip to content

Commit

Permalink
Update styles and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Fercas123 committed Dec 10, 2024
1 parent 4bcfb82 commit c326a4f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 77 deletions.
40 changes: 8 additions & 32 deletions packages/lab/src/skip-link/SkipLink.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/* CSS Variables for the Skip Link */
.saltSkipLink {
--skipLink-padding: var(--saltSkipLink-padding, var(--salt-size-unit));
--skipLink-margin: var(--saltSkipLink-margin, var(--salt-size-unit));
--skipLink-background: var(--saltSkipLink-background, var(--salt-actionable-primary-background));
--skipLink-color: var(--saltSkipLink-color, var(--salt-content-primary-foreground));
}

/* Overrides */
.saltSkipLink {
--saltLink-color-focus: var(--skipLink-color);
}

.saltSkipLink-target {
--skipLink-target-focus: var(--salt-focused-outline);
}

/*Styles applied when the link is focused to hide the Skip Link when not in focus*/

Check failure on line 1 in packages/lab/src/skip-link/SkipLink.css

View workflow job for this annotation

GitHub Actions / lint

format

File content differs from formatting output
.saltSkipLink {
top: 0;
Expand All @@ -31,22 +14,15 @@
.saltSkipLink:focus {
opacity: 1;
width: auto;
height: auto;
height: max(var(--salt-size-base), auto);
white-space: nowrap;
margin: var(--skipLink-margin);
padding: calc(var(--skipLink-padding) - 1px) var(--skipLink-padding) var(--skipLink-padding);
background: var(--skipLink-background);
color: var(--skipLink-color);
box-shadow: var(--salt-overlayable-shadow-popout);
}

.saltSkipLink {
font-size: var(--salt-text-fontSize);
font-family: var(--saltSkipLink-fontFamily, var(--salt-text-fontFamily));
line-height: var(--saltSkipLink-lineHeight, var(--salt-text-lineHeight));
background: var(--saltSkipLink-background, var(--salt-container-primary-background));
padding: var(--salt-spacing-100) var(--salt-spacing-300);
box-shadow: var(--salt-overlayable-shadow);
outline-offset: calc(-1 * var(--salt-focused-outlineWidth));
}

/*Styles applied to the skip link focus target*/
.saltSkipLink-target {
outline: var(--skipLink-target-focus);
.saltSkipLink.saltLink:focus, .saltSkipLink.saltLink:hover {
text-decoration: var(--salt-navigable-textDecoration);
color: var(--salt-content-primary-foreground);
}
2 changes: 1 addition & 1 deletion packages/lab/src/skip-link/SkipLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Link, type LinkProps, makePrefixer } from "@salt-ds/core";
import { useComponentCssInjection } from "@salt-ds/styles";
import { useWindow } from "@salt-ds/window";
import { clsx } from "clsx";
import { type RefObject, forwardRef } from "react";
import { forwardRef, type RefObject } from "react";
import { useManageFocusOnTarget } from "./internal/useManageFocusOnTarget";

import skipLinkCss from "./SkipLink.css";
Expand Down
1 change: 0 additions & 1 deletion packages/lab/src/skip-link/SkipLinks.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
float: left;
list-style: none;
margin: 0;
padding: 0;
}
73 changes: 30 additions & 43 deletions packages/lab/stories/skip-link/skip-link.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Button } from "@salt-ds/core";
import {
Button,
Divider,
H2,
H3,
SplitLayout,
StackLayout,
Text,
} from "@salt-ds/core";
import { SkipLink, SkipLinks } from "@salt-ds/lab";
import type { Meta, StoryFn } from "@storybook/react";
import { useRef } from "react";
import "./skip-link.stories.css";

export default {
title: "Lab/Skip Link",
Expand All @@ -13,30 +20,22 @@ export const Default: StoryFn<typeof SkipLink> = () => {
const articleRef = useRef<HTMLElement>(null);

return (
<>
<span style={{ height: 50, lineHeight: "50px" }} tabIndex={-1}>
<StackLayout style={{ maxWidth: 500 }}>
<Text tabIndex={-1}>
Click here and press the Tab key to see the Skip Link
</span>
<div style={{ position: "relative", maxWidth: 500 }}>
</Text>
<div>
<SkipLinks>
<SkipLink data-testid="skipLink" href="#main" targetRef={articleRef}>
Skip to main content
</SkipLink>
</SkipLinks>

<div
style={{
borderTop: "2px solid grey",
fontSize: 24,
lineHeight: 3.5,
}}
>
What we do
</div>
<Divider />
<H2>What we do</H2>

<article id="main" ref={articleRef}>
<section>
<h1>Salt</h1>
<H3>Salt</H3>
<p>
Salt provides you with a suite of UI components and a flexible
theming system. With no customisation, the default theme offers an
Expand All @@ -47,7 +46,7 @@ export const Default: StoryFn<typeof SkipLink> = () => {
</p>
</section>
<section>
<h1>Goals</h1>
<H3>Goals</H3>
<p>Salt has been developed with the following design goals:</p>
<ul className="goalsList">
<li>
Expand All @@ -60,11 +59,9 @@ export const Default: StoryFn<typeof SkipLink> = () => {
</ul>
</section>
</article>
<div style={{ overflow: "auto" }}>
<Button style={{ marginTop: 30, float: "right" }}>Next</Button>
</div>
<SplitLayout endItem={<Button style={{}}>Next</Button>} />
</div>
</>
</StackLayout>
);
};

Expand All @@ -73,11 +70,11 @@ export const MultipleLinks: StoryFn<typeof SkipLink> = () => {
const sectionRef2 = useRef<HTMLElement>(null);

return (
<>
<span style={{ height: 50, lineHeight: "50px" }} tabIndex={-1}>
<StackLayout style={{ maxWidth: 500 }}>
<Text tabIndex={-1}>
Click here and press the Tab key to see the Skip Link
</span>
<div style={{ position: "relative", maxWidth: 500 }}>
</Text>
<div>
<SkipLinks>
<SkipLink href="#introduction" targetRef={sectionRef1}>
Skip to Introduction
Expand All @@ -86,20 +83,12 @@ export const MultipleLinks: StoryFn<typeof SkipLink> = () => {
Skip to Goals
</SkipLink>
</SkipLinks>

<div
style={{
borderTop: "2px solid grey",
fontSize: 24,
lineHeight: 3.5,
}}
>
What we do
</div>
<Divider />
<H2>What we do</H2>

<article>
<section id="introduction" ref={sectionRef1}>
<h1>Salt</h1>
<section id="intro" ref={sectionRef1}>
<H3>Salt</H3>
<p>
Salt provides you with a suite of UI components and a flexible
theming system. With no customisation, the default theme offers an
Expand All @@ -110,7 +99,7 @@ export const MultipleLinks: StoryFn<typeof SkipLink> = () => {
</p>
</section>
<section id="goals" ref={sectionRef2}>
<h1>Goals</h1>
<H3>Goals</H3>
<p>Salt has been developed with the following design goals:</p>
<ul className="goalsList">
<li>
Expand All @@ -123,10 +112,8 @@ export const MultipleLinks: StoryFn<typeof SkipLink> = () => {
</ul>
</section>
</article>
<div style={{ overflow: "auto" }}>
<Button style={{ marginTop: 30, float: "right" }}>Next</Button>
</div>
<SplitLayout endItem={<Button style={{}}>Next</Button>} />
</div>
</>
</StackLayout>
);
};

0 comments on commit c326a4f

Please sign in to comment.