Skip to content

Commit 71f7d4f

Browse files
feat(contextualhelp): add mod to allow max-width (#3523)
* feat(contextualhelp): add mod to allow max-width on popover Added `--mod-spectrum-contextual-help-popover-maximum-width` to customize popover max-width via `max-inline-size`. SWC had a feature request from the express team to support long text in the contextual-help popover. Jira ticket: [SWC-509](https://jira.corp.adobe.com/browse/SWC-509) --------- Co-authored-by: [ Cassondra ] <[email protected]>
1 parent 19305e2 commit 71f7d4f

File tree

4 files changed

+58
-13
lines changed

4 files changed

+58
-13
lines changed

.changeset/spicy-boats-repair.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@spectrum-css/contextualhelp": patch
3+
---
4+
5+
Added `--mod-spectrum-contextual-help-popover-maximum-width` to customize popover max-width via `max-inline-size`. SWC had a feature request from the express team to support long text in the contextual-help popover. Jira ticket: [SWC-509](https://jira.corp.adobe.com/browse/SWC-509)

components/contextualhelp/dist/metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"--mod-spectrum-contextual-help-heading-size",
1717
"--mod-spectrum-contextual-help-link-spacing",
1818
"--mod-spectrum-contextual-help-minimum-width",
19-
"--mod-spectrum-contextual-help-padding"
19+
"--mod-spectrum-contextual-help-padding",
20+
"--mod-spectrum-contextual-help-popover-maximum-width"
2021
],
2122
"component": [
2223
"--spectrum-contextual-help-body-size",

components/contextualhelp/index.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
font-size: var(--mod-spectrum-contextual-help-body-size, var(--spectrum-contextual-help-body-size));
2727
color: var(--highcontrast-contextual-help-body-color, var(--mod-contextual-help-body-color, var(--spectrum-body-color)));
2828

29+
max-inline-size: var(--mod-spectrum-contextual-help-popover-maximum-width);
30+
2931
.spectrum-ContextualHelp-heading,
3032
.spectrum-ContextualHelp-body {
3133
margin: 0;

components/contextualhelp/stories/contextualhelp.stories.js

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,12 @@ export default {
8484
iconSet: "workflow",
8585
popoverPlacement: "bottom-start",
8686
title: "Permission required",
87-
body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
87+
body: "Your admin must grant you permission before you can create a new document. Please contact your admin for more information.",
8888
customStyles: { "inline-size": "275px" },
8989
},
9090
parameters: {
9191
actions: {
92-
handles: [
93-
...(ActionButtonStories?.parameters?.actions?.handles ?? [])
94-
],
92+
handles: [...(ActionButtonStories?.parameters?.actions?.handles ?? [])],
9593
},
9694
design: {
9795
type: "figma",
@@ -132,9 +130,25 @@ WithLink.parameters = {
132130
};
133131
WithLink.storyName = "Default - info icon with link";
134132

135-
/**
136-
* This is an example of the contextual help component within a popover with a placement of `top`. Read more about the 22 available placement positions in the [popover documentation](/docs/components-popover--docs).
137-
*/
133+
export const MaxWidthPopover = Template.bind({});
134+
MaxWidthPopover.tags = ["!dev"];
135+
MaxWidthPopover.args = {
136+
customStyles: {
137+
"inline-size": "275px",
138+
"--mod-spectrum-contextual-help-popover-maximum-width": "180px",
139+
"margin-bottom": "270px",
140+
},
141+
};
142+
MaxWidthPopover.parameters = {
143+
chromatic: { disableSnapshot: true },
144+
docs: {
145+
story: {
146+
height: "auto",
147+
},
148+
},
149+
};
150+
MaxWidthPopover.storyName = "Default - max width popover";
151+
138152
export const TopPopover = Template.bind({});
139153
TopPopover.tags = ["!dev"];
140154
TopPopover.args = {
@@ -143,8 +157,6 @@ TopPopover.args = {
143157
"inline-size": "275px",
144158
"margin-top": "170px",
145159
},
146-
title: "Top popover example of text wrapping in the title",
147-
body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
148160
};
149161
TopPopover.parameters = {
150162
chromatic: { disableSnapshot: true },
@@ -163,6 +175,7 @@ export const HelpDefault = Template.bind({});
163175
HelpDefault.tags = ["!dev"];
164176
HelpDefault.args = {
165177
iconName: "Help",
178+
title: "Need help?",
166179
};
167180
HelpDefault.parameters = {
168181
chromatic: { disableSnapshot: true },
@@ -177,6 +190,8 @@ HelpWithLink.args = {
177190
url: "#",
178191
},
179192
iconName: "Help",
193+
title: "Need help?",
194+
body: "Reach out to your admin for help regarding the document you are trying to create.",
180195
};
181196
HelpWithLink.parameters = {
182197
chromatic: { disableSnapshot: true },
@@ -191,8 +206,8 @@ HelpTopPopover.args = {
191206
"inline-size": "275px",
192207
"margin-top": "170px",
193208
},
194-
title: "Top popover example of text wrapping in the title",
195-
body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
209+
title: "Need help?",
210+
body: "Reach out to your admin for help regarding the document you are trying to create.",
196211
iconName: "Help",
197212
};
198213
HelpTopPopover.parameters = {
@@ -205,13 +220,35 @@ HelpTopPopover.parameters = {
205220
};
206221
HelpTopPopover.storyName = "Help icon - top popover";
207222

223+
export const HelpMaxWidthPopover = Template.bind({});
224+
HelpMaxWidthPopover.tags = ["!dev"];
225+
HelpMaxWidthPopover.args = {
226+
customStyles: {
227+
"inline-size": "275px",
228+
"--mod-spectrum-contextual-help-popover-maximum-width": "180px",
229+
"margin-bottom": "270px",
230+
},
231+
title: "Need help?",
232+
body: "Reach out to your admin for help regarding the document you are trying to create.",
233+
iconName: "Help",
234+
};
235+
HelpMaxWidthPopover.parameters = {
236+
chromatic: { disableSnapshot: true },
237+
docs: {
238+
story: {
239+
height: "auto",
240+
},
241+
},
242+
};
243+
HelpMaxWidthPopover.storyName = "Help icon - max width popover";
244+
208245
// ********* VRT ONLY ********* //
209246
export const WithForcedColors = ContextualHelpGroup.bind({});
210247
WithForcedColors.args = Default.args;
211248
WithForcedColors.tags = ["!autodocs", "!dev"];
212249
WithForcedColors.parameters = {
213250
chromatic: {
214251
forcedColors: "active",
215-
modes: disableDefaultModes
252+
modes: disableDefaultModes,
216253
},
217254
};

0 commit comments

Comments
 (0)