Skip to content

Commit

Permalink
chore(storybook): align display viewports for stories (#3131)
Browse files Browse the repository at this point in the history
  • Loading branch information
castastrophe authored Sep 26, 2024
1 parent 97fe29f commit 719775e
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 131 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-olives-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spectrum-css/modal": patch
---

The `-moz-available` prefix as an alias for the block-size: stretch property is not behaving as intended. This removes that prefix and forces FF to fallback to the 100vh property which is aligning as intended.
5 changes: 3 additions & 2 deletions .storybook/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ svg:has(symbol):not(:has(use)) {
}

/* --- DOCS STYLES --- */
.innerZoomElementWrapper .sb-story {
padding: 10px !important;
.docs-story > *:first-child {
background-color: var(--spectrum-background-layer-1-color);
overflow: hidden;
}

/* Make sure heading provided by <Stories/> doc block uses styles consistent with the default H2. */
Expand Down
1 change: 0 additions & 1 deletion .storybook/decorators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export { withTestingPreviewWrapper } from "./testing-preview.js";
export { withTextDirectionWrapper } from "./text-direction.js";

/* This is exported but must be opted-into on a component-by-component basis */
export { withSizingWrapper } from "./sizing.js";
export { withUnderlayWrapper } from "./underlay.js";

/* External decorators exported for use in stories */
Expand Down
60 changes: 0 additions & 60 deletions .storybook/decorators/sizing.js

This file was deleted.

18 changes: 10 additions & 8 deletions .storybook/decorators/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { capitalize } from "lodash-es";
const Heading = ({
type = "heading",
content,
size = "m",
size = "l",
weight,
customClasses = [],
} = {}) => {
Expand All @@ -28,7 +28,7 @@ const Heading = ({
skipLineBreak: true,
customClasses: ["chromatic-ignore", ...customClasses],
customStyles: {
"color": type !== "code" ? "var(--spectrum-gray-600)" : undefined,
"color": type !== "code" ? "var(--spectrum-heading-color)" : undefined,
}
});
};
Expand Down Expand Up @@ -79,8 +79,8 @@ export const Container = ({
<div
data-outer-container
style=${styleMap({
"z-index": "1",
"position": "relative",
"z-index": "1",
"position": "relative",
"display": "flex",
"flex-direction": "column",
"flex-wrap": "nowrap",
Expand Down Expand Up @@ -273,7 +273,6 @@ export const Sizes = ({
withBorder,
heading: withHeading ? "Sizing" : undefined,
argKey: "size",
level: 3,
labels: {
xxs: "Extra-extra-small",
xs: "Extra-small",
Expand Down Expand Up @@ -325,14 +324,19 @@ export const Variants = ({
}

return (args, context) => {
// Fetch any docs configurations from the context to use for VRT
const { parameters = {} } = context;
const storyHeight = parameters.docs?.story?.height;

const height = parameters?.docs?.story?.height;
const width = parameters?.docs?.story?.width;

return html`
<!-- Simple, clean template preview for non-testing grid views -->
<div
style=${styleMap({
"padding": "12px",
"min-block-size": typeof height === "number" ? `${height}px` : height,
"min-inline-size": typeof width === "number" ? `${width}px` : width,
...wrapperStyles,
"display": window.isChromatic() ? "none" : wrapperStyles.display,
})}
Expand Down Expand Up @@ -388,14 +392,12 @@ export const Variants = ({
}
const combinedStyles = {
"min-block-size": storyHeight,
...wrapperStyles,
...testWrapperStyles,
};
return Container({
heading: testHeading,
level: withStates ? 1 : 3,
withBorder,
containerStyles: {
// the z-index is necessary to ensure elements always appear above the overlay
Expand Down
12 changes: 0 additions & 12 deletions .storybook/modes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,3 @@ export const disableDefaultModes = {
return acc;
}, {}),
};

export const mobile = {
"Mobile": {
scale: "large",
},
};

export const viewports = {
small: {
width: 480,
},
};
4 changes: 2 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ setConsoleOptions({
});

/** @type import('@storybook/types').StorybookParameters & import('@storybook/types').API_Layout */
const parameters = {
layout: "padded",
export const parameters = {
layout: "centered",
showNav: true,
showTabs: true,
showPanel: true,
Expand Down
5 changes: 3 additions & 2 deletions components/alertbanner/stories/alertbanner.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default {
showCloseButton: true,
},
parameters: {
layout: "padded",
actions: {
handles: ["click .spectrum-AlertBanner button"],
},
Expand Down Expand Up @@ -133,7 +134,7 @@ Negative.parameters = {
* The alert banner component can contain both an icon-only close button and a button with a contextual action to
* take. Whenever possible, include the in-line action button if there's a way for a user to quickly address the issue
* associated with an alert. There should never be more than one button with a contextual action in an alert banner.
*
*
* The close button is optional, depending on context. Consider adding one to let a user easily dismiss the alert.
*/
export const ActionableOptions = ActionableOptionsTemplate.bind({});
Expand All @@ -160,4 +161,4 @@ TextOverflow.args = {
};
TextOverflow.parameters = {
chromatic: { disableSnapshot: true },
};
};
7 changes: 5 additions & 2 deletions components/alertbanner/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export const Template = ({
[`${rootClass}--${variant}`]: typeof variant !== "undefined",
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
})}
style=${styleMap(customStyles)}
style=${styleMap({
"min-inline-size": "500px",
...customStyles,
})}
id=${id}
data-testid=${ifDefined(testId)}
>
Expand Down Expand Up @@ -172,4 +175,4 @@ export const ActionableOptionsTemplate = (args, context) => Container({
}, context),
})}
`,
});
});
1 change: 1 addition & 0 deletions components/alertdialog/stories/alertdialog.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default {
variant: "confirmation",
},
parameters: {
layout: "fullscreen",
actions: {
handles: ["click .spectrum-AlertDialog button"],
},
Expand Down
8 changes: 7 additions & 1 deletion components/coachindicator/stories/coachindicator.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AllVariantsCoachIndicatorGroup } from "./template";

/**
* The coach indicator component can be used to bring added attention to specific parts of a page.
*
*
* Coach indicator is primarily used along with the [coach mark](/docs/components-coach-mark--docs) component.
*/
export default {
Expand Down Expand Up @@ -41,6 +41,12 @@ Default.parameters = {
chromatic: {
prefersReducedMotion: "reduce",
pauseAnimationAtEnd: true,
modes: {
// Skips the dark mode/RTL b/c no changes are made to the component
"Dark | RTL": {
disable: true,
},
},
},
};
Default.tags = ["!autodocs"];
Expand Down
9 changes: 3 additions & 6 deletions components/coachmark/stories/coachmark.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { default as ActionButton } from "@spectrum-css/actionbutton/stories/actionbutton.stories.js";
import { default as Menu } from "@spectrum-css/menu/stories/menu.stories.js";
import { disableDefaultModes, mobile } from "@spectrum-css/preview/modes";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import pkgJson from "../package.json";
import { CoachMarkGroup } from "./coachmark.test.js";
import { Template } from "./template.js";
Expand Down Expand Up @@ -47,16 +47,14 @@ export default {
hasImage: false,
},
parameters: {
layout: "padded",
actions: {
handles: [
...(ActionButton.parameters?.actions?.handles ?? []),
...(Menu.parameters?.actions?.handles ?? []),
],
},
packageJson: pkgJson,
chromatic: {
modes: mobile,
},
docs: {
story: {
height: "300px",
Expand All @@ -80,8 +78,7 @@ WithMedia.parameters = {
},
docs: {
story: {
inline: false,
height: "475px",
height: "500px",
},
},
};
Expand Down
4 changes: 1 addition & 3 deletions components/coachmark/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ export const Template = (args, context) => {
customClasses: [`${args.rootClass}-popover`],
isOpen: true,
position: "right-top",
trigger: (passthrough) => CoachIndicator({
...passthrough,
}, context),
trigger: (passthrough) => CoachIndicator(passthrough, context),
content: [
CoachContainer(args, context)
],
Expand Down
3 changes: 0 additions & 3 deletions components/colorarea/stories/colorarea.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Template } from "./template.js";

export const ColorAreaGroup = Variants({
Template,
skipBorders: true,
testData: [
{
testHeading: "Default",
Expand All @@ -19,11 +18,9 @@ export const ColorAreaGroup = Variants({
{
testHeading: "Disabled",
isDisabled: true,
isFocused: false,
},
{
testHeading: "Focused",
isDisabled: false,
isFocused: true,
},
],
Expand Down
6 changes: 0 additions & 6 deletions components/colorhandle/stories/colorhandle.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ WithColorLoupe.args = {
WithColorLoupe.tags = ["!dev"];
WithColorLoupe.parameters = {
chromatic: { disableSnapshot: true },
docs: {
story: {
inline: false,
height: "150px",
},
},
};

// ********* VRT ONLY ********* //
Expand Down
16 changes: 15 additions & 1 deletion components/contextualhelp/stories/contextualhelp.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ export default {
],
},
packageJson: pkgJson,
docs: {
story: {
height: "200px",
},
},
},
tags: ["!autodocs"],
};

export const Default = ContextualHelpGroup.bind({});
Expand Down Expand Up @@ -124,6 +128,11 @@ TopPopover.args = {
};
TopPopover.parameters = {
chromatic: { disableSnapshot: true },
docs: {
story: {
height: "auto",
},
},
};

export const HelpDefault = Template.bind({});
Expand Down Expand Up @@ -162,6 +171,11 @@ HelpTopPopover.args = {
};
HelpTopPopover.parameters = {
chromatic: { disableSnapshot: true },
docs: {
story: {
height: "auto",
},
},
};

// ********* VRT ONLY ********* //
Expand Down
1 change: 1 addition & 0 deletions components/dialog/stories/dialog.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default {
layout: "default",
},
parameters: {
layout: "fullscreen",
actions: {
handles: ["click .spectrum-Dialog button"],
},
Expand Down
Loading

0 comments on commit 719775e

Please sign in to comment.