Skip to content

Commit

Permalink
chore(storybook): link to swc on docs pages (#3356)
Browse files Browse the repository at this point in the history
  • Loading branch information
castastrophe authored Nov 1, 2024
1 parent 38adbe1 commit 5eea58b
Show file tree
Hide file tree
Showing 63 changed files with 191 additions and 65 deletions.
4 changes: 3 additions & 1 deletion .storybook/assets/base.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* stylelint-disable selector-class-pattern -- Targeting pre-defined Storybook classes */

/*!
* Copyright 2024 Adobe. All rights reserved.
*
Expand All @@ -11,7 +13,6 @@
* governing permissions and limitations under the License.
*/

/* stylelint-disable selector-class-pattern */
body {
--spectrum-font-family: var(--spectrum-sans-font-family-stack);
--spectrum-font-style: var(--spectrum-default-font-style);
Expand Down Expand Up @@ -67,4 +68,5 @@ svg:has(symbol):not(:has(use)) {
story view), due to Storybook's inline style that sets overflow: auto */
overflow: visible !important;
}

/* stylelint-enable selector-class-pattern */
28 changes: 28 additions & 0 deletions .storybook/assets/images/wc_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion .storybook/assets/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* stylelint-disable selector-class-pattern -- Targeting pre-defined Storybook classes */

/*!
* Copyright 2024 Adobe. All rights reserved.
*
Expand All @@ -11,7 +13,6 @@
* governing permissions and limitations under the License.
*/

/* stylelint-disable selector-class-pattern */
body {
--spectrum-font-family-ar: myriad-arabic, adobe-clean, "Source Sans Pro", -apple-system, blinkmacsystemfont, "Segoe UI", roboto, ubuntu, "Trebuchet MS", "Lucida Grande", sans-serif;
--spectrum-font-family-he: myriad-hebrew, adobe-clean, "Source Sans Pro", -apple-system, blinkmacsystemfont, "Segoe UI", roboto, ubuntu, "Trebuchet MS", "Lucida Grande", sans-serif;
Expand Down Expand Up @@ -66,6 +67,15 @@ nav .spectrum-Site-logo {
padding: 20px !important;
}

/* Hide that first divider line in the top navigation */
div.sb-bar > div > div > span:first-child {
display: none;
}

div.sb-bar > div > div > div > button {
background-color: white !important;
}

.docblock-argstable-body tr td {
letter-spacing: unset;
font-size: 11px;
Expand Down Expand Up @@ -118,4 +128,5 @@ select:focus,
border-color: rgb(2, 101, 220) !important;
box-shadow: rgb(2, 101, 220) 0 0 0 1px inset !important;
}

/* stylelint-enable selector-class-pattern */
22 changes: 19 additions & 3 deletions .storybook/blocks/ComponentDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useEffect, useState } from "react";
import AdobeSVG from "../assets/images/adobe_logo.svg?raw";
import GitHubSVG from "../assets/images/github_logo.svg?raw";
import NpmSVG from "../assets/images/npm_logo.svg?raw";
import WCSVG from "../assets/images/wc_logo.svg?raw";
import { Body, Code, Heading } from "./Typography.jsx";
import { fetchToken } from "./utilities.js";

Expand Down Expand Up @@ -121,6 +122,7 @@ export const ResourceLink = styled.a`
border-color: rgb(230, 230, 230);
overflow: hidden;
color: rgb(0, 0, 0);
background-color: rgba(255 255 255 / 80%);
&:hover {
border-color: rgb(213, 213, 213);
Expand Down Expand Up @@ -314,6 +316,8 @@ const fetchLogo = (brand) => {
return GitHubSVG;
case "Adobe":
return AdobeSVG;
case "WC":
return WCSVG;
}

return;
Expand Down Expand Up @@ -361,23 +365,35 @@ export const ResourceLinkContent = ({ heading, alt, logo, href }) => {
export const ResourceListDetails = ({ packageName, spectrumData = [], rootClassName, isDeprecated }) => {
if (!packageName) return;

let href;
let swc, href;

for(let i = 0; i < spectrumData?.length; i++) {
if (spectrumData[i]?.guidelines && spectrumData[i]?.rootClass === rootClassName) {
const thisComponent = !spectrumData[i]?.rootClass || spectrumData[i]?.rootClass === rootClassName;
if (spectrumData[i]?.guidelines && thisComponent) {
href = spectrumData[i]?.guidelines;
}

if (spectrumData[i]?.swc && thisComponent) {
swc = spectrumData[i]?.swc;
}
}

return (
<ResourceSection className="sb-unstyled">
{href ?
<ResourceLinkContent
className="doc-block-resource-cards"
heading="View guidelines"
heading="Design guidelines"
alt="Spectrum website"
logo="Adobe"
href={href}/> : ""}
{swc ?
<ResourceLinkContent
className="doc-block-resource-cards"
heading="Web components"
alt="Spectrum web components"
logo="WC"
href={swc}/> : ""}
<ResourceLinkContent
className="doc-block-resource-cards"
heading="View package"
Expand Down
3 changes: 2 additions & 1 deletion components/accordion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"spectrum": [
{
"guidelines": "https://spectrum-contributions.corp.adobe.com/page/accordion-beta",
"rootClass": "spectrum-Accordion"
"rootClass": "spectrum-Accordion",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/accordion/"
}
]
}
3 changes: 2 additions & 1 deletion components/actionbar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/action-bar",
"rootClass": "spectrum-ActionBar"
"rootClass": "spectrum-ActionBar",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/action-bar/"
}
]
}
3 changes: 2 additions & 1 deletion components/actionbutton/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/action-button",
"rootClass": "spectrum-ActionButton"
"rootClass": "spectrum-ActionButton",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/action-button/"
}
]
}
3 changes: 2 additions & 1 deletion components/actiongroup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/action-group",
"rootClass": "spectrum-ActionGroup"
"rootClass": "spectrum-ActionGroup",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/action-group/"
}
]
}
7 changes: 6 additions & 1 deletion components/actionmenu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@
],
"publishConfig": {
"access": "public"
}
},
"spectrum": [
{
"swc": "https://opensource.adobe.com/spectrum-web-components/components/action-menu/"
}
]
}
3 changes: 2 additions & 1 deletion components/alertbanner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/alert-banner",
"rootClass": "spectrum-AlertBanner"
"rootClass": "spectrum-AlertBanner",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/alert-banner/"
}
]
}
3 changes: 2 additions & 1 deletion components/alertdialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/alert-dialog",
"rootClass": "spectrum-AlertDialog"
"rootClass": "spectrum-AlertDialog",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/alert-dialog/"
}
]
}
3 changes: 2 additions & 1 deletion components/asset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
},
"spectrum": [
{
"rootClass": "spectrum-Asset"
"rootClass": "spectrum-Asset",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/asset/"
}
]
}
3 changes: 2 additions & 1 deletion components/avatar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/avatar",
"rootClass": "spectrum-Avatar"
"rootClass": "spectrum-Avatar",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/avatar/"
}
]
}
3 changes: 2 additions & 1 deletion components/badge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/badge",
"rootClass": "spectrum-Badge"
"rootClass": "spectrum-Badge",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/badge/"
}
]
}
3 changes: 2 additions & 1 deletion components/breadcrumb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/breadcrumbs",
"rootClass": "spectrum-Breadcrumbs"
"rootClass": "spectrum-Breadcrumbs",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/breadcrumbs/"
}
]
}
3 changes: 2 additions & 1 deletion components/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/button",
"rootClass": "spectrum-Button"
"rootClass": "spectrum-Button",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/button/"
}
]
}
3 changes: 2 additions & 1 deletion components/buttongroup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/button-group",
"rootClass": "spectrum-ButtonGroup"
"rootClass": "spectrum-ButtonGroup",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/button-group/"
}
]
}
3 changes: 2 additions & 1 deletion components/card/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/cards",
"rootClass": "spectrum-Card"
"rootClass": "spectrum-Card",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/card/"
}
]
}
3 changes: 2 additions & 1 deletion components/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/checkbox",
"rootClass": "spectrum-Checkbox"
"rootClass": "spectrum-Checkbox",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/checkbox/"
}
]
}
3 changes: 2 additions & 1 deletion components/coachindicator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"spectrum": [
{
"guidelines": "https://spectrum-contributions.corp.adobe.com/page/coach-indicator-beta",
"rootClass": "spectrum-CoachIndicator"
"rootClass": "spectrum-CoachIndicator",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/coach-indicator/"
}
]
}
3 changes: 2 additions & 1 deletion components/coachmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/coach-mark",
"rootClass": "spectrum-CoachMark"
"rootClass": "spectrum-CoachMark",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/coachmark/"
}
]
}
3 changes: 2 additions & 1 deletion components/colorarea/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/color-area",
"rootClass": "spectrum-ColorArea"
"rootClass": "spectrum-ColorArea",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/color-area/"
}
]
}
3 changes: 2 additions & 1 deletion components/colorhandle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
},
"spectrum": [
{
"rootClass": "spectrum-ColorHandle"
"rootClass": "spectrum-ColorHandle",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/color-handle/"
}
]
}
3 changes: 2 additions & 1 deletion components/colorloupe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/color-loupe",
"rootClass": "spectrum-ColorLoupe"
"rootClass": "spectrum-ColorLoupe",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/color-loupe/"
}
]
}
3 changes: 2 additions & 1 deletion components/colorslider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/color-slider",
"rootClass": "spectrum-ColorSlider"
"rootClass": "spectrum-ColorSlider",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/color-slider/"
}
]
}
3 changes: 2 additions & 1 deletion components/colorwheel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/color-wheel",
"rootClass": "spectrum-ColorWheel"
"rootClass": "spectrum-ColorWheel",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/color-wheel/"
}
]
}
3 changes: 2 additions & 1 deletion components/combobox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/combo-box",
"rootClass": "spectrum-Combobox"
"rootClass": "spectrum-Combobox",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/combobox/"
}
]
}
3 changes: 2 additions & 1 deletion components/contextualhelp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"spectrum": [
{
"guidelines": "https://spectrum.adobe.com/page/contextual-help",
"rootClass": "spectrum-ContextualHelp"
"rootClass": "spectrum-ContextualHelp",
"swc": "https://opensource.adobe.com/spectrum-web-components/components/contextual-help/"
}
]
}
Loading

0 comments on commit 5eea58b

Please sign in to comment.