Skip to content

Commit 5442c6a

Browse files
committed
feat: different thumb colours for light and dark themes
refactor: renaming accessibleChunks to viewable
1 parent edff4f7 commit 5442c6a

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

src/components/mid-panel/ProgressBar.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ProgressBar extends React.Component {
1515

1616
this.max;
1717
this.current;
18-
this.accessibleChunks;
18+
this.viewable;
1919
this.next;
2020
this.prev;
2121

@@ -48,30 +48,29 @@ class ProgressBar extends React.Component {
4848
return;
4949
}
5050

51-
// search for the closest accessible chunk
52-
// in a certain radius
51+
// search for the closest viewable chunk in a certain radius
5352
for (let i = 0; i <= searchRadius; i++) {
5453
if (i === 0) {
55-
if (this.accessibleChunks[x]) {
54+
if (this.viewable[x]) {
5655
chunkNum = x;
5756
break;
5857
}
5958
continue;
6059
}
6160

62-
if (this.accessibleChunks[x + i]) {
61+
if (this.viewable[x + i]) {
6362
chunkNum = x + i;
6463
break;
6564
}
6665

67-
if (this.accessibleChunks[x - i]) {
66+
if (this.viewable[x - i]) {
6867
chunkNum = x - i;
6968
break;
7069
}
7170
}
7271
}
7372

74-
if (this.accessibleChunks[chunkNum]) {
73+
if (this.viewable[chunkNum]) {
7574
if (chunkNum > this.current) {
7675
this.next({stopAt: chunkNum, playing: false});
7776
}
@@ -102,8 +101,8 @@ class ProgressBar extends React.Component {
102101

103102
this.max = max;
104103
this.current = current;
105-
this.accessibleChunks = (state.chunker !== undefined) ?
106-
state.chunker.accessibleChunks :
104+
this.viewable = (state.chunker !== undefined) ?
105+
state.chunker.viewable :
107106
null;
108107

109108
this.prev = (playing) => {

src/context/actions.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,18 @@ function addLineExplanation(procedurePseudocode) {
211211
}
212212
}
213213

214-
// set the visibility attribute for chunks if the chunk can be reached
215-
// i.e. not in a collapsed code block
216-
function setChunkAccessibility(chunker, pseudocode, collapse) {
214+
// get the list showing which chunks can be viewed
215+
function viewableChunks(chunker, pseudocode, collapse) {
217216
let currChunkNum = 0;
218-
let accessibleChunks = Array(chunker.chunks.length).fill(false);
219-
accessibleChunks[0] = true;
217+
let viewable = Array(chunker.chunks.length).fill(false);
218+
viewable[0] = true;
220219

221220
while (currChunkNum < chunker.chunks.length - 1) {
222221
currChunkNum = findNext(chunker.chunks, currChunkNum, pseudocode, collapse);
223-
accessibleChunks[currChunkNum] = true;
222+
viewable[currChunkNum] = true;
224223
}
225224

226-
chunker.accessibleChunks = accessibleChunks;
225+
chunker.viewable = viewable;
227226
}
228227

229228
// At any time the app may call dispatch(action, params), which will trigger one of
@@ -287,7 +286,7 @@ export const GlobalActions = {
287286
const collapse = state === undefined || state.collapse === undefined
288287
? getCollapseController(algorithms)
289288
: state.collapse;
290-
setChunkAccessibility(chunker, procedurePseudocode, collapse[params.name][params.mode]);
289+
viewableChunks(chunker, procedurePseudocode, collapse[params.name][params.mode]);
291290

292291
return {
293292
...state,
@@ -336,7 +335,7 @@ export const GlobalActions = {
336335
if (stopAt < state.chunker.chunks.length - 1) {
337336
do {
338337
stopAt++;
339-
} while (!state.chunker.accessibleChunks[stopAt])
338+
} while (!state.chunker.viewable[stopAt])
340339
}
341340
}
342341
// step forward until we are at stopAt, or last chunk, or some weird
@@ -399,7 +398,7 @@ export const GlobalActions = {
399398
if (stopAt > 0) {
400399
do {
401400
stopAt--;
402-
} while (!state.chunker.accessibleChunks[stopAt])
401+
} while (!state.chunker.viewable[stopAt])
403402
}
404403
}
405404
let result1 = {bookmark:"", chunk: state.chunker.currentChunk};
@@ -439,7 +438,12 @@ export const GlobalActions = {
439438
onCollapseStateChange(); // Transitive closure plugin
440439
unionFindToggleRank(state);
441440

442-
setChunkAccessibility(state.chunker, state.pseudocode, state.collapse[state.id.name][state.id.mode]);
441+
// update viewable chunks
442+
viewableChunks(
443+
state.chunker,
444+
state.pseudocode,
445+
state.collapse[state.id.name][state.id.mode]
446+
);
443447

444448
return {
445449
...state,

src/styles/ProgressBar.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ $progWidth: 320px;
178178
overflow: hidden;
179179
position: relative;
180180
transform: translateZ(0);
181-
background-color: var(--mid-control-slider-bg);
181+
background-color: var(--mid-control-progress-bg);
182182
transition: opacity 250ms linear;
183183
width: $progWidth;
184184
@include border-radius(16px); // makes the border curvy
@@ -252,7 +252,7 @@ $border: 4px;
252252
z-index: 51;
253253
width: $progHeight - ($border + $border);
254254
height: $progHeight - ($border + $border);
255-
background-color: $darkerBlue;
255+
background-color: var(--mid-control-progress-thumb);
256256
@include border-radius(14px);
257257
}
258258
}

src/styles/global.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Shared Colors and Sizes
22
$blue: #037DFF;
3-
$darkerBlue: #1565C0;
3+
$darkerBlue: #01579B;
44
$sigBlue: #027AFF;
55
$red: #DC0707;
66
$green: #53DD6C;
@@ -61,8 +61,9 @@ $yellowLine: #FFDE3C;
6161
--mid-instruction-content-number-col: #2d2d2d;
6262
--mid-instruction-content-key: #027AFF;
6363

64-
--mid-control-progress-bg: #b5b5b5;
64+
--mid-control-progress-bg: #F7F7F7;
6565
--mid-control-progress-active: #027AFF;
66+
--mid-control-progress-thumb: #64B5F6;
6667
--mid-control-progress-font: #161515;
6768

6869
--mid-control-param-border: #D4D4D4;
@@ -282,6 +283,7 @@ $yellowLine: #FFDE3C;
282283

283284
--mid-control-progress-bg: #111215;
284285
--mid-control-progress-active: #027AFF;
286+
--mid-control-progress-thumb: #1565C0;
285287
--mid-control-progress-font: #a0a0a0;
286288

287289
--mid-control-bg: #16171B;

0 commit comments

Comments
 (0)