Skip to content

Commit

Permalink
refactor: add support for nested components
Browse files Browse the repository at this point in the history
this applies to form and meter. Form should no longer render a guidelines
link card, and meter should navigate to its own guidelines page instead
of progress bar's.
  • Loading branch information
marissahuysentruyt committed Sep 19, 2024
1 parent 3719d9e commit 0ac451e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .storybook/blocks/ComponentDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ export const ResourceLinkContent = ({data, linkType=["package", "repository", "g
// componentBetaName: for components with guidelines that are still on spectrum-contributions/beta site
let packageAltName = "";
let packageAltLink = "";

// For form and meter, both are nested within other component package.json files
let nestedComponent = packageJson?.nestedComponentName ?? undefined;

if(linkType === "package") {
// NPM package name and link
Expand All @@ -269,6 +272,16 @@ export const ResourceLinkContent = ({data, linkType=["package", "repository", "g
else if (linkType === "guidelines") {
// guidelines site name and link
packageName = packageJson?.componentGuidelinesName ?? undefined;

// TODO: This may not be a sustainable approach to targeting specific nested components. For example, text area is sort of nested under text field, but we don't surface text area as a separate component, like meter or form. We should probably refactor this to either support nested components more dynamically or potentially un-nest components.
if (nestedComponent === "form") {
packageName = undefined;
}

if (nestedComponent === "meter") {
packageName = nestedComponent;
}

packageLink = (packageName && typeof packageName !== "undefined") ? `https://spectrum.adobe.com/page/${packageName}` : false;

// internal contributions/beta guidelines name and link
Expand Down
3 changes: 2 additions & 1 deletion components/fieldlabel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@
"publishConfig": {
"access": "public"
},
"componentGuidelinesName": "field-label"
"componentGuidelinesName": "field-label",
"nestedComponentName": "form"
}
3 changes: 2 additions & 1 deletion components/progressbar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@
"publishConfig": {
"access": "public"
},
"componentGuidelinesName": "progress-bar"
"componentGuidelinesName": "progress-bar",
"nestedComponentName": "meter"
}

0 comments on commit 0ac451e

Please sign in to comment.