Skip to content

Commit 3245a8a

Browse files
committed
columnGapAt prototype
1 parent 90f7e63 commit 3245a8a

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

src/components/DataStructures/Array/Array1DRenderer/Array1DRenderer.module.scss

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,40 @@
5656
// z-index: 1;
5757
// }
5858

59-
.col {
59+
.columnGap { // like .col but for a gap - no border
60+
justify-content: center;
61+
align-items: center;
62+
63+
text-align: center;
64+
min-width: 8px;
65+
width: 28px;
66+
// min-height: var(--array-1d-minimum-height);
67+
// background-color: var(--array-2d-row-col-bg);
68+
border: none;
69+
padding: 0 4px;
70+
margin-right: 4px;
71+
72+
.value {
73+
font-size: 12px;
74+
color: var(--array-2d-row-col-value-color);
75+
}
76+
&.index {
77+
background: var(--array-2d-row-col-bg-index);
78+
border: none;
79+
color: var(--array-2d-row-col-color-index);
80+
padding: 0 4px;
81+
margin-right: 5px;
82+
}
83+
&.variables {
84+
background: var(--array-2d-row-col-bg-index);
85+
border: none;
86+
color: var(--array-2d-row-col-color-index);
87+
vertical-align: text-top;
88+
min-height: 60px;
89+
}
90+
}
91+
92+
.col { // column (within a row, ie an array element)
6093
justify-content: center;
6194
align-items: center;
6295

@@ -72,7 +105,6 @@
72105
.value {
73106
font-size: 12px;
74107
color: var(--array-2d-row-col-value-color);
75-
76108
}
77109

78110
.variable {

src/components/DataStructures/Array/Array1DRenderer/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ class Array1DRenderer extends Array2DRenderer {
5252
this.toggleZoom(true);
5353

5454
this.maxStackDepth = 0;
55+
// XXX prototype stuff for insertion sort where we can have
56+
// the array to sort then a gap then the tmp variable and do
57+
// tweening for the moving of values around. Need to define
58+
// setColumnGapAt here and in the controller use the last array
59+
// element as tmp and set the previous element as the gap.
60+
// Best change the color of the indexAfterGap also so it's the same
61+
// as other variables.
62+
this.columnGapAt = undefined; // set to a number for a gap in array
63+
// this.columnGapAt = 10; // for testing
64+
this.indexAfterGap = 'tmp';
5565
}
5666

5767
// XXX "Warning: Each child in a list should have a unique "key" prop.
@@ -141,7 +151,8 @@ class Array1DRenderer extends Array2DRenderer {
141151
}}
142152
/* eslint-disable-next-line react/jsx-props-no-multi-spaces */
143153
className={classes(
144-
styles.col,
154+
(j === this.columnGapAt ? styles.columnGap : styles.col),
155+
// styles.col,
145156
col.faded && styles.faded,
146157
col.selected && styles.selected,
147158
col.selected1 && styles.selected1,
@@ -161,7 +172,8 @@ class Array1DRenderer extends Array2DRenderer {
161172
col.style && col.style.textStyle,
162173
)}
163174
>
164-
{this.toString(col.value)}
175+
{(j == this.columnGapAt ? ' '
176+
: this.toString(col.value))}
165177
</motion.span>
166178
{ (ALGOS_USING_FLOAT_BOX.includes(algo) && (
167179
<div
@@ -202,7 +214,12 @@ class Array1DRenderer extends Array2DRenderer {
202214

203215
return (
204216
<div className={classes(styles.col, styles.index)} key={i}>
205-
<span className={styles.value}>{i}</span>
217+
<span className={styles.value}>
218+
{(i-1 == this.columnGapAt ? ' '
219+
: i-1 == this.columnGapAt+1 ? this.indexAfterGap
220+
: i
221+
)}
222+
</span>
206223
</div>
207224
);
208225
})}

0 commit comments

Comments
 (0)