-
Notifications
You must be signed in to change notification settings - Fork 249
feat(link): 2nd-gen template, stories, styling #6326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aramos-adobe
wants to merge
5
commits into
main
Choose a base branch
from
aziz/link-files-api-styles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bf4bda9
feat(link): 2nd-gen template, stories, styling
aramos-adobe 19c5d56
Merge branch 'main' into aziz/link-files-api-styles
aramos-adobe 08d6f77
feat(link): resolving feedback
aramos-adobe 4b04d34
feat(link): fixing css structure
aramos-adobe 060ffbb
Merge branch 'main' into aziz/link-files-api-styles
aramos-adobe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
137 changes: 137 additions & 0 deletions
137
2nd-gen/packages/swc/components/link/migration-guide.mdx
This file contains hidden or 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,137 @@ | ||
| import { Meta } from '@storybook/addon-docs/blocks'; | ||
|
|
||
| <Meta title="Link/Migration guide" /> | ||
|
|
||
| # Link migration guide | ||
|
|
||
| Spectrum 2 delivers links as **native `<a href>` elements** with CSS — there is no `swc-link` custom element. Replace `<sp-link>` with semantic anchors and the styles documented below. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| # Remove | ||
| yarn remove @spectrum-web-components/link | ||
|
|
||
| # Add | ||
| yarn add @adobe/spectrum-wc | ||
| ``` | ||
|
|
||
| ## Stylesheets | ||
|
|
||
| | Stylesheet | Import | Purpose | | ||
| | ---------------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------- | | ||
| | `typography.css` | `@adobe/spectrum-wc/typography.css` | Default link appearance inside **`.swc-Typography--prose`** and **`.swc-Typography--links`** | | ||
| | `link.css` | `@adobe/spectrum-wc/link.css` | BEM modifier classes for standalone / secondary / quiet / static-color anchors | | ||
| | `global-link.css` (optional) | `@adobe/spectrum-wc/global-link.css` | Opt-in baseline for **bare** `<a>` without classes | | ||
|
|
||
| > Default in-body and link-list styling ships with **Typography** — see the [Typography migration guide](../typography/migration-guide.mdx) for prose and wrapper patterns. This guide covers explicit link modifiers and migrating from `sp-link`. | ||
|
|
||
| ```js | ||
| // Prose / link lists (typography wrappers style unclassed anchors) | ||
| import '@adobe/spectrum-wc/typography.css'; | ||
|
|
||
| // Explicit modifiers on individual anchors | ||
| import '@adobe/spectrum-wc/link.css'; | ||
| ``` | ||
|
|
||
| ## What changed | ||
|
|
||
| ### Architecture | ||
|
|
||
| | Area | Spectrum 1 (`sp-link`) | Spectrum 2 | | ||
| | -------------------- | --------------------------------------------- | ---------------------------------------------------- | | ||
| | Element | `<sp-link href="#">` shadow host | Native `<a href="#">` | | ||
| | Presentation | `variant`, `quiet`, `static-color` attributes | BEM classes on `<a>` (and typography wrappers) | | ||
| | In-body copy | Per-link custom element | `<a href>` inside `.swc-Typography--prose` | | ||
| | Link lists / footers | `sp-link` in lists | `<ul class="swc-Typography--links">` with `<a href>` | | ||
|
|
||
| ### Attribute → class mapping | ||
|
|
||
| | `sp-link` attribute | Spectrum 2 | | ||
| | ---------------------- | ----------------------------------------------------------------------------------------------------------------------- | | ||
| | (default) | Unclassed `<a>` inside `.swc-Typography--prose` or `.swc-Typography--links`, or `class="swc-Link swc-Link--standalone"` | | ||
| | `variant="secondary"` | `class="swc-Link swc-Link--secondary"` | | ||
| | `quiet` | `class="swc-Link swc-Link--quiet swc-Link--standalone"` (section / footer contexts only) | | ||
| | `static-color="white"` | `class="swc-Link swc-Link--staticWhite"` | | ||
| | `static-color="black"` | `class="swc-Link swc-Link--staticBlack"` | | ||
| | `disabled` | **Not supported** on navigational links — use a disabled `<button>` or remove the control | | ||
|
|
||
| Behavioral attributes (`href`, `target`, `rel`, `download`, `referrerpolicy`, `aria-label`) remain standard HTML on `<a>`. | ||
|
|
||
| ### Removed | ||
|
|
||
| | Removed | Replacement | | ||
| | ---------------------------- | ------------------------------------------------- | | ||
| | `<sp-link>` | `<a href>` + typography and/or `link.css` classes | | ||
| | `disabled` on links | Disabled button, or remove link | | ||
| | `inline` as author attribute | Links in prose inherit typography automatically | | ||
|
|
||
| ## Update your code | ||
|
|
||
| ### 1. Prose and running text | ||
|
|
||
| ```html | ||
| <!-- Before --> | ||
| <p class="spectrum-Body"> | ||
| Read the | ||
| <sp-link href="/docs">documentation</sp-link> | ||
| for details. | ||
| </p> | ||
|
|
||
| <!-- After --> | ||
| <div class="swc-Typography--prose"> | ||
| <p> | ||
| Read the | ||
| <a href="/docs">documentation</a> | ||
| for details. | ||
| </p> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### 2. Link lists (footers, sidebars) | ||
|
|
||
| ```html | ||
| <ul class="swc-Typography--links"> | ||
| <li><a href="/privacy">Privacy</a></li> | ||
| <li><a href="/terms">Terms</a></li> | ||
| <li><a href="/help">Help</a></li> | ||
| </ul> | ||
| ``` | ||
|
|
||
| ### 3. Standalone link with modifiers | ||
|
|
||
| ```html | ||
| <a class="swc-Link swc-Link--standalone" href="/account">Account settings</a> | ||
| <a class="swc-Link swc-Link--secondary swc-Link--standalone" href="/learn-more"> | ||
| Learn more | ||
| </a> | ||
| ``` | ||
|
|
||
| ### 4. Quiet links in section context | ||
|
|
||
| Use quiet styling only where surrounding context makes links obvious (for example footers). Pair **`swc-Link--quiet`** with **`swc-Link--standalone`**: | ||
|
|
||
| ```html | ||
| <footer> | ||
| <a class="swc-Link swc-Link--quiet swc-Link--standalone" href="/privacy"> | ||
| Privacy | ||
| </a> | ||
| </footer> | ||
| ``` | ||
|
|
||
| ## Accessibility | ||
|
|
||
| - Use real `<a href>` for navigation; avoid JavaScript-only fake links. | ||
| - Do not use `disabled` on anchors — it is not valid for navigational links. | ||
| - Icon-only links need an accessible name (`aria-label` or visible text). | ||
| - Restrict **quiet** styling to approved section patterns, not undifferentiated long-form body copy. | ||
|
|
||
| See [Semantic HTML and ARIA](../../.storybook/guides/accessibility-guides/semantic_html_aria.mdx) and the contributor [accessibility migration analysis](https://github.com/adobe/spectrum-web-components/blob/main/CONTRIBUTOR-DOCS/03_project-planning/03_components/link/accessibility-migration-analysis.md). | ||
|
|
||
| ## Checklist | ||
|
|
||
| - [ ] Replace `<sp-link>` with `<a href>` in prose (`swc-Typography--prose`) and link lists (`swc-Typography--links`) | ||
| - [ ] Import `@adobe/spectrum-wc/typography.css` (and `link.css` when using BEM modifiers) | ||
| - [ ] Map `variant`, `quiet`, and `static-color` to BEM classes | ||
| - [ ] Remove `disabled` from links; use button + routing where needed | ||
| - [ ] Retest contrast for links adjacent to body text |
177 changes: 177 additions & 0 deletions
177
2nd-gen/packages/swc/components/link/stories/link.stories.ts
This file contains hidden or 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,177 @@ | ||
| /** | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import { html } from 'lit'; | ||
| import type { Meta, StoryObj as Story } from '@storybook/web-components'; | ||
|
|
||
| import { | ||
| CONTEXTS, | ||
| LANGS, | ||
| type LinkTemplateProps, | ||
| SIZES, | ||
| template, | ||
| VARIANTS, | ||
| } from './link.template.js'; | ||
|
|
||
| /** | ||
| * Link presentation uses native `<a href>` with BEM classes from `link.css`. | ||
| * | ||
| * Default anchor appearance inside prose and link lists ships with | ||
| * `typography.css` — see [Typography / Prose container](../typography/stories/typography.stories.ts) | ||
| * and [Typography / Link list](../typography/stories/typography.stories.ts). | ||
| */ | ||
| const meta: Meta<LinkTemplateProps> = { | ||
| title: 'Link', | ||
| parameters: { | ||
| docs: { | ||
| subtitle: | ||
| 'Native anchors with `.swc-Link` modifier classes. Import `@adobe/spectrum-wc/link.css`.', | ||
| }, | ||
| }, | ||
| argTypes: { | ||
| variant: { control: 'select', options: VARIANTS }, | ||
| context: { control: 'select', options: CONTEXTS }, | ||
| size: { | ||
| control: 'select', | ||
| options: SIZES, | ||
| description: | ||
| 'Prose and link lists: `swc-Body--size*`. Standalone: `--swc-link-font-size`.', | ||
| }, | ||
| quiet: { | ||
| control: 'boolean', | ||
| description: | ||
| 'Removes underline until hover. Only applies with standalone context (pairs with `swc-Link--standalone`).', | ||
| }, | ||
| inline: { | ||
| control: 'boolean', | ||
| description: | ||
| 'Uses regular font weight on standalone links (S2 inline behavior).', | ||
| }, | ||
| lang: { control: 'select', options: LANGS }, | ||
| href: { control: 'text' }, | ||
| sampleText: { control: 'text' }, | ||
| showAllVariants: { control: 'boolean' }, | ||
| }, | ||
| render: (args) => html` | ||
| ${template(args)} | ||
| `, | ||
| tags: ['migrated', 'utility'], | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| export const Playground: Story = { | ||
| args: { | ||
| variant: 'default', | ||
| context: 'standalone', | ||
|
aramos-adobe marked this conversation as resolved.
Outdated
|
||
| size: 'M', | ||
| quiet: false, | ||
| inline: false, | ||
| lang: undefined, | ||
| href: '#', | ||
| sampleText: '', | ||
| showAllVariants: false, | ||
| }, | ||
| parameters: { | ||
| docs: { | ||
| canvas: { | ||
| sourceState: 'shown', | ||
| }, | ||
| }, | ||
| }, | ||
| tags: ['autodocs', 'dev'], | ||
| }; | ||
|
|
||
| /** | ||
| * Standalone link with explicit Spectrum typography (not inheriting a prose wrapper). | ||
| */ | ||
| export const Standalone: Story = { | ||
| args: { | ||
| context: 'standalone', | ||
| variant: 'default', | ||
| sampleText: 'Account settings', | ||
| }, | ||
| tags: ['options'], | ||
| }; | ||
|
|
||
| /** | ||
| * Secondary color treatment (replaces `sp-link variant="secondary"`). | ||
| */ | ||
| export const Secondary: Story = { | ||
| args: { | ||
| context: 'standalone', | ||
| variant: 'secondary', | ||
| sampleText: 'Learn more', | ||
| }, | ||
| tags: ['options'], | ||
| }; | ||
|
|
||
| /** | ||
| * Quiet + standalone removes the default underline until hover — use in footers | ||
| * and other section-scoped patterns, not undifferentiated body copy. | ||
| */ | ||
| export const QuietStandalone: Story = { | ||
| args: { | ||
| context: 'standalone', | ||
| variant: 'default', | ||
| quiet: true, | ||
| sampleText: 'Privacy policy', | ||
| }, | ||
| tags: ['options'], | ||
| }; | ||
|
|
||
| export const InProse: Story = { | ||
| args: { | ||
| context: 'prose', | ||
| variant: 'default', | ||
| size: 'M', | ||
| }, | ||
| tags: ['options'], | ||
| }; | ||
|
|
||
| export const LinkList: Story = { | ||
| args: { | ||
| context: 'links', | ||
| variant: 'default', | ||
| }, | ||
| tags: ['options'], | ||
| }; | ||
|
|
||
| export const StaticWhite: Story = { | ||
| args: { | ||
| context: 'standalone', | ||
| variant: 'staticWhite', | ||
| sampleText: 'white link', | ||
| }, | ||
| tags: ['options'], | ||
| }; | ||
|
|
||
| export const StaticBlack: Story = { | ||
| args: { | ||
| context: 'standalone', | ||
| variant: 'staticBlack', | ||
| sampleText: 'black link', | ||
| }, | ||
| tags: ['options'], | ||
| }; | ||
|
aramos-adobe marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * All color variants for side-by-side comparison. | ||
| */ | ||
| export const AllVariants: Story = { | ||
| args: { | ||
| context: 'standalone', | ||
| showAllVariants: true, | ||
| sampleText: 'Link label', | ||
| }, | ||
| tags: ['options'], | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.