Skip to content

Commit 628781b

Browse files
committed
Added the horizontal and vertical switch button
1 parent eecff84 commit 628781b

File tree

2 files changed

+46
-23
lines changed

2 files changed

+46
-23
lines changed

src/assets/styles/panel.css

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@
5353

5454
.panel__options {
5555
grid-area: option;
56-
display: grid;
57-
grid-auto-flow: column;
58-
align-content: center;
59-
grid-template-columns: 30% 1fr 30%;
60-
align-self: baseline;
56+
display: flex;
57+
gap: 2rem;
58+
padding: 1rem;
6159
}
6260

6361
.range__option {
@@ -180,37 +178,36 @@ input[type="radio"] {
180178
label {
181179
background-color: var(--orientation__bg--8);
182180
color: var(--panel__cell__txt--6);
183-
border-radius: 0.5rem;
184-
transition: all 0.5s;
181+
border-radius: 1rem;
182+
padding: 0.5rem 2rem;
183+
transition: all 0.3s ease;
185184
cursor: pointer;
186-
font-size: x-large;
187-
display: inline-block;
188-
transform-origin: center;
189-
transform-style: preserve-3d;
190-
transform-box: view-box;
191-
transition-delay: 2ms;
185+
display: flex;
186+
align-items: center;
187+
justify-content: center;
188+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
192189
}
193190

194-
.horizontal {
195-
transform: rotateZ(0deg);
196-
width: 10rem;
197-
height: 3rem;
198-
justify-self: end;
191+
.horizontal, .vertical {
192+
width: 5rem;
193+
height: 5rem;
199194
}
200195

201-
.vertical {
202-
transform: rotateZ(0deg);
203-
height: 10rem;
204-
width: 3rem;
196+
.icon {
197+
font-size: 2rem;
205198
}
206199

207200
label:hover {
208201
background-color: var(--orientation__bg--9);
202+
transform: translateY(-2px);
203+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
209204
}
210205

211206
label:has(input[type="radio"]:checked) {
212207
color: var(--panel__cell__txt--6);
213208
background-color: var(--label__bg--10);
209+
transform: translateY(1px);
210+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
214211
}
215212

216213
/* range slider */

src/pages/panel.astro

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ import "@/assets/styles/common.css";
1313
/>
1414
</Fragment>
1515
<article class="tv container__panel">
16+
<section id="option-box" class="panel__options">
17+
<label class="vertical" for="vertical">
18+
<input type="radio" class="orientation" name="orientation" id="vertical" value="X" />
19+
<span class="icon">↕️</span>
20+
</label>
21+
22+
<label class="horizontal" for="horizontal">
23+
<input type="radio" class="orientation" name="orientation" id="horizontal" value="Y" />
24+
<span class="icon">↔️</span>
25+
</label>
26+
</section>
27+
1628
<section class="scene">
1729
<letter-panel>
1830
<div class="panel" id="panel"></div>
@@ -30,6 +42,7 @@ import "@/assets/styles/common.css";
3042
// Define the behaviour for our new type of HTML element.
3143
class LetterPanel extends HTMLElement {
3244
#panel;
45+
#orientationPanel;
3346
#orientation = "Y";
3447
#selectedIndex = 0;
3548
#radius = "0px";
@@ -39,7 +52,7 @@ import "@/assets/styles/common.css";
3952
constructor() {
4053
super();
4154
this.#panel = this.querySelector("#panel") as HTMLElement;
42-
//this.checkPanel();
55+
this.#orientationPanel = document.querySelectorAll(".orientation");
4356
this.#emitEvent();
4457
}
4558

@@ -55,6 +68,19 @@ import "@/assets/styles/common.css";
5568
console.log({ charCode, code, keyCode, key });
5669
this.onKeyChange(keyCode);
5770
});
71+
72+
this.#orientationPanel.forEach((radio) => {
73+
radio.addEventListener(
74+
"click",
75+
(e: Event) => {
76+
const target = e.target as HTMLInputElement;
77+
this.#orientation = target.value;
78+
this.changePanel();
79+
target.blur(); //unfocus the radio button
80+
},
81+
false
82+
);
83+
});
5884
}
5985

6086
doTheMath() {

0 commit comments

Comments
 (0)