Skip to content

Commit cc8a77e

Browse files
Ivan SemochkinIvan Semochkin
Ivan Semochkin
authored and
Ivan Semochkin
committed
update colors
1 parent 0976cc6 commit cc8a77e

File tree

5 files changed

+91
-71
lines changed

5 files changed

+91
-71
lines changed

src/app.css

+14-11
Original file line numberDiff line numberDiff line change
@@ -136,26 +136,29 @@ input[type='search'] {
136136
}
137137

138138
body {
139-
--bg-body: #121210;
139+
--bg-body: #160F1D;
140140
--bg-interface: #22192B;
141141

142-
--bg-start: #96E458;
143-
--bg-end: #E3A359;
144-
--bg-visited: #7EA151;
142+
--bg-start: #7084E9;
145143

146-
--bg-path: #B651BF;
147-
--bg-wall: #C2444C;
144+
--bg-end: #E39B48;
148145

149-
--bg-weight-1: #6143B7;
150-
--bg-weight-2: #6F4ECF;
151-
--bg-weight-3: #8463E3;
146+
--bg-visited: #4D368F;
147+
148+
--bg-path: #5568CD;
149+
150+
--bg-wall: #D0424B;
151+
152+
--bg-weight-1: #2A943B;
153+
--bg-weight-2: #56A73B;
154+
--bg-weight-3: #74C358;
152155

153156
--bg-weight-tool: var(--bg-weight-2);
154157
--bg-wall-tool: var(--bg-wall);
155158

156159

157160
--bg-select: hsl(0, 0%, 3%);
158-
--bg-tool-border: hsl(227, 25%, 15%);
161+
--bg-tool-border: #F0E8F4;
159162
--select-active: hsl(215, 80%, 35%);
160163

161164
--color-weight: hsl(218, 13%, 88%);
@@ -168,5 +171,5 @@ body.dark {
168171
}
169172

170173
body.light {
171-
--bg-not-visited: #E0DCE4;
174+
--bg-not-visited: #F0E8F4;
172175
}

src/lib/Components/AlgoSelect.svelte

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
font-size: 24px;
5050
color: white;
5151
position: relative;
52+
border-bottom: 2px solid var(--bg-tool-border);
5253
font-weight: bold;
5354
}
5455

src/lib/Components/Node.svelte

+35-7
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,59 @@
11
<script lang="ts">
22
import { animationQ } from '$lib/stores/animation';
3+
import { theme } from '$lib/stores/theme';
34
import type { Node } from '$lib/types';
45
import { startNodeKey, endNodeKey, selectedNodeKey, walls, weight } from '../stores/nodes';
56
67
export let key: string;
78
export let node: Node;
89
9-
const getCurrentWeight = () => {
10+
const getLightWeight = (key) => {
1011
let currentWeight = $weight.get(key);
11-
console.log('currentWeight', currentWeight);
12+
if (!currentWeight) {
13+
return '';
14+
}
15+
16+
let prefix;
17+
18+
if (currentWeight <= 3) {
19+
prefix = 3;
20+
} else if (currentWeight <= 7) {
21+
prefix = 2;
22+
} else {
23+
prefix = 1;
24+
}
1225
26+
return `var(--bg-weight-${prefix})`;
27+
};
28+
29+
const getDarkWeight = (key) => {
30+
let currentWeight = $weight.get(key);
1331
if (!currentWeight) {
1432
return '';
15-
} else if (currentWeight <= 3) {
16-
return 'bg-weight-1';
33+
}
34+
35+
let prefix;
36+
37+
if (currentWeight <= 3) {
38+
prefix = 1;
1739
} else if (currentWeight <= 7) {
18-
return 'bg-weight-2';
40+
prefix = 2;
1941
} else {
20-
return 'bg-weight-3';
42+
prefix = 3;
2143
}
44+
45+
return `var(--bg-weight-${prefix})`;
2246
};
2347
</script>
2448

2549
<div
2650
id={key}
2751
data-type="node"
28-
style="--weight-dynamic-bg:{$weight.has(key) ? `var(--${getCurrentWeight()})` : ''}"
52+
style="--weight-dynamic-bg:{$weight.has(key) && $theme === 'light'
53+
? getLightWeight(key)
54+
: $weight.has(key) && $theme === 'dark'
55+
? getDarkWeight(key)
56+
: ''}"
2957
class="node"
3058
class:visited={node.visited}
3159
class:startNode={$startNodeKey === key}

src/lib/Components/Tools/Tool.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
.border {
3232
position: absolute;
3333
transition: 0.5s cubic-bezier(0.075, 0.82, 0.165, 1);
34-
background-color: var(--bg-body);
34+
background-color: var(--bg-tool-border);
3535
height: 3px;
3636
width: 10px;
3737
bottom: 0;

src/lib/stores/nodes.ts

+40-52
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,47 @@ import { writable } from 'svelte/store';
22

33
// Walls
44
const createWallsStore = () => {
5-
const { subscribe, update, set } = writable(new Set<string>());
6-
return {
7-
subscribe,
8-
addWall: (key: string) =>
9-
update((current) => {
10-
current.add(key);
11-
return current;
12-
}),
13-
removeWall: (key: string) =>
14-
update((current) => {
15-
current.delete(key);
16-
return current;
17-
}),
18-
reset: () => set(new Set())
19-
};
5+
const { subscribe, update, set } = writable(new Set<string>());
6+
return {
7+
subscribe,
8+
addWall: (key: string) =>
9+
update((current) => {
10+
current.add(key);
11+
return current;
12+
}),
13+
removeWall: (key: string) =>
14+
update((current) => {
15+
current.delete(key);
16+
return current;
17+
}),
18+
reset: () => set(new Set())
19+
};
2020
};
2121

2222
const createWeightStore = () => {
23-
const { subscribe, update, set } = writable(new Map<string, number>());
24-
return {
25-
subscribe,
26-
addWeight: (key: string) => {
27-
update((current) => {
28-
const weightedNode = current.get(key);
29-
if (weightedNode) {
30-
current.set(key, Math.min(9, weightedNode + 1));
31-
} else {
32-
current.set(key, 1);
33-
}
34-
35-
return current;
36-
});
37-
},
38-
removeWeight: (key: string) => {
39-
update((current) => {
40-
const weightedNode = current.get(key);
41-
42-
if (!weightedNode) {
43-
return current;
44-
}
45-
46-
const nextWeight = weightedNode - 1;
47-
48-
if (nextWeight <= 0) {
49-
current.delete(key);
50-
} else {
51-
current.set(key, nextWeight);
52-
}
53-
return current;
54-
});
55-
},
56-
reset: () => set(new Map())
57-
};
23+
const { subscribe, update, set } = writable(new Map<string, number>());
24+
return {
25+
subscribe,
26+
addWeight: (key: string) => {
27+
update((current) => {
28+
const weightedNode = current.get(key);
29+
if (weightedNode) {
30+
current.set(key, Math.min(9, weightedNode + 1));
31+
} else {
32+
current.set(key, 1);
33+
}
34+
35+
return current;
36+
});
37+
},
38+
removeWeight: (key: string) => {
39+
update((current) => {
40+
current.delete(key);
41+
return current
42+
})
43+
},
44+
reset: () => set(new Map())
45+
};
5846
};
5947

6048
// Start Node
@@ -70,6 +58,6 @@ export const walls = createWallsStore();
7058
export const weight = createWeightStore();
7159

7260
export const resetNodes = () => {
73-
walls.reset();
74-
weight.reset();
61+
walls.reset();
62+
weight.reset();
7563
};

0 commit comments

Comments
 (0)