Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove locked labels flags #2065

Open
wants to merge 2 commits into
base: remove-locked-figure-flags-2
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions .changeset/lucky-seas-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": patch
"@khanacademy/perseus-editor": patch
---

Remove the locked-[figureName]-labels flags
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ export const flags = {
point: true,
"unlimited-point": true,
none: true,

// Locked figures flags
"locked-point-labels": true,
"locked-line-labels": true,
"locked-vector-labels": true,
"locked-ellipse-labels": true,
"locked-polygon-labels": true,
"locked-function-labels": true,
},
} satisfies APIOptions["flags"];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,163 +153,7 @@ export const InteractiveGraphNone = (): React.ReactElement => {
);
};

export const MafsWithLockedFiguresCurrent = (): React.ReactElement => {
return (
<EditorPageWithStorybookPreview
apiOptions={{
isMobile: false,
flags: {
mafs: {
...flags.mafs,
"locked-point-labels": false,
"locked-line-labels": false,
"locked-vector-labels": false,
"locked-ellipse-labels": false,
"locked-polygon-labels": false,
"locked-function-labels": false,
},
},
}}
question={segmentWithLockedFigures}
/>
);
};

MafsWithLockedFiguresCurrent.parameters = {
chromatic: {
// Disabling because this isn't visually testing anything on the
// initial load of the editor page.
disableSnapshot: true,
},
};

export const MafsWithLockedPointLabelsFlag = (): React.ReactElement => {
return (
<EditorPageWithStorybookPreview
apiOptions={{
flags: {
mafs: {
...flags.mafs,
"locked-point-labels": true,
"locked-line-labels": false,
"locked-vector-labels": false,
"locked-ellipse-labels": false,
"locked-polygon-labels": false,
"locked-function-labels": false,
},
},
}}
question={segmentWithLockedFigures}
/>
);
};

export const MafsWithLockedLineLabelsFlag = (): React.ReactElement => {
return (
<EditorPageWithStorybookPreview
apiOptions={{
flags: {
mafs: {
...flags.mafs,
"locked-point-labels": false,
"locked-line-labels": true,
"locked-vector-labels": false,
"locked-ellipse-labels": false,
"locked-polygon-labels": false,
"locked-function-labels": false,
},
},
}}
question={segmentWithLockedFigures}
/>
);
};

export const MafsWithLockedVectorLabelsFlag = (): React.ReactElement => {
return (
<EditorPageWithStorybookPreview
apiOptions={{
flags: {
mafs: {
...flags.mafs,
"locked-point-labels": false,
"locked-line-labels": false,
"locked-vector-labels": true,
"locked-ellipse-labels": false,
"locked-polygon-labels": false,
"locked-function-labels": false,
},
},
}}
question={segmentWithLockedFigures}
/>
);
};

export const MafsWithLockedEllipseLabelsFlag = (): React.ReactElement => {
return (
<EditorPageWithStorybookPreview
apiOptions={{
flags: {
mafs: {
...flags.mafs,
"locked-point-labels": false,
"locked-line-labels": false,
"locked-vector-labels": false,
"locked-ellipse-labels": true,
"locked-polygon-labels": false,
"locked-function-labels": false,
},
},
}}
question={segmentWithLockedFigures}
/>
);
};

export const MafsWithLockedPolygonLabelsFlag = (): React.ReactElement => {
return (
<EditorPageWithStorybookPreview
apiOptions={{
flags: {
mafs: {
...flags.mafs,
"locked-point-labels": false,
"locked-line-labels": false,
"locked-vector-labels": false,
"locked-ellipse-labels": false,
"locked-polygon-labels": true,
"locked-function-labels": false,
},
},
}}
question={segmentWithLockedFigures}
/>
);
};

export const MafsWithLockedFunctionLabelsFlag = (): React.ReactElement => {
return (
<EditorPageWithStorybookPreview
apiOptions={{
flags: {
mafs: {
...flags.mafs,
"locked-point-labels": false,
"locked-line-labels": false,
"locked-vector-labels": false,
"locked-ellipse-labels": false,
"locked-polygon-labels": false,
"locked-function-labels": true,
},
},
}}
question={segmentWithLockedFigures}
/>
);
};

