-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update spacing in locked figure settings (#1231)
## Summary: Update spacing in the Locked Point Settings and Locked Line Settings accordions so that the settings fit better. PR includes - spacing updates - lowercase letters to save space - checkboxes changed to switches (based on this [UX guidance](https://blog.uxtweak.com/checkbox-vs-toggle-switch/)) - LabeledSwitch component to remove redundancy - LockedFiguresSection stories Issue: https://khanacademy.atlassian.net/browse/LEMS-1965 ## Test plan: `yarn jest` http://localhost:6006/?path=/story/perseus-editor-components-locked-figures-section--with-prod-width ### Screenshots Note: the font styles are ever so slightly off, probably because of global styles in prod vs dev | Before | After ("solid") | After ("dashed") | | --- | --- | --- | | ![Screenshot 2024-04-26 at 4 54 42 PM](https://github.com/Khan/perseus/assets/13231763/21403be0-dc63-426d-96b6-a70f56dbf13e) | ![Screenshot 2024-04-26 at 4 53 35 PM](https://github.com/Khan/perseus/assets/13231763/cc1ac547-4546-4af9-9004-3ac619f676c6) | ![Screenshot 2024-04-26 at 5 06 21 PM](https://github.com/Khan/perseus/assets/13231763/83b8875f-930e-4b1a-aed2-58d6036dcb8e) | Author: nishasy Reviewers: jeremywiebe, mark-fitzgerald Required Reviewers: Approved By: jeremywiebe Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage, ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1231
- Loading branch information
Showing
13 changed files
with
377 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@khanacademy/perseus": patch | ||
"@khanacademy/perseus-editor": patch | ||
--- | ||
|
||
Adjust spacing in locked point and locked line settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/perseus-editor/src/components/__stories__/locked-figures-section.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import {View} from "@khanacademy/wonder-blocks-core"; | ||
import {color, spacing} from "@khanacademy/wonder-blocks-tokens"; | ||
import {StyleSheet} from "aphrodite"; | ||
import * as React from "react"; | ||
|
||
import LockedFiguresSection from "../locked-figures-section"; | ||
import {getDefaultFigureForType} from "../util"; | ||
|
||
import type {Meta, StoryObj} from "@storybook/react"; | ||
|
||
export default { | ||
title: "PerseusEditor/Components/Locked Figures Section", | ||
component: LockedFiguresSection, | ||
} as Meta<typeof LockedFiguresSection>; | ||
|
||
export const Default = (args): React.ReactElement => { | ||
return <LockedFiguresSection {...args} />; | ||
}; | ||
|
||
type StoryComponentType = StoryObj<typeof LockedFiguresSection>; | ||
|
||
// Set the default values in the control panel. | ||
Default.args = {}; | ||
|
||
export const Controlled: StoryComponentType = { | ||
render: function Render() { | ||
const [figures, setFigures] = React.useState([]); | ||
|
||
const handlePropsUpdate = (newProps) => { | ||
setFigures(newProps.lockedFigures); | ||
}; | ||
|
||
return ( | ||
<LockedFiguresSection | ||
figures={figures} | ||
onChange={handlePropsUpdate} | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export const WithProdWidth: StoryComponentType = { | ||
render: function Render() { | ||
const [figures, setFigures] = React.useState([ | ||
getDefaultFigureForType("point"), | ||
getDefaultFigureForType("line"), | ||
]); | ||
|
||
const handlePropsUpdate = (newProps) => { | ||
setFigures(newProps.lockedFigures); | ||
}; | ||
|
||
return ( | ||
<View style={styles.prodSizeContainer}> | ||
<LockedFiguresSection | ||
figures={figures} | ||
onChange={handlePropsUpdate} | ||
/> | ||
</View> | ||
); | ||
}, | ||
}; | ||
|
||
const contentSize = 310; | ||
const padding = 10; | ||
// Padding on each side | ||
const containerSize = contentSize + 2 * padding; | ||
|
||
const styles = StyleSheet.create({ | ||
prodSizeContainer: { | ||
width: containerSize, | ||
padding: padding, | ||
marginInlineStart: spacing.medium_16, | ||
border: `1px solid ${color.offBlack32}`, | ||
borderRadius: spacing.xxxSmall_4, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {View, useUniqueIdWithMock} from "@khanacademy/wonder-blocks-core"; | ||
import {Strut} from "@khanacademy/wonder-blocks-layout"; | ||
import Switch from "@khanacademy/wonder-blocks-switch"; | ||
import {spacing} from "@khanacademy/wonder-blocks-tokens"; | ||
import {LabelMedium} from "@khanacademy/wonder-blocks-typography"; | ||
import {StyleSheet} from "aphrodite"; | ||
import * as React from "react"; | ||
|
||
import type {StyleType} from "@khanacademy/wonder-blocks-core"; | ||
|
||
type Props = { | ||
label: string; | ||
checked: boolean; | ||
style?: StyleType; | ||
onChange: (newValue: boolean) => void; | ||
}; | ||
|
||
const LabeledSwitch = (props: Props) => { | ||
const {checked, label, style, onChange} = props; | ||
|
||
const ids = useUniqueIdWithMock(); | ||
const switchId = ids.get("switch"); | ||
|
||
return ( | ||
<View style={[styles.row, style]}> | ||
<Switch id={switchId} checked={checked} onChange={onChange} /> | ||
<Strut size={spacing.xSmall_8} /> | ||
<LabelMedium tag="label" htmlFor={switchId}> | ||
{label} | ||
</LabelMedium> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
row: { | ||
flexDirection: "row", | ||
alignItems: "center", | ||
}, | ||
}); | ||
|
||
export default LabeledSwitch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.