Skip to content

Commit cea2daa

Browse files
feat: improve pieces page
1 parent 1e66681 commit cea2daa

File tree

4 files changed

+50
-9
lines changed

4 files changed

+50
-9
lines changed

pieces.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
body {
2+
padding: 1rem;
3+
}
4+
5+
h1:target {
6+
text-decoration: underline;
7+
}
8+
9+
h1 {
10+
display: flex;
11+
align-items: center;
12+
margin-bottom: 0;
13+
14+
&:target {
15+
text-decoration: underline;
16+
}
17+
}
18+
19+
ul {
20+
margin-top: 0;
21+
padding: 0;
22+
margin-left: 48px;
23+
list-style-type: none;
24+
display: flex;
25+
align-items: center;
26+
27+
& li {
28+
cursor: pointer;
29+
}
30+
}

pieces.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>Industrial Chess</title>
88
<script type="module" src="/src/pieces.ts"></script>
99
<link rel="stylesheet" href="style.css" />
10-
<!-- TODO: style this better -->
10+
<link rel="stylesheet" href="pieces.css" />
1111
<link rel="icon" href="bishop-knight-white.png">
1212
</head>
1313

src/pieces.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,36 @@ for (const piece of getAllPieces("white")) {
88

99
const h1 = document.createElement("h1");
1010
h1.id = piece.name;
11-
let content: string;
11+
const span = document.createElement("span")
12+
const img = document.createElement("img")
13+
img.src = `${piece.name}-white.png`
14+
img.alt = piece.name
1215
if (piece.name === "bishop-rook") {
13-
content = "Bishop + Rook (Queen)";
16+
span.textContent = "Bishop + Rook (Queen)";
1417
} else if (piece.name === "amazon") {
15-
content = "Amazon (Bishop + Knight + Rook)";
18+
span.textContent = "Amazon (Bishop + Knight + Rook)";
1619
} else {
17-
content = piece.name
20+
span.textContent = piece.name
1821
.split("-")
1922
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
2023
.join(" + ");
2124
}
22-
h1.textContent = content;
25+
h1.appendChild(img)
26+
h1.appendChild(span)
2327
body.appendChild(h1);
2428

2529
const ul = document.createElement("ul");
30+
ul.textContent = "requires:"
2631
for (const requirement of piece.requirements) {
2732
const li = document.createElement("li");
2833
const a = document.createElement("a");
2934
a.href = `#${requirement.name}`;
30-
a.textContent = requirement.name;
35+
const img = document.createElement("img");
36+
img.src = `${requirement.name}-white.png`
37+
img.alt = requirement.name
38+
a.appendChild(img)
3139
li.appendChild(a);
3240
ul.appendChild(li);
3341
}
3442
body.appendChild(ul);
3543
}
36-
37-
// TODO: images

vite.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ export default defineConfig({
1010
},
1111
},
1212
},
13+
server: {
14+
watch: {
15+
usePolling: true
16+
}
17+
}
1318
});

0 commit comments

Comments
 (0)