Skip to content

feat(contextual-help): S2 migration #3909

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
wants to merge 4 commits into
base: spectrum-two
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .changeset/legal-lands-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
"@spectrum-css/contextualhelp": major
---

#### S2 migration for contextual help

This migrates the `contextual help` component to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification.

Typographic and color tokens have been updated per design specifications.

All existing popover positioning varations are supported.

##### New custom properties

`--spectrum-contextual-help-body-color`
`--spectrum-contextual-help-body-line-height`
`--spectrum-contextual-help-body-sans-serif-font-family`
`--spectrum-contextual-help-body-sans-serif-font-style`
`--spectrum-contextual-help-body-sans-serif-font-weight`
`--spectrum-contextual-help-title-color`
`--spectrum-contextual-help-title-font-style`
`--spectrum-contextual-help-title-font-weight`
`--spectrum-contextual-help-title-line-height`
`--spectrum-contextual-help-title-sans-serif-font-family`

##### New mods

`--mod-contextual-help-body-line-height`
`--mod-contextual-help-body-sans-serif-font-family`
`--mod-contextual-help-body-sans-serif-font-style`
`--mod-contextual-help-body-sans-serif-font-weight`
`--mod-contextual-help-body-size`
`--mod-contextual-help-title-color`
`--mod-contextual-help-title-font-style`
`--mod-contextual-help-title-font-weight`
`--mod-contextual-help-title-line-height`
`--mod-contextual-help-title-sans-serif-font-family`
`--highcontrast-contextual-help-heading-color`
`--highcontrast-contextual-help-title-color`
32 changes: 29 additions & 3 deletions components/contextualhelp/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
],
"modifiers": [
"--mod-contextual-help-body-color",
"--mod-contextual-help-heading-color",
"--mod-contextual-help-body-line-height",
"--mod-contextual-help-body-sans-serif-font-family",
"--mod-contextual-help-body-sans-serif-font-style",
"--mod-contextual-help-body-sans-serif-font-weight",
"--mod-contextual-help-body-size",
"--mod-contextual-help-title-color",
"--mod-contextual-help-title-font-style",
"--mod-contextual-help-title-font-weight",
"--mod-contextual-help-title-line-height",
"--mod-contextual-help-title-sans-serif-font-family",
"--mod-spectrum-contextual-help-body-size",
"--mod-spectrum-contextual-help-content-spacing",
"--mod-spectrum-contextual-help-heading-size",
Expand All @@ -20,20 +29,37 @@
"--mod-spectrum-contextual-help-popover-maximum-width"
],
"component": [
"--spectrum-contextual-help-body-color",
"--spectrum-contextual-help-body-line-height",
"--spectrum-contextual-help-body-sans-serif-font-family",
"--spectrum-contextual-help-body-sans-serif-font-style",
"--spectrum-contextual-help-body-sans-serif-font-weight",
"--spectrum-contextual-help-body-size",
"--spectrum-contextual-help-content-spacing",
"--spectrum-contextual-help-minimum-width",
"--spectrum-contextual-help-title-color",
"--spectrum-contextual-help-title-font-style",
"--spectrum-contextual-help-title-font-weight",
"--spectrum-contextual-help-title-line-height",
"--spectrum-contextual-help-title-sans-serif-font-family",
"--spectrum-contextual-help-title-size"
],
"global": [
"--spectrum-body-color",
"--spectrum-body-sans-serif-font-style",
"--spectrum-body-sans-serif-font-weight",
"--spectrum-heading-color",
"--spectrum-line-height-200",
"--spectrum-sans-font-family-stack",
"--spectrum-spacing-300",
"--spectrum-spacing-400"
"--spectrum-spacing-400",
"--spectrum-title-line-height",
"--spectrum-title-sans-serif-font-style",
"--spectrum-title-sans-serif-font-weight"
],
"passthroughs": [],
"high-contrast": [
"--highcontrast-contextual-help-body-color",
"--highcontrast-contextual-help-heading-color"
"--highcontrast-contextual-help-title-color"
]
}
40 changes: 34 additions & 6 deletions components/contextualhelp/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2024 Adobe. All rights reserved.
* Copyright 2025 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
Expand All @@ -11,6 +11,22 @@
* governing permissions and limitations under the License.
*/

