From dcd78eb747043eb28a521fa8760f4fceb793e221 Mon Sep 17 00:00:00 2001 From: Russell Samora Date: Fri, 17 Jan 2025 14:06:18 -0500 Subject: [PATCH] workin on it --- properties/color.json | 9 ++- src/components/Game.svelte | 1 + src/components/Grid.svelte | 113 ++++++++++++++++++++++++++++------- src/components/Index.svelte | 6 +- src/components/Keypad.svelte | 2 +- src/components/Result.svelte | 48 +++++++++------ src/data/variables.json | 8 ++- src/runes/misc.svelte.js | 2 +- src/styles/app.css | 2 +- src/styles/variables.css | 8 ++- 10 files changed, 149 insertions(+), 50 deletions(-) diff --git a/properties/color.json b/properties/color.json index ab5af9c..e73bf73 100644 --- a/properties/color.json +++ b/properties/color.json @@ -39,7 +39,9 @@ "gray-1000": { "value": "rgb(25, 25, 25)" }, - + "green-lightest": { + "value": "#4ca658" + }, "green-light": { "value": "#63c74d" }, @@ -70,6 +72,9 @@ "red": { "value": "#ff0044" }, + "orange-lightest": { + "value": "#eb6d72" + }, "orange-medium": { "value": "#e22b33" }, @@ -80,7 +85,7 @@ "value": "#c0cbdc" }, "grayblue-medium": { - "value": "#8b9bb4" + "value": "#8596b0" }, "grayblue-dark": { "value": "#5a6988" diff --git a/src/components/Game.svelte b/src/components/Game.svelte index 9cfef8f..63e143e 100644 --- a/src/components/Game.svelte +++ b/src/components/Game.svelte @@ -67,6 +67,7 @@ if (str.length < MAX_LENGTH) { storage.value.path = path; + game.path = $state.snapshot(path); if (!alreadyCompleted) { // TODO if we can do heuristic on front end, only submit if not already completed // const response = await server("submit", str); diff --git a/src/components/Grid.svelte b/src/components/Grid.svelte index 7fe24f5..1a470fa 100644 --- a/src/components/Grid.svelte +++ b/src/components/Grid.svelte @@ -1,13 +1,27 @@
{#if !game && path.length > 1} - {#each path as [x, y], i} - {@const x1 = x + 0.5} - {@const y1 = y + 0.5} - {@const x2 = (path[i + 1] ? path[i + 1][0] : x) + 0.5} - {@const y2 = (path[i + 1] ? path[i + 1][1] : y) + 0.5} - - {/each} + {#if animating} + {#each path as [x, y], i (i)} + {@const x1 = x + 0.5} + {@const y1 = y + 0.5} + {@const x2 = (path[i + 1] ? path[i + 1][0] : x) + 0.5} + {@const y2 = (path[i + 1] ? path[i + 1][1] : y) + 0.5} + + + {/each} + {/if} + {/if} @@ -98,8 +157,8 @@ figure.perspective { perspective-origin: 50% 100%; - transform: scale(0.9); - margin-top: -3.25%; + transform: scale(0.75); + margin-top: -10%; } .grid { @@ -120,7 +179,7 @@ } .perspective .inner { - transform: rotateX(40deg); + transform: rotateX(35deg); } .cell { @@ -245,11 +304,11 @@ /* nodes mode */ .nodes .grid { - border: 0.5px solid var(--color-gray-300); + /* border: 0.5px solid var(--color-gray-500); */ } .nodes .cell { - border: 0.5px solid var(--color-gray-300); + /* border: 0.5px solid var(--color-gray-500); */ background: none; } @@ -262,7 +321,9 @@ width: 20%; height: 20%; border-radius: 50%; - border: 1px solid var(--color-fg-light); + border: 1px solid var(--color-gray-500); + background: var(--color-bg); + /* opacity: 0.5; */ position: absolute; top: 50%; left: 50%; @@ -270,9 +331,12 @@ } .nodes .obstacle { - background: var(--color-fg-light); - /* background: var(--color-fg-light); */ - /* border-radius: 0; */ + background: var(--color-gray-500); + border: 0.5px solid var(--color-bg); + } + + .nodes .obstacle .fg { + display: none; } svg { @@ -284,9 +348,18 @@ left: 0; } - path { - stroke: var(--path); - stroke-width: 0.2; + path.line { + stroke-width: 0.5; stroke-linecap: round; + /* stroke-opacity: 0.2; */ + fill: none; + stroke: var(--path-start); + } + + path.arrow { + stroke-width: 0.1; + /* stroke-linecap: round; */ + fill: none; + stroke: var(--path-start); } diff --git a/src/components/Index.svelte b/src/components/Index.svelte index f9fad47..d39c7ef 100644 --- a/src/components/Index.svelte +++ b/src/components/Index.svelte @@ -38,11 +38,15 @@ padding: 0 16px; } - :global(.c p, .c h1, .c figure) { + :global(.c p, .c h1) { margin: 32px auto; max-width: var(--grid-max-width); } + :global(.c figure) { + max-width: 800px; + } + @media (min-width: 960px) { .byline p { font-size: var(--16px); diff --git a/src/components/Keypad.svelte b/src/components/Keypad.svelte index 9903973..f55543e 100644 --- a/src/components/Keypad.svelte +++ b/src/components/Keypad.svelte @@ -21,7 +21,7 @@ -
+
diff --git a/src/components/Result.svelte b/src/components/Result.svelte index 48503fa..f05ee84 100644 --- a/src/components/Result.svelte +++ b/src/components/Result.svelte @@ -2,34 +2,46 @@ import Grid from "$components/Grid.svelte"; import obstacles from "$data/obstacles.json"; import solution from "$data/solution.json"; + import { game } from "$runes/misc.svelte.js"; + import inView from "$actions/inview.js"; + const size = 10; - const user = [ - [0, 0], - [1, 0], - [2, 0] - ]; + let visible = $state(false); + let gridUser = $state(); + let gridSolution = $state(); + + $effect(() => { + if (visible) { + if (gridUser) gridUser.animate(); + gridSolution.animate(); + } + }); -
+
(visible = true)}>
+ {#if game.path.length} +
+ +
+ {/if}
-
-
-
@@ -39,7 +51,7 @@ .inner { display: flex; justify-content: center; - max-width: 640px; + max-width: 800px; margin: 0 auto; } diff --git a/src/data/variables.json b/src/data/variables.json index fd0bd05..1b8f3fe 100644 --- a/src/data/variables.json +++ b/src/data/variables.json @@ -22,8 +22,9 @@ "gray-800": "rgb(55, 55, 55)", "gray-900": "rgb(38, 38, 38)", "gray-1000": "rgb(25, 25, 25)", + "green-lightest": "#4ca658", "green-light": "#63c74d", - "green-medium": "#3e8948", + "green-medium": "#3c8446", "green-dark": "#265c42", "pink-light": "#f6757a", "pink-medium": "#b55088", @@ -32,10 +33,11 @@ "brown-medium": "#b86f50", "brown-light": "#e4a672", "red": "#ff0044", - "orange-medium": "#e43b44", + "orange-lightest": "#eb6d72", + "orange-medium": "#e22b33", "orange-dark": "#9e2835", "grayblue-light": "#c0cbdc", - "grayblue-medium": "#8b9bb4", + "grayblue-medium": "#8596b0", "grayblue-dark": "#5a6988", "grayblue-darkest": "#262b44", "blue-lightest": "#cefafd", diff --git a/src/runes/misc.svelte.js b/src/runes/misc.svelte.js index dde7294..94f34c5 100644 --- a/src/runes/misc.svelte.js +++ b/src/runes/misc.svelte.js @@ -1 +1 @@ -export const game = $state({ active: true, completed: false }); +export const game = $state({ active: true, completed: false, path: [] }); diff --git a/src/styles/app.css b/src/styles/app.css index af8acc4..3bf7a6b 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -132,4 +132,4 @@ span.you.visible, span.skip.visible { main p:first-of-type { margin-top: 0; -} \ No newline at end of file +} diff --git a/src/styles/variables.css b/src/styles/variables.css index 5b81076..871c378 100644 --- a/src/styles/variables.css +++ b/src/styles/variables.css @@ -23,8 +23,9 @@ --color-gray-800: rgb(55, 55, 55); --color-gray-900: rgb(38, 38, 38); --color-gray-1000: rgb(25, 25, 25); + --color-green-lightest: #4ca658; --color-green-light: #63c74d; - --color-green-medium: #3e8948; + --color-green-medium: #3c8446; --color-green-dark: #265c42; --color-pink-light: #f6757a; --color-pink-medium: #b55088; @@ -33,10 +34,11 @@ --color-brown-medium: #b86f50; --color-brown-light: #e4a672; --color-red: #ff0044; - --color-orange-medium: #e43b44; + --color-orange-lightest: #eb6d72; + --color-orange-medium: #e22b33; --color-orange-dark: #9e2835; --color-grayblue-light: #c0cbdc; - --color-grayblue-medium: #8b9bb4; + --color-grayblue-medium: #8596b0; --color-grayblue-dark: #5a6988; --color-grayblue-darkest: #262b44; --color-blue-lightest: #cefafd;