export const MafsWithLockedFigureLabelsAllFlags = (): React.ReactElement => {
export const MafsWithLockedFigures = (): React.ReactElement => {
return (
<EditorPageWithStorybookPreview question={segmentWithLockedFigures} />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,6 @@ class InteractiveGraphEditor extends React.Component<Props> {
this.props.graph.type
] && (
<LockedFiguresSection
flags={this.props.apiOptions.flags}
figures={this.props.lockedFigures}
onChange={this.props.onChange}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ import {
import type {UserEvent} from "@testing-library/user-event";

const defaultProps = {
flags: {
...flags,
mafs: {
...flags.mafs,
"locked-ellipse-settings": true,
},
},
flags: flags,
...getDefaultFigureForType("ellipse"),
onChangeProps: () => {},
onMove: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export type Props = LockedFigureSettingsCommonProps &

const LockedEllipseSettings = (props: Props) => {
const {
flags,
center,
radius,
angle,
Expand Down Expand Up @@ -256,55 +255,48 @@ const LockedEllipseSettings = (props: Props) => {
/>

{/* Visible Labels */}
{flags?.["mafs"]?.["locked-ellipse-labels"] && (
<>
<Strut size={spacing.xxxSmall_4} />
<View style={styles.horizontalRule} />
<Strut size={spacing.small_12} />

<LabelMedium>Visible labels</LabelMedium>

{labels?.map((label, labelIndex) => (
<LockedLabelSettings
{...label}
key={labelIndex}
expanded={true}
onChangeProps={(newLabel) => {
handleLabelChange(newLabel, labelIndex);
}}
onRemove={() => {
handleLabelRemove(labelIndex);
}}
containerStyle={styles.labelContainer}
/>
))}

<Button
kind="tertiary"
startIcon={plusCircle}
onClick={() => {
const newLabel = {
...getDefaultFigureForType("label"),
coord: [
center[0],
// Additional vertical offset for each
// label so they don't overlap.
center[1] - (labels?.length ?? 0),
],
// Default to the same color as the ellipse
color: color,
} satisfies LockedLabelType;

onChangeProps({
labels: [...(labels ?? []), newLabel],
});
}}
style={styles.addButton}
>
Add visible label
</Button>
</>
)}
<Strut size={spacing.xxxSmall_4} />
<View style={styles.horizontalRule} />
<Strut size={spacing.small_12} />
<LabelMedium>Visible labels</LabelMedium>
{labels?.map((label, labelIndex) => (
<LockedLabelSettings
{...label}
key={labelIndex}
expanded={true}
onChangeProps={(newLabel) => {
handleLabelChange(newLabel, labelIndex);
}}
onRemove={() => {
handleLabelRemove(labelIndex);
}}
containerStyle={styles.labelContainer}
/>
))}
<Button
kind="tertiary"
startIcon={plusCircle}
onClick={() => {
const newLabel = {
...getDefaultFigureForType("label"),
coord: [
center[0],
// Additional vertical offset for each
// label so they don't overlap.
center[1] - (labels?.length ?? 0),
],
// Default to the same color as the ellipse
color: color,
} satisfies LockedLabelType;

onChangeProps({
labels: [...(labels ?? []), newLabel],
});
}}
style={styles.addButton}
>
Add visible label
</Button>

{/* Actions */}
<LockedFigureSettingsActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ import type {Props as LockedLineProps} from "./locked-line-settings";
import type {Props as LockedPointProps} from "./locked-point-settings";
import type {Props as LockedPolygonProps} from "./locked-polygon-settings";
import type {Props as LockedVectorProps} from "./locked-vector-settings";
import type {APIOptions} from "@khanacademy/perseus";

export type LockedFigureSettingsCommonProps = {
flags?: APIOptions["flags"];

// Movement props
/**
* Called when a movement button (top, up, down, bottom) is pressed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ import {getDefaultFigureForType} from "./util";

import type {LockedFigureSettingsMovementType} from "./locked-figure-settings-actions";
import type {Props as InteractiveGraphEditorProps} from "../interactive-graph-editor";
import type {
APIOptions,
LockedFigure,
LockedFigureType,
} from "@khanacademy/perseus";
import type {LockedFigure, LockedFigureType} from "@khanacademy/perseus";

type Props = {
flags?: APIOptions["flags"];
figures?: Array<LockedFigure>;
onChange: (props: Partial<InteractiveGraphEditorProps>) => void;
};
Expand Down Expand Up @@ -165,7 +160,6 @@ const LockedFiguresSection = (props: Props) => {
return (
<LockedFigureSettings
key={`${uniqueId}-locked-${figure}-${index}`}
flags={props.flags}
expanded={expandedStates[index]}
onToggle={(newValue) => {
const newExpanded = [...expandedStates];
Expand Down
Loading
Loading