.spectrum-ContextualHelp {
--spectrum-contextual-help-title-sans-serif-font-family: var(--spectrum-sans-font-family-stack);
--spectrum-contextual-help-title-font-weight: var(--spectrum-title-sans-serif-font-weight);
--spectrum-contextual-help-title-font-style: var(--spectrum-title-sans-serif-font-style);
--spectrum-contextual-help-title-line-height: var(--spectrum-title-line-height);

--spectrum-contextual-help-title-color: var(--spectrum-heading-color);

--spectrum-contextual-help-body-sans-serif-font-family: var(--spectrum-sans-font-family-stack);
--spectrum-contextual-help-body-sans-serif-font-weight: var(--spectrum-body-sans-serif-font-weight);
--spectrum-contextual-help-body-sans-serif-font-style: var(--spectrum-body-sans-serif-font-style);
--spectrum-contextual-help-body-line-height: var(--spectrum-line-height-200);

--spectrum-contextual-help-body-color: var(--spectrum-body-color);
Comment on lines +22 to +27
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's so funny this ties right into our conversation this morning in backlog grooming! I think this makes a lot of sense here for now but I am interested in exploring more how typography can inherit better from the cascade without requiring so much intervention.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — it struck me as being quite verbose. I'd love something simpler. ✨

}

.spectrum-ContextualHelp {
position: relative;
min-inline-size: var(--mod-spectrum-contextual-help-minimum-width, var(--spectrum-contextual-help-minimum-width));
Expand All @@ -21,8 +37,7 @@
}

.spectrum-ContextualHelp-popover {
padding-block: var(--mod-spectrum-contextual-help-padding, var(--spectrum-spacing-400));
padding-inline: var(--mod-spectrum-contextual-help-padding, var(--spectrum-spacing-400));
padding: var(--mod-spectrum-contextual-help-padding, var(--spectrum-spacing-400));
font-size: var(--mod-spectrum-contextual-help-body-size, var(--spectrum-contextual-help-body-size));
color: var(--highcontrast-contextual-help-body-color, var(--mod-contextual-help-body-color, var(--spectrum-body-color)));

Expand All @@ -34,9 +49,22 @@
}

.spectrum-ContextualHelp-heading {
margin-block-end: var(--mod-spectrum-contextual-help-content-spacing, var(--spectrum-contextual-help-content-spacing));
font-family: var(--mod-contextual-help-title-sans-serif-font-family, var(--spectrum-contextual-help-title-sans-serif-font-family));
font-weight: var(--mod-contextual-help-title-font-weight, var(--spectrum-contextual-help-title-font-weight));
font-size: var(--mod-spectrum-contextual-help-heading-size, var(--spectrum-contextual-help-title-size));
color: var(--highcontrast-contextual-help-heading-color, var(--mod-contextual-help-heading-color, var(--spectrum-heading-color)));
font-style: var(--mod-contextual-help-title-font-style, var(--spectrum-contextual-help-title-font-style));
line-height: var(--mod-contextual-help-title-line-height, var(--spectrum-contextual-help-title-line-height));
color: var(--highcontrast-contextual-help-title-color, var(--mod-contextual-help-title-color, var(--spectrum-contextual-help-title-color)));
margin-block-end: var(--mod-spectrum-contextual-help-content-spacing, var(--spectrum-contextual-help-content-spacing));
}

.spectrum-ContextualHelp-body {
font-size: var(--mod-contextual-help-body-size, var(--spectrum-contextual-help-body-size));
font-family: var(--mod-contextual-help-body-sans-serif-font-family, var(--spectrum-contextual-help-body-sans-serif-font-family));
font-weight: var(--mod-contextual-help-body-sans-serif-font-weight, var(--spectrum-contextual-help-body-sans-serif-font-weight));
font-style: var(--mod-contextual-help-body-sans-serif-font-style, var(--spectrum-contextual-help-body-sans-serif-font-style));
line-height: var(--mod-contextual-help-body-line-height, var(--spectrum-contextual-help-body-line-height));
color: var(--mod-contextual-help-body-color, var(--spectrum-contextual-help-body-color));
}
}

Expand All @@ -46,7 +74,7 @@

