Skip to content

Commit 09bc38d

Browse files
committed
Mostly switched to Tailwind CSS
1 parent 47223ce commit 09bc38d

File tree

12 files changed

+234
-392
lines changed

12 files changed

+234
-392
lines changed

src/components/GameBoard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { TileInfo } from "~/types";
55
import Tile from "./Tile";
66

77
const GameBoard = (props: { tiles: TileInfo[] }) => (
8-
<div id="game-board">
8+
<div class="grid grid-cols-5 gap-[5px] mb-5">
99
<For each={props.tiles}>{(tile) => <Tile tile={tile} />}</For>
1010
</div>
1111
);

src/components/LeaderboardContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const LeaderboardContainer = () => (
22
<div class="content-container">
3-
<h2>{"Leaderboard (coming soon)"}</h2>
3+
<h2 class="font-bold text-2xl text-center mb-5">{"Leaderboard (not coming soon)"}</h2>
44
</div>
55
);
66

src/components/SettingsContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const SettingGroup = <T extends string>(props: {
77
options: { value: T; label: string }[];
88
onChange: (value: T) => void;
99
}) => (
10-
<div class="setting-group">
11-
<label for={props.id} class="setting-label">
10+
<div class="flex justify-between items-end w-full mb-4">
11+
<label for={props.id} class="font-bold text-2xl">
1212
{props.label}
1313
</label>
1414

@@ -29,7 +29,7 @@ const SettingsContainer = (props: {
2929
settings: Settings;
3030
updateSettings: (settings: Partial<Settings>) => void;
3131
}) => (
32-
<div id="settings-container" class="content-container">
32+
<div class="content-container">
3333
<SettingGroup
3434
id="theme-select"
3535
label="Theme"

src/components/StatsContainer.tsx

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { For } from "solid-js";
22
import type { Stats } from "~/types";
33

44
const GuessDistributionRow = (props: { v: number; i: number; p: number }) => (
5-
<div class="guess-row">
6-
<div class="guess-label">{props.i + 1}</div>
5+
<div class="flex items-center w-9/10">
6+
<div class="w-5 text-right mr-2.5 font-bold text-base">{props.i + 1}</div>
77
<div class="guess-bar">
88
<div class="guess-bar-fill" style={{ width: `${props.p}%` }} />
99
<div class="guess-count">{props.v}</div>
@@ -12,7 +12,7 @@ const GuessDistributionRow = (props: { v: number; i: number; p: number }) => (
1212
);
1313

1414
const GuessDistribution = (props: { guessDistribution: number[] }) => (
15-
<div id="guess-distribution">
15+
<div class="flex flex-col gap-[5px] w-full">
1616
<For each={props.guessDistribution}>
1717
{(v, i) => (
1818
<GuessDistributionRow
@@ -25,43 +25,41 @@ const GuessDistribution = (props: { guessDistribution: number[] }) => (
2525
</div>
2626
);
2727

28+
const StatBox = (props: {
29+
id?: string;
30+
value: string | number;
31+
label: string;
32+
}) => (
33+
<div class="stat-box">
34+
<div class="text-2xl font-bold mb-[5px]" id={props.id}>
35+
{props.value}
36+
</div>
37+
<div class="text-base">{props.label}</div>
38+
</div>
39+
);
40+
41+
const getNormalizedPercentage = (part: number, total: number) =>
42+
total === 0 ? 0 : Math.round((part / total) * 100);
43+
2844
const StatsContainer = (props: { stats: Stats }) => (
29-
<div id="stats-container" class="content-container">
30-
<div id="stats-grid">
31-
<div class="stat-box">
32-
<div class="stat-number" id="games-played">
33-
{props.stats.gamesPlayed}
34-
</div>
35-
<div class="stat-label">Played</div>
36-
</div>
45+
<div class="content-container">
46+
<div class="grid grid-cols-2 gap-5 mb-5">
47+
<StatBox label="Played" value={props.stats.gamesPlayed} />
3748

38-
<div class="stat-box">
39-
<div class="stat-number" id="win-percentage">
40-
{props.stats.gamesPlayed === 0
41-
? "0%"
42-
: Math.round(
43-
(props.stats.gamesWon / props.stats.gamesPlayed) * 100
44-
) + "%"}
45-
</div>
46-
<div class="stat-label">Win %</div>
47-
</div>
49+
<StatBox
50+
label="Win %"
51+
value={`${getNormalizedPercentage(
52+
props.stats.gamesWon,
53+
props.stats.gamesPlayed
54+
)}%`}
55+
/>
4856

49-
<div class="stat-box">
50-
<div class="stat-number" id="current-streak">
51-
{props.stats.currentStreak}
52-
</div>
53-
<div class="stat-label">Current Streak</div>
54-
</div>
57+
<StatBox label="Current Streak" value={props.stats.currentStreak} />
5558

56-
<div class="stat-box">
57-
<div class="stat-number" id="max-streak">
58-
{props.stats.maxStreak}
59-
</div>
60-
<div class="stat-label">Max Streak</div>
61-
</div>
59+
<StatBox label="Max Streak" value={props.stats.maxStreak} />
6260
</div>
6361

64-
<h3 class="my-[10px]">Guess Distribution</h3>
62+
<h3 class="font-bold text-lg text-center my-2.5">Guess Distribution</h3>
6563

6664
<GuessDistribution guessDistribution={props.stats.guessDistribution} />
6765
</div>

src/components/TopBar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const TopBar = (props: {
4040
setCurrentSection: (section: CurrentSection) => void;
4141
}) => (
4242
<div id="top-bar">
43-
<div class="top-bar-buttons-div">
43+
<div class="flex flex-row gap-2.5 basis-1/3">
4444
<TopbarButton
4545
section="menu"
4646
currentSection={props.currentSection}
@@ -60,9 +60,9 @@ const TopBar = (props: {
6060
</TopbarButton>
6161
</div>
6262

63-
<h1 id="game-title">Wordle</h1>
63+
<h1 id="game-title" class="font-bold text-[2em] m-0 text-center tracking-[2px] grow">Wordle</h1>
6464

65-
<div class="top-bar-buttons-div">
65+
<div class="flex flex-row gap-2.5 basis-1/3 justify-end">
6666
<TopbarButton
6767
section="stats"
6868
currentSection={props.currentSection}

src/layouts/Layout.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Props {
1212
const { title, description, canonical, thumbnail } = Astro.props;
1313
---
1414

15-
<html lang="en">
15+
<html lang="en" class="h-screen">
1616
<head>
1717
<meta charset="UTF-8" />
1818
<meta name="referrer" content="no-referrer-when-downgrade" />

src/pages/index.astro

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
---
22
import "~/styles/global.css";
3-
43
import "~/styles/main.css";
5-
import "~/styles/notifications.css";
6-
import "~/styles/statistics.css";
7-
import "~/styles/variables.css";
84
95
import Layout from "~/layouts/Layout.astro";
106
import Game from "~/components/Game.tsx";

src/styles/global.css

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
@import "tailwindcss";
22

3-
/**
4-
53
@custom-variant dark (&:where(.dark, .dark *));
6-
7-
/* or */
8-
9-
/**
10-
4+
/* or */ /**
115
@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));
12-
136
*/
14-
15-
h1,
16-
h2,
17-
h3 {
18-
@apply font-bold;
19-
}
20-
21-
h1 {
22-
font-size: 2em;
23-
}
24-
25-
h2 {
26-
font-size: 1.5em;
27-
}
28-
29-
h3 {
30-
font-size: 1.17em;
31-
}

0 commit comments

Comments
 (0)