Skip to content

Commit 48bc498

Browse files
Undo Label Location work (#2314)
## Summary: Undoing the Label Location work as something seems to have gone strange after deploying to webapp. We will revisit this work separately afterwards. This will also require some changes to webapp to remove the new property from the go structs. ## Test plan: tests pass Author: SonicScrewdriver Reviewers: nishasy Required Reviewers: Approved By: nishasy Checks: ✅ 8 checks were successful, ⏹️ 9 checks were cancelled, ⌛ 1 check is pending Pull Request URL: #2314
1 parent f2d6002 commit 48bc498

File tree

13 files changed

+30
-317
lines changed

13 files changed

+30
-317
lines changed

.changeset/khaki-mayflies-lick.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@khanacademy/perseus": minor
3+
"@khanacademy/perseus-core": minor
4+
"@khanacademy/perseus-editor": minor
5+
---
6+
7+
Revert labelLocation

packages/perseus-core/src/data-schema.ts

-8
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ export type PerseusImageBackground = {
431431
* - none: shows no markings
432432
*/
433433
export type MarkingsType = "axes" | "graph" | "grid" | "none";
434-
export type AxisLabelLocation = "onAxis" | "alongEdge";
435434

436435
export type PerseusCategorizerWidgetOptions = {
437436
// Translatable text; a list of items to categorize. e.g. ["banana", "yellow", "apple", "purple", "shirt"]
@@ -735,13 +734,6 @@ export type PerseusInteractiveGraphWidgetOptions = {
735734
markings: MarkingsType;
736735
// How to label the X and Y axis. default: ["x", "y"]
737736
labels?: ReadonlyArray<string>;
738-
/**
739-
* Specifies the location of the labels on the graph. default: "onAxis".
740-
* - "onAxis": Labels are positioned on the axis at the right (x) and top (y) of the graph.
741-
* - "alongEdge": Labels are centered along the bottom (x) and left (y) edges of the graph.
742-
* The y label is rotated. Typically used when the range min is near 0 with longer labels.
743-
*/
744-
labelLocation?: AxisLabelLocation;
745737
// Whether to show the Protractor tool overlayed on top of the graph
746738
showProtractor: boolean;
747739
/**

packages/perseus-editor/src/widgets/interactive-graph-editor/components/interactive-graph-settings.tsx

-34
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Heading from "../../../components/heading";
2020
import LabeledRow from "../locked-figures/labeled-row";
2121

2222
import type {
23-
AxisLabelLocation,
2423
MarkingsType,
2524
PerseusImageBackground,
2625
} from "@khanacademy/perseus-core";
@@ -50,13 +49,6 @@ type Props = {
5049
* The labels for the x and y axes.
5150
*/
5251
labels: ReadonlyArray<string>;
53-
/**
54-
* Specifies the location of the labels on the graph. default: "onAxis".
55-
* - "onAxis": Labels are positioned on the axis at the right (x) and top (y) of the graph.
56-
* - "alongEdge": Labels are centered along the bottom (x) and left (y) edges of the graph.
57-
* The y label is rotated. Typically used when the range min is near 0 with longer labels.
58-
*/
59-
labelLocation: AxisLabelLocation;
6052
/**
6153
* The range of the graph.
6254
*/
@@ -107,7 +99,6 @@ type Props = {
10799
type State = {
108100
isExpanded: boolean;
109101
labelsTextbox: ReadonlyArray<string>;
110-
labelLocation: AxisLabelLocation;
111102
gridStepTextbox: [x: number, y: number];
112103
snapStepTextbox: [x: number, y: number];
113104
stepTextbox: [x: number, y: number];
@@ -125,7 +116,6 @@ class InteractiveGraphSettings extends React.Component<Props, State> {
125116
static stateFromProps(props: Props) {
126117
return {
127118
labelsTextbox: props.labels,
128-
labelLocation: props.labelLocation,
129119
gridStepTextbox: props.gridStep,
130120
snapStepTextbox: props.snapStep,
131121
stepTextbox: props.step,
@@ -150,7 +140,6 @@ class InteractiveGraphSettings extends React.Component<Props, State> {
150140
interactiveSizes.defaultBoxSizeSmall,
151141
],
152142
labels: ["$x$", "$y$"],
153-
labelLocation: "onAxis",
154143
range: [
155144
[-10, 10],
156145
[-10, 10],
@@ -176,7 +165,6 @@ class InteractiveGraphSettings extends React.Component<Props, State> {
176165
UNSAFE_componentWillReceiveProps(nextProps) {
177166
if (
178167
!_.isEqual(this.props.labels, nextProps.labels) ||
179-
!_.isEqual(this.props.labelLocation, nextProps.labelLocation) ||
180168
!_.isEqual(this.props.gridStep, nextProps.gridStep) ||
181169
!_.isEqual(this.props.snapStep, nextProps.snapStep) ||
182170
!_.isEqual(this.props.step, nextProps.step) ||
@@ -411,7 +399,6 @@ class InteractiveGraphSettings extends React.Component<Props, State> {
411399

412400
changeGraph = () => {
413401
const labels = this.state.labelsTextbox;
414-
const labelLocation = this.state.labelLocation;
415402
const range = _.map(this.state.rangeTextbox, function (range) {
416403
return _.map(range, Number);
417404
});
@@ -438,7 +425,6 @@ class InteractiveGraphSettings extends React.Component<Props, State> {
438425
this.change({
439426
valid: true,
440427
labels: labels,
441-
labelLocation: labelLocation,
442428
range: range,
443429
step: step,
444430
gridStep: gridStep,
@@ -466,26 +452,6 @@ class InteractiveGraphSettings extends React.Component<Props, State> {
466452
{this.state.isExpanded && (
467453
<View>
468454
<div className="graph-settings">
469-
<div className="perseus-widget-row">
470-
<LabeledRow label="Label Location">
471-
<ButtonGroup
472-
value={this.props.labelLocation}
473-
allowEmpty={false}
474-
buttons={[
475-
{
476-
value: "onAxis",
477-
content: "On Axis",
478-
},
479-
{
480-
value: "alongEdge",
481-
content: "Along Graph Edge",
482-
},
483-
]}
484-
onChange={this.change("labelLocation")}
485-
/>
486-
</LabeledRow>
487-
</div>
488-
489455
<div className="perseus-widget-row">
490456
<div className="perseus-widget-left-col">
491457
<LabeledRow label="x Label">

packages/perseus-editor/src/widgets/interactive-graph-editor/interactive-graph-editor.tsx

-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
type PerseusGraphType,
1515
type MarkingsType,
1616
type InteractiveGraphDefaultWidgetOptions,
17-
type AxisLabelLocation,
1817
interactiveGraphLogic,
1918
} from "@khanacademy/perseus-core";
2019
import {Id, View} from "@khanacademy/wonder-blocks-core";
@@ -71,13 +70,6 @@ export type Props = {
7170
* The labels for the x and y axes.
7271
*/
7372
labels: ReadonlyArray<string>;
74-
/**
75-
* Specifies the location of the labels on the graph. default: "onAxis".
76-
* - "onAxis": Labels are positioned on the axis at the right (x) and top (y) of the graph.
77-
* - "alongEdge": Labels are centered along the bottom (x) and left (y) edges of the graph.
78-
* The y label is rotated. Typically used when the range min is near 0 with longer labels.
79-
*/
80-
labelLocation?: AxisLabelLocation;
8173
/**
8274
* The range of the graph in the x and y directions.
8375
*/
@@ -202,7 +194,6 @@ class InteractiveGraphEditor extends React.Component<Props> {
202194
"backgroundImage",
203195
"markings",
204196
"labels",
205-
"labelLocation",
206197
"showProtractor",
207198
"showTooltips",
208199
"range",
@@ -300,7 +291,6 @@ class InteractiveGraphEditor extends React.Component<Props> {
300291
box: this.props.box,
301292
range: this.props.range,
302293
labels: this.props.labels,
303-
labelLocation: this.props.labelLocation,
304294
step: this.props.step,
305295
gridStep: gridStep,
306296
snapStep: snapStep,
@@ -751,7 +741,6 @@ class InteractiveGraphEditor extends React.Component<Props> {
751741
box={getInteractiveBoxFromSizeClass(sizeClass)}
752742
range={this.props.range}
753743
labels={this.props.labels}
754-
labelLocation={this.props.labelLocation}
755744
step={this.props.step}
756745
gridStep={gridStep}
757746
snapStep={snapStep}

packages/perseus/src/widgets/interactive-graphs/__snapshots__/interactive-graph.test.tsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ exports[`Interactive Graph A none-type graph renders predictably: first render 1
3737
</span>
3838
<span
3939
aria-label="Y-axis"
40-
style="position: absolute; left: 200px; top: -28px; font-size: 14px; transform: translate(-50%, 0px);"
40+
style="position: absolute; left: 200px; top: -24px; font-size: 14px; transform: translate(-50%, 0px);"
4141
>
4242
<span
4343
class="mock-TeX"

packages/perseus/src/widgets/interactive-graphs/backgrounds/axis-labels.test.ts

-96
This file was deleted.

0 commit comments

Comments
 (0)