@media (forced-colors: active) {
.spectrum-ContextualHelp {
--highcontrast-contextual-help-heading-color: CanvasText;
--highcontrast-contextual-help-title-color: CanvasText;
--highcontrast-contextual-help-body-color: CanvasText;
}
}
80 changes: 15 additions & 65 deletions components/contextualhelp/stories/contextualhelp.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export default {
iconName: {
name: "Icon",
type: { name: "string", required: true },
defaultValue: "Info",
defaultValue: "InfoCircle",
table: {
type: { summary: "string" },
category: "Component",
defaultValue: { summary: "Info" },
},
options: ["Info", "Help"],
options: ["InfoCircle", "HelpCircle"],
control: "select",
},
iconSet: { table: { disable: true } },
Expand Down Expand Up @@ -76,13 +76,23 @@ export default {
],
control: "select",
},
link: { table: { disable: true } },
link: {
name: "Has link",
type: { name: "boolean", required: false },
defaultValue: false,
table: {
summary: "boolean",
category: "Component",
defaultValue: { summary: false }
}
},
},
args: {
rootClass: "spectrum-ContextualHelp",
iconName: "Info",
iconName: "InfoCircle",
iconSet: "workflow",
popoverPlacement: "bottom-start",
link: false,
title: "Permission required",
body: "Your admin must grant you permission before you can create a new document. Please contact your admin for more information.",
customStyles: { "inline-size": "275px" },
Expand Down Expand Up @@ -180,74 +190,14 @@ TopPopover.storyName = "Default - top popover";
export const HelpDefault = Template.bind({});
HelpDefault.tags = ["!dev"];
HelpDefault.args = {
iconName: "Help",
iconName: "HelpCircle",
title: "Need help?",
};
HelpDefault.parameters = {
chromatic: { disableSnapshot: true },
};
HelpDefault.storyName = "Help icon";

export const HelpWithLink = Template.bind({});
HelpWithLink.tags = ["!dev"];
HelpWithLink.args = {
link: {
text: "Learn about permissions",
url: "#",
},
iconName: "Help",
title: "Need help?",
body: "Reach out to your admin for help regarding the document you are trying to create.",
};
HelpWithLink.parameters = {
chromatic: { disableSnapshot: true },
};
HelpWithLink.storyName = "Help icon - with link";

export const HelpTopPopover = Template.bind({});
HelpTopPopover.tags = ["!dev"];
HelpTopPopover.args = {
popoverPlacement: "top",
customStyles: {
"inline-size": "275px",
"margin-top": "170px",
},
title: "Need help?",
body: "Reach out to your admin for help regarding the document you are trying to create.",
iconName: "Help",
};
HelpTopPopover.parameters = {
chromatic: { disableSnapshot: true },
docs: {
story: {
height: "auto",
},
},
};
HelpTopPopover.storyName = "Help icon - top popover";

export const HelpMaxWidthPopover = Template.bind({});
HelpMaxWidthPopover.tags = ["!dev"];
HelpMaxWidthPopover.args = {
customStyles: {
"inline-size": "275px",
"--mod-spectrum-contextual-help-popover-maximum-width": "180px",
"margin-bottom": "270px",
},
title: "Need help?",
body: "Reach out to your admin for help regarding the document you are trying to create.",
iconName: "Help",
};
HelpMaxWidthPopover.parameters = {
chromatic: { disableSnapshot: true },
docs: {
story: {
height: "auto",
},
},
};
HelpMaxWidthPopover.storyName = "Help icon - max width popover";

// ********* VRT ONLY ********* //
export const WithForcedColors = ContextualHelpGroup.bind({});
WithForcedColors.args = Default.args;
Expand Down
7 changes: 2 additions & 5 deletions components/contextualhelp/stories/contextualhelp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ export const ContextualHelpGroup = Variants({
"inline-size": "275px",
"margin-bottom": "200px",
},
link: {
text: "Learn about permissions",
url: "#",
},
link: true,
},
{
testHeading: "Help",
iconName: "Help",
iconName: "HelpCircle",
customStyles: {
"inline-size": "275px",
"margin-bottom": "170px",
Expand Down
4 changes: 2 additions & 2 deletions components/contextualhelp/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const Template = ({
body ? html`<p class="${rootClass}-body">${body}</p>` : "",
link
? Link({
text: link.text,
url: link.url,
text: "Link text",
url: "#",
customClasses: [`${rootClass}-link`],
})
: nothing,
Expand Down
Loading