Skip to content

Commit 56bad86

Browse files
committed
updeps
1 parent 5b4eaf3 commit 56bad86

File tree

14 files changed

+120
-29
lines changed

14 files changed

+120
-29
lines changed

esbuild.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import log from './env/log.js';
77
const DEV = process.argv.includes('--dev');
88

99
const serveOptions = {
10-
servedir: 'public',
11-
port: 8001
10+
servedir: 'public'
1211
};
1312

1413
const svelteOptions = {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"devDependencies": {
1313
"@tsconfig/svelte": "^3.0.0",
14-
"esbuild": "^0.17.7",
14+
"esbuild": "^0.17.8",
1515
"esbuild-svelte": "^0.7.3",
1616
"svelte": "^3.55.1",
1717
"svelte-preprocess": "^5.0.1",

src/App.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<script lang="ts" context="module">
22
import Score from "$components/Score.svelte";
33
import Board from "$components/Board.svelte";
4+
import Nav from "$components/Nav.svelte";
45
</script>
56

67
<Score />
7-
<main>
8-
<Board />
9-
</main>
10-
<footer>
11-
<p>Sort tiles: 1, 2, 3 ... 9 ... 12, 13 ... 15</p>
12-
</footer>
8+
<Board />
9+
<Nav />
1310

11+
<!-- <footer>
12+
<p>Sort tiles: 1, 2, 3 ... 9 ... 12, 13 ... 15</p>
13+
</footer> -->
1414
<style>
1515
@import "app.css";
1616
</style>

src/app.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import 'css/theme.css';
22
@import 'css/base.css';
33
@import 'css/board.css';
4-
@import 'css/tile.css';
4+
@import 'css/tile.css';
5+
@import 'css/nav.css';

src/components/Board.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
const numbers = Array.from({ length: 15 }, (_, i) => i + 1);
77
</script>
88

9-
<section id="board">
10-
{#each numbers as number}
11-
<Tile {number} />
12-
{/each}
13-
</section>
9+
<main>
10+
<section id="board">
11+
{#each numbers as number}
12+
<Tile {number} />
13+
{/each}
14+
</section>
15+
</main>

src/components/Nav.svelte

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script lang="ts" context="module">
2+
import { shuffle } from "$lib/actions";
3+
import { score, sorted } from "$lib/stores";
4+
</script>
5+
6+
<script lang="ts">
7+
shuffle($sorted);
8+
</script>
9+
10+
<footer>
11+
<nav class:playing={!$sorted}>
12+
{#if !$sorted}
13+
<button on:click={() => shuffle($sorted)}>Sort</button>
14+
{:else}
15+
<button class="lg" on:click={() => shuffle()}>Shuffle</button>
16+
{/if}
17+
</nav>
18+
</footer>

src/components/Score.svelte

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script lang="ts" context="module">
2-
import { score, sorted } from "$lib/stores";
2+
import { score, steps, sorted } from "$lib/stores";
33
import { shuffle } from "$lib/actions.js";
44
import gh from "../svg/gh.svg";
55
</script>
66

77
<header>
8-
<h3 class="counter">Steps: {$score}</h3>
8+
<p>Score: {$score}</p>
99
<h1>
1010
<a
1111
href="https://github.com/Valexr/Tagy"
@@ -17,12 +17,5 @@
1717
</a>
1818
Tagy
1919
</h1>
20-
<nav>
21-
<button
22-
on:click={() => shuffle($sorted)}
23-
title="{$sorted ? 'Shuffle' : 'Sort'} the tiles"
24-
>
25-
{$sorted ? "Shuffle" : "Sort"}
26-
</button>
27-
</nav>
20+
<p>Steps: {$steps}</p>
2821
</header>

src/components/Tile.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" context="module">
22
import { move } from "$lib/actions";
3-
import { positions, score, sorted } from "$lib/stores.js";
3+
import { positions, score, steps, sorted } from "$lib/stores.js";
44
</script>
55

66
<script lang="ts">
@@ -12,7 +12,7 @@
1212
$positions[number].m === $positions[0].m;
1313
if (movable && !$sorted) {
1414
move(number);
15-
$score += 1;
15+
$steps += 1;
1616
}
1717
}
1818
</script>

src/css/base.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ body {
1313
background-color: var(--light);
1414
}
1515

16-
header {
16+
header,
17+
footer {
1718
display: flex;
1819
align-items: center;
1920
justify-content: space-between;

src/css/nav.css

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
footer nav {
2+
color-scheme: dark;
3+
position: absolute;
4+
left: calc(50% - 150px);
5+
top: calc(50% - 25px);
6+
display: flex;
7+
flex-flow: column nowrap;
8+
width: 300px;
9+
}
10+
11+
footer nav.playing {
12+
top: auto;
13+
left: auto;
14+
position: relative;
15+
flex-flow: row nowrap;
16+
justify-content: center;
17+
gap: 1rem;
18+
width: 100%;
19+
}
20+
21+
footer nav fieldset {
22+
display: flex;
23+
justify-content: space-between;
24+
border: 0;
25+
margin: 0;
26+
padding: 1rem 0;
27+
}
28+
29+
footer nav label {
30+
flex: 0 1 min-content;
31+
}
32+
33+
input,
34+
select {
35+
border: 0;
36+
border-radius: 0;
37+
padding: 0.25rem;
38+
color: var(--dark);
39+
background-color: var(--light);
40+
font-size: inherit;
41+
border-radius: 0.15rem;
42+
}
43+
44+
select {
45+
appearance: none;
46+
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%204%205'%3E%3Cpath%20fill='currentColor'%20d='M2%200L0%202h4zm0%205L0%203h4z'/%3E%3C/svg%3E");
47+
background-position: right 0.5em center;
48+
background-repeat: no-repeat;
49+
background-size: .5em .75em;
50+
padding-right: 2em;
51+
}
52+
53+
footer nav button {
54+
position: relative;
55+
box-shadow: var(--shadow);
56+
}
57+
58+
footer nav button.lg {
59+
font-size: 2rem;
60+
box-shadow: var(--shadow-lg);
61+
}
62+
63+
footer nav button:active {
64+
top: 2px;
65+
left: 2px;
66+
box-shadow: none;
67+
}

0 commit comments

Comments
 (0)