Skip to content

Commit 32ba4b3

Browse files
authored
[Radio] | (CX) | Nicer image editing in radio (#2647)
## Summary: Implement a UI for adding images to the content area within the Radio widget editor. Note for reviewer: Over half the lines of code are tests. Issue: https://khanacademy.atlassian.net/browse/LEMS-3028 ## Demo: | Default | Adding image | Added image | | --- | --- | --- | | <img width="333" height="265" alt="image" src="https://github.com/user-attachments/assets/237ad001-9693-4761-923f-214e603fadea" /> | <img width="337" height="467" alt="Screenshot 2025-08-05 at 1 46 53 PM" src="https://github.com/user-attachments/assets/ac4ad8aa-53f6-4dac-8a74-0e42ad76fc89" /> | <img width="337" height="718" alt="image" src="https://github.com/user-attachments/assets/4fa37858-f4d6-4871-9cd1-f77af06bb7d3" /> | https://github.com/user-attachments/assets/d7791b90-a089-440b-a225-fac1f1df12ed ## Test plan: `pnpm jest packages/perseus-editor/src/widgets/radio/utils.test.ts` `pnpm jest packages/perseus-editor/src/widgets/__tests__/radio-editor.test.tsx` ZND manual testing: - Press "Add image" to show the editor tile - Close the "Add image" editor tile - Add an image to see a new image show up - It should also cause a new editor accordion to show up - Edit an image with the accordion - Delete an image with the accordion - Paste an image into the content box Author: nishasy Reviewers: nishasy, ivyolamit, mark-fitzgerald, SonicScrewdriver, anakaren-rojas Required Reviewers: Approved By: ivyolamit, mark-fitzgerald Checks: ✅ 10 checks were successful Pull Request URL: #2647
1 parent 4ab552d commit 32ba4b3

File tree

10 files changed

+1081
-24
lines changed

10 files changed

+1081
-24
lines changed

.changeset/forty-bobcats-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus-editor": minor
3+
---
4+
5+
[Radio] | (CX) | Implment UI for adding images in Radio editor

packages/perseus-editor/src/components/perseus-editor-accordion.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Props = {
1313
expanded?: boolean;
1414
containerStyle?: StyleType;
1515
panelStyle?: StyleType;
16+
headerStyle?: StyleType;
1617
onToggle?: (expanded: boolean) => void;
1718
};
1819

@@ -24,6 +25,7 @@ const PerseusEditorAccordion = (props: Props) => {
2425
expanded,
2526
containerStyle,
2627
panelStyle,
28+
headerStyle,
2729
onToggle,
2830
} = props;
2931

@@ -39,7 +41,7 @@ const PerseusEditorAccordion = (props: Props) => {
3941
expanded={expanded}
4042
onToggle={onToggle}
4143
style={[styles.container, containerStyle]}
42-
headerStyle={styles.accordionHeader}
44+
headerStyle={[styles.accordionHeader, headerStyle]}
4345
header={header}
4446
>
4547
<View style={[styles.accordionPanel, panelStyle]}>

packages/perseus-editor/src/widgets/__docs__/radio-editor.stories.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import RadioEditor from "../radio/editor";
1111

1212
import type {Meta, StoryObj} from "@storybook/react-vite";
1313

14+
const PROD_EDITOR_WIDTH = 330;
15+
1416
// This is to address timing - Perseus widget editor registry accessed before initialization!
1517
registerAllWidgetsAndEditorsForTesting();
1618

@@ -31,9 +33,13 @@ export const Default: Story = {
3133
};
3234

3335
export const SingleChoice = (): React.ReactElement => (
34-
<EditorPageWithStorybookPreview question={singleSelectQuestion} />
36+
<div style={{width: PROD_EDITOR_WIDTH}}>
37+
<EditorPageWithStorybookPreview question={singleSelectQuestion} />
38+
</div>
3539
);
3640

3741
export const MultiChoice = (): React.ReactElement => (
38-
<EditorPageWithStorybookPreview question={multiChoiceQuestion} />
42+
<div style={{width: PROD_EDITOR_WIDTH}}>
43+
<EditorPageWithStorybookPreview question={multiChoiceQuestion} />
44+
</div>
3945
);

0 commit comments

Comments
 (0)