Skip to content

Commit 9fef6e8

Browse files
committed
improved panel page ui
1 parent c097f00 commit 9fef6e8

File tree

2 files changed

+44
-26
lines changed

2 files changed

+44
-26
lines changed

src/assets/styles/panel.css

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,34 @@
3333
gap: 1rem;
3434
}
3535

36-
& label {
36+
& label .icon {
3737
width: 3rem;
3838
height: 3rem;
3939
border-radius: 0.5rem;
40-
display: grid;
41-
place-items: center;
40+
display: flex;
41+
align-items: center;
42+
justify-content: center;
4243
background: var(--bg);
4344
cursor: pointer;
4445
transition: 0.2s;
4546
position: relative;
4647
}
4748

48-
& label:hover,
49-
& label:focus-within {
49+
& label:focus-within,
50+
& .icon:hover {
5051
background: var(--primary);
5152
}
5253

53-
& input[type="radio"]:focus-visible + .icon {
54+
& input[type="radio"]:focus-visible+.icon {
5455
outline: 2px solid var(--primary);
5556
outline-offset: 2px;
56-
border-radius: 0.25rem;
57+
border-radius: 0.5rem;
5758
}
5859

59-
& input[type="radio"]:checked + .icon {
60+
& input[type="radio"]:checked+.icon {
6061
color: white;
6162
background: var(--primary);
62-
border-radius: 0.25rem;
63+
border-radius: 0.5rem;
6364
padding: 0.25rem;
6465
}
6566

@@ -79,7 +80,7 @@
7980
display: none;
8081
}
8182

82-
& input[type="radio"]:checked + .icon {
83+
& input[type="radio"]:checked+.icon {
8384
color: white;
8485
}
8586

@@ -125,7 +126,7 @@
125126
perspective: 1000px;
126127
margin: auto;
127128

128-
& > letter-panel {
129+
&>letter-panel {
129130
display: block;
130131
width: 100%;
131132
height: 100%;
@@ -147,58 +148,64 @@
147148
width: var(--panel-width);
148149
height: var(--panel-height);
149150
backface-visibility: visible;
150-
display: grid;
151-
place-items: center;
151+
display: flex;
152+
align-items: center;
153+
justify-content: center;
152154
font-size: 3rem;
153155
color: var(--text);
154156
background: var(--surface);
155157
border-radius: 0.5rem;
156158
box-shadow: 0 2px 8px var(--shadow);
157-
transition: transform 0.6s;
159+
transition: transform 0.6s, font-size 0.6s, background-color 0.6s;
158160
opacity: 0.7;
159161
}
160162

161163
& .panel__cell:nth-child(10n + 1) {
162-
background: var(--color-1);
164+
background-color: #3b82f6;
163165
}
164166

165167
& .panel__cell:nth-child(10n + 2) {
166-
background: var(--color-2);
168+
background-color: #8b5cf6;
167169
}
168170

169171
& .panel__cell:nth-child(10n + 3) {
170-
background: var(--color-3);
172+
background-color: #ec4899;
171173
}
172174

173175
& .panel__cell:nth-child(10n + 4) {
174-
background: var(--color-4);
176+
background-color: #f43f5e;
175177
}
176178

177179
& .panel__cell:nth-child(10n + 5) {
178-
background: var(--color-5);
180+
background-color: #f97316;
179181
}
180182

181183
& .panel__cell:nth-child(10n + 6) {
182-
background: var(--color-6);
184+
background-color: #84cc16;
183185
}
184186

185187
& .panel__cell:nth-child(10n + 7) {
186-
background: var(--color-7);
188+
background-color: #06b6d4;
187189
}
188190

189191
& .panel__cell:nth-child(10n + 8) {
190-
background: var(--color-8);
192+
background-color: #6366f1;
191193
}
192194

193195
& .panel__cell:nth-child(10n + 9) {
194-
background: var(--color-9);
196+
background-color: #0ea5e9;
195197
}
196198

197199
& .panel__cell:nth-child(10n + 0) {
198-
background: var(--color-10);
200+
background-color: #14b8a6;
201+
}
202+
203+
& .panel__cell.front {
204+
font-size: 10rem;
205+
background-color: black;
206+
transition: font-size 0.6s, background-color 0.6s;
199207
}
200208

201-
/* Add rotation values back */
202209
& .panel__cell:nth-child(1) {
203210
--ry: var(--ry, 0deg);
204211
}
@@ -238,4 +245,4 @@
238245
& .panel__cell:nth-child(10) {
239246
--ry: 360deg;
240247
}
241-
}
248+
}

src/pages/panel.astro

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ import "@/assets/styles/common.css";
165165
cell.style.transform = transformString;
166166
});
167167
this.rotatePanel({ by: this.#orientation });
168+
this.updateFrontCell(); // update front cell styling
169+
}
170+
171+
updateFrontCell() {
172+
const cells = this.#panel.querySelectorAll(".panel__cell") as NodeListOf<HTMLElement>;
173+
if (!cells.length) return;
174+
cells.forEach((cell) => cell.classList.remove("front"));
175+
const count = cells.length;
176+
const normalizedIndex = ((this.#selectedIndex % count) + count) % count;
177+
const frontIndex = (count - normalizedIndex) % count;
178+
cells[frontIndex].classList.add("front");
168179
}
169180

170181
rotatePanel({ by = "X" }) {

0 commit comments

Comments
 (0)