Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/six-crabs-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Added a reusable narrowViewportDecorator that constrains the story width to 400px, forcing content overflow so scroll buttons appear and applied the decorator to all "with scroll" radio widget stories.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from "react";

import type {Decorator} from "@storybook/react-vite";

export const mobileDecorator = (Story) => (
<div className="framework-perseus perseus-mobile">
<Story />
Expand Down Expand Up @@ -82,3 +84,10 @@ export const articleFloatRightDecorator = (Story) => (
<div className="paragraph">{articleContent3}</div>
</div>
);

// Force overflow so the radio widget’s scroll controls render in these stories.
export const narrowViewportDecorator: Decorator = (Story) => (
<div style={{maxWidth: "400px"}}>
<Story />
</div>
);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from "react";

import {getFeatureFlags} from "../../../testing/feature-flags-util";
import {ServerItemRendererWithDebugUI} from "../../../testing/server-item-renderer-with-debug-ui";
import {narrowViewportDecorator} from "../../__testutils__/story-decorators";
import {groupedRadioRationaleQuestion} from "../../graded-group/graded-group.testdata";
import {
question,
Expand Down Expand Up @@ -122,6 +123,7 @@ export const SelectWithImagesAndScroll = {
question: SingleSelectOverflowImageContent,
}),
},
decorators: [narrowViewportDecorator],
};

export const SingleSelectWithScroll = {
Expand All @@ -130,6 +132,7 @@ export const SingleSelectWithScroll = {
question: SingleSelectOverflowContent,
}),
},
decorators: [narrowViewportDecorator],
};

export const MultiSelectSimple = {
Expand All @@ -154,6 +157,7 @@ export const MultiSelectWithScroll = {
question: multiChoiceQuestionSimpleOverflowContent,
}),
},
decorators: [narrowViewportDecorator],
};

export const GradedGroupSetWithScroll = {
Expand All @@ -162,6 +166,7 @@ export const GradedGroupSetWithScroll = {
question: overflowContentInGradedGroupSet,
}),
},
decorators: [narrowViewportDecorator],
};

export const GradedGroup = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {ApiOptions} from "../../../perseus-api";
import {ServerItemRenderer} from "../../../server-item-renderer";
import {getFeatureFlags} from "../../../testing/feature-flags-util";
import {testDependenciesV2} from "../../../testing/test-dependencies";
import {narrowViewportDecorator} from "../../__testutils__/story-decorators";
import {
choicesWithGraphie,
choicesWithImages,
Expand Down Expand Up @@ -155,6 +156,7 @@ export const SingleSelectWithImagesAndScroll: Story = {
}),
}),
},
decorators: [narrowViewportDecorator],
};

export const SingleSelectWithLongMathjax: Story = {
Expand Down Expand Up @@ -329,6 +331,7 @@ export const MultiSelectWithImagesAndScroll: Story = {
}),
}),
},
decorators: [narrowViewportDecorator],
};

export const MultiSelectWithLongText: Story = {
Expand Down Expand Up @@ -363,6 +366,7 @@ export const GradedGroupSetWithScroll: Story = {
question: overflowContentInGradedGroupSet,
}),
},
decorators: [narrowViewportDecorator],
};

function RadioQuestionRenderer(props: {
Expand Down
Loading