Skip to content

Commit eee9288

Browse files
authored
CSE Machine: Remove old components and make compact components the default (source-academy#2848)
* Make compact components the new default and remove any mentions to the old components. Also removes the experimental button toggle. * Update test snapshots * Clean up testing code a little * Formatting changes * Fix some minor issues
1 parent 7e1f581 commit eee9288

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+537
-3706
lines changed

src/commons/sideContent/__tests__/__snapshots__/SideContentCseMachine.tsx.snap

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ exports[`CSE Machine component renders correctly 1`] = `
119119
className="bp5-button-text"
120120
>
121121
<label
122-
className="bp5-control bp5-checkbox"
122+
className="bp5-control bp5-checkbox bp5-disabled"
123123
style={
124124
Object {
125125
"margin": 0,
@@ -128,7 +128,7 @@ exports[`CSE Machine component renders correctly 1`] = `
128128
>
129129
<input
130130
checked={false}
131-
disabled={false}
131+
disabled={true}
132132
onChange={[Function]}
133133
type="checkbox"
134134
/>
@@ -256,55 +256,6 @@ exports[`CSE Machine component renders correctly 1`] = `
256256
<div
257257
className="bp5-button-group"
258258
>
259-
<span
260-
className="bp5-popover-target"
261-
onBlur={[Function]}
262-
onContextMenu={[Function]}
263-
onFocus={[Function]}
264-
onMouseEnter={[Function]}
265-
onMouseLeave={[Function]}
266-
>
267-
<a
268-
aria-disabled={true}
269-
aria-expanded={false}
270-
className="bp5-button bp5-disabled"
271-
disabled={true}
272-
onBlur={[Function]}
273-
onKeyDown={[Function]}
274-
onKeyUp={[Function]}
275-
onMouseUp={[Function]}
276-
role="button"
277-
tabIndex={-1}
278-
>
279-
<span
280-
aria-hidden={true}
281-
className="bp5-icon bp5-icon-standard bp5-icon-build"
282-
data-icon="build"
283-
/>
284-
<span
285-
className="bp5-button-text"
286-
>
287-
<label
288-
className="bp5-control bp5-checkbox bp5-disabled"
289-
style={
290-
Object {
291-
"margin": 0,
292-
}
293-
}
294-
>
295-
<input
296-
checked={false}
297-
disabled={true}
298-
onChange={[Function]}
299-
type="checkbox"
300-
/>
301-
<span
302-
className="bp5-control-indicator"
303-
/>
304-
</label>
305-
</span>
306-
</a>
307-
</span>
308259
<span
309260
className="bp5-popover-target"
310261
onBlur={[Function]}

src/commons/sideContent/content/SideContentCseMachine.tsx

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -211,35 +211,35 @@ class SideContentCseMachineBase extends React.Component<CseMachineProps, State>
211211
<Tooltip2 content="Control and Stash" compact>
212212
<AnchorButton
213213
onMouseUp={() => {
214-
if (this.state.visualization && CseMachine.getCompactLayout()) {
214+
if (this.state.visualization) {
215215
CseMachine.toggleControlStash();
216216
CseMachine.redraw();
217217
}
218218
}}
219219
icon="layers"
220-
disabled={!this.state.visualization || !CseMachine.getCompactLayout()}
220+
disabled={!this.state.visualization}
221221
>
222222
<Checkbox
223223
checked={CseMachine.getControlStash()}
224-
disabled={!CseMachine.getCompactLayout()}
224+
disabled={!this.state.visualization}
225225
style={{ margin: 0 }}
226226
/>
227227
</AnchorButton>
228228
</Tooltip2>
229229
<Tooltip2 content="Truncate Control" compact>
230230
<AnchorButton
231231
onMouseUp={() => {
232-
if (this.state.visualization && CseMachine.getControlStash()) {
232+
if (this.state.visualization) {
233233
CseMachine.toggleStackTruncated();
234234
CseMachine.redraw();
235235
}
236236
}}
237237
icon="minimize"
238-
disabled={!this.state.visualization || !CseMachine.getControlStash()}
238+
disabled={!this.state.visualization}
239239
>
240240
<Checkbox
241241
checked={CseMachine.getStackTruncated()}
242-
disabled={!CseMachine.getControlStash()}
242+
disabled={!this.state.visualization}
243243
style={{ margin: 0 }}
244244
/>
245245
</AnchorButton>
@@ -268,24 +268,6 @@ class SideContentCseMachineBase extends React.Component<CseMachineProps, State>
268268
/>
269269
</ButtonGroup>
270270
<ButtonGroup>
271-
<Tooltip2 content="Experimental" compact>
272-
<AnchorButton
273-
onMouseUp={() => {
274-
if (this.state.visualization) {
275-
CseMachine.toggleCompactLayout();
276-
CseMachine.redraw();
277-
}
278-
}}
279-
icon="build"
280-
disabled={!this.state.visualization}
281-
>
282-
<Checkbox
283-
checked={!CseMachine.getCompactLayout()}
284-
disabled={!this.state.visualization}
285-
style={{ margin: 0 }}
286-
/>
287-
</AnchorButton>
288-
</Tooltip2>
289271
<Tooltip2 content="Print" compact>
290272
<AnchorButton
291273
onMouseUp={() => {

src/features/cseMachine/CseMachine.tsx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export default class CseMachine {
1919
/** callback function to update the step limit exceeded state in the SideContentCseMachine component */
2020
private static setIsStepLimitExceeded: SetisStepLimitExceeded;
2121
private static printableMode: boolean = false;
22-
private static compactLayout: boolean = true;
2322
private static controlStash: boolean = false; // TODO: discuss if the default should be true
2423
private static stackTruncated: boolean = false;
2524
private static environmentTree: EnvTree | undefined;
@@ -29,9 +28,6 @@ export default class CseMachine {
2928
public static togglePrintableMode(): void {
3029
CseMachine.printableMode = !CseMachine.printableMode;
3130
}
32-
public static toggleCompactLayout(): void {
33-
CseMachine.compactLayout = !CseMachine.compactLayout;
34-
}
3531
public static toggleControlStash(): void {
3632
CseMachine.controlStash = !CseMachine.controlStash;
3733
}
@@ -44,9 +40,6 @@ export default class CseMachine {
4440
public static getPrintableMode(): boolean {
4541
return CseMachine.printableMode;
4642
}
47-
public static getCompactLayout(): boolean {
48-
return CseMachine.compactLayout;
49-
}
5043
public static getControlStash(): boolean {
5144
return CseMachine.controlStash;
5245
}
@@ -75,7 +68,6 @@ export default class CseMachine {
7568

7669
static clear() {
7770
Layout.values.clear();
78-
Layout.compactValues.clear();
7971
}
8072

8173
/** updates the visualization state in the SideContentCseMachine component based on
@@ -103,60 +95,40 @@ export default class CseMachine {
10395
if (CseMachine.environmentTree && CseMachine.control && CseMachine.stash) {
10496
// checks if the required diagram exists, and updates the dom node using setVis
10597
if (
106-
CseMachine.getCompactLayout() &&
10798
CseMachine.getPrintableMode() &&
10899
CseMachine.getControlStash() &&
109100
CseMachine.getStackTruncated() &&
110101
Layout.currentStackTruncLight !== undefined
111102
) {
112103
this.setVis(Layout.currentStackTruncLight);
113104
} else if (
114-
CseMachine.getCompactLayout() &&
115105
CseMachine.getPrintableMode() &&
116106
CseMachine.getControlStash() &&
117107
!CseMachine.getStackTruncated() &&
118108
Layout.currentStackLight !== undefined
119109
) {
120110
this.setVis(Layout.currentStackLight);
121111
} else if (
122-
CseMachine.getCompactLayout() &&
123112
!CseMachine.getPrintableMode() &&
124113
CseMachine.getControlStash() &&
125114
CseMachine.getStackTruncated() &&
126115
Layout.currentStackTruncDark !== undefined
127116
) {
128117
this.setVis(Layout.currentStackTruncDark);
129118
} else if (
130-
CseMachine.getCompactLayout() &&
131119
!CseMachine.getPrintableMode() &&
132120
CseMachine.getControlStash() &&
133121
!CseMachine.getStackTruncated() &&
134122
Layout.currentStackDark !== undefined
135123
) {
136124
this.setVis(Layout.currentStackDark);
137125
} else if (
138-
CseMachine.getCompactLayout() &&
139-
CseMachine.getPrintableMode() &&
140-
!CseMachine.getControlStash() &&
141-
Layout.currentCompactLight !== undefined
142-
) {
143-
this.setVis(Layout.currentCompactLight);
144-
} else if (
145-
CseMachine.getCompactLayout() &&
146-
!CseMachine.getPrintableMode() &&
147-
!CseMachine.getControlStash() &&
148-
Layout.currentCompactDark !== undefined
149-
) {
150-
this.setVis(Layout.currentCompactDark);
151-
} else if (
152-
!CseMachine.getCompactLayout() &&
153126
CseMachine.getPrintableMode() &&
154127
!CseMachine.getControlStash() &&
155128
Layout.currentLight !== undefined
156129
) {
157130
this.setVis(Layout.currentLight);
158131
} else if (
159-
!CseMachine.getCompactLayout() &&
160132
!CseMachine.getPrintableMode() &&
161133
!CseMachine.getControlStash() &&
162134
Layout.currentDark !== undefined

src/features/cseMachine/CseMachineAnimation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { BlockAnimation } from './animationComponents/BlockAnimation';
77
import { LiteralAnimation } from './animationComponents/LiteralAnimation';
88
import { PopAnimation } from './animationComponents/PopAnimation';
99
import { UnaryOperationAnimation } from './animationComponents/UnaryOperationAnimation';
10-
import { isInstr } from './compactComponents/ControlStack';
10+
import { isInstr } from './components/ControlStack';
1111
import CseMachine from './CseMachine';
1212
import { Layout } from './CseMachineLayout';
1313

src/features/cseMachine/CseMachineCompactConfig.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/features/cseMachine/CseMachineConfig.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,22 @@ export enum Config {
1111
FrameMinWidth = 100,
1212
FramePaddingX = 20,
1313
FramePaddingY = 30,
14-
FrameMarginX = 60,
15-
FrameMarginY = 100,
14+
FrameMarginX = 30,
15+
FrameMarginY = 10,
1616
FrameCornerRadius = 3,
1717

1818
FnRadius = 15,
1919
FnInnerRadius = 3,
20-
FnTooltipOpacity = 0.6,
20+
FnTooltipOpacity = 0.3,
2121

2222
DataMinWidth = 20,
2323
DataUnitWidth = 40,
24-
DataUnitPaddingY = 40,
25-
DataUnitPaddingX = 50,
2624
DataUnitHeight = 40,
2725
DataCornerRadius = 3,
2826
DataHitStrokeWidth = 5,
29-
DataGroupMaxDist = 500,
3027

3128
TextPaddingX = 10,
32-
TextPaddingY = 20,
29+
TextPaddingY = 30,
3330
TextMargin = 5,
3431
TextMinWidth = 30,
3532
FontFamily = 'monospace, monospace',
@@ -43,19 +40,15 @@ export enum Config {
4340
ArrowStrokeWidth = 1,
4441
ArrowHitStrokeWidth = 5,
4542
ArrowHoveredStrokeWidth = 2,
46-
ArrowUnhoveredOpacity = 0.8,
47-
ArrowCornerRadius = 10,
48-
ArrowMinHeight = 100,
49-
ArrowNumLanes = 5,
50-
ArrowLaneInterval = 1, // lane for next arrow = previous lane + lane interval % num lanes.
51-
FrameArrowStrokeWidth = 2,
52-
FrameArrowHoveredStrokeWidth = 2.5,
43+
ArrowCornerRadius = 40,
44+
5345
MaxExportWidth = 20000,
5446
MaxExportHeight = 12000,
5547

5648
SA_WHITE = '#999999',
5749
SA_BLUE = '#2c3e50',
5850
PRINT_BACKGROUND = 'white',
51+
SA_CURRENT_ITEM = '#030fff',
5952

6053
ConstantColon = ':= ',
6154
VariableColon = ': ',

src/features/cseMachine/CseMachineControlStash.ts renamed to src/features/cseMachine/CseMachineControlStashConfig.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,3 @@ export enum ControlStashConfig {
3636
PRINT_BACKGROUND = 'white',
3737
STASH_DANGER_ITEM = '#ff0000'
3838
}
39-
40-
export const ShapeDefaultProps = {
41-
preventDefault: false
42-
};

0 commit comments

Comments
 (0)