Skip to content

Commit af7bf22

Browse files
authored
Minor update to clock
1 parent 93d9321 commit af7bf22

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

clock/script.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,19 @@
451451
if (e.key === "Escape") {
452452
this.state.selectedHand = null;
453453
}
454+
455+
const keyNum = parseInt(e.key, 10);
456+
if (!isNaN(keyNum) && keyNum >= 1 && keyNum <= 12) {
457+
// Convert to 24-hour format based on current time
458+
const currentMinutes = Math.round(this.state.totalMinutes);
459+
const currentHours = Math.floor(
460+
utils.mod(currentMinutes, C.MINUTES_IN_24_HOURS) / 60
461+
);
462+
const isAm = currentHours < 12;
463+
const h12 = keyNum % 12;
464+
const newHour = isAm ? h12 : h12 + 12;
465+
this.setTime(newHour, 0, true);
466+
}
454467
}
455468

456469
// --- Helper Methods ---

clock/style.css

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ p {
4848
margin: 0 auto;
4949
margin-bottom: 20px;
5050
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.5);
51+
box-shadow: inset 0 0 10px rgba(0, 0, 0, 1), 0 10px 20px rgba(0, 0, 0, 0.5);
5152
border: 8px solid var(--border);
5253
border-radius: 50%;
5354
background: var(--clock-bg);
@@ -62,25 +63,28 @@ p {
6263
left: 50%;
6364
transform: translate(-50%, -90%) rotate(0deg);
6465
transform-origin: 50% 90%;
66+
/* clip-path: polygon(50% 0%, 100% 20%, 100% 100%, 0% 100%, 0% 20%); */
6567
transition: transform 0.35s ease-in-out;
6668
cursor: grab;
6769
box-sizing: content-box;
68-
border-radius: 4px;
70+
border-radius: 10px;
6971
touch-action: none;
7072
}
7173

7274
.hand.hour {
7375
z-index: 2;
76+
border: 3px solid color-mix(in srgb, var(--accent-hour) 60%, black);
7477
background: var(--accent-hour);
75-
width: 10px;
78+
width: 11px;
7679
height: 80px;
7780
}
7881

7982
.hand.minute {
8083
z-index: 1;
84+
border: 3px solid color-mix(in srgb, var(--accent-minute) 60%, black);
8185
background: var(--accent-minute);
8286
width: 5px;
83-
height: 120px
87+
height: 115px;
8488
}
8589

8690
#hourHand,
@@ -100,10 +104,14 @@ p {
100104
left: 50%;
101105
transform: translate(-50%, -50%);
102106
z-index: 10;
107+
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
108+
border: 2px solid rgba(0, 0, 0, 0.5);
103109
border-radius: 50%;
104110
background: var(--text);
111+
background: radial-gradient(circle at center, #fff 0%, #999 100%);
105112
width: 16px;
106113
height: 16px;
114+
;
107115
}
108116

109117
.number {
@@ -112,8 +120,10 @@ p {
112120
transform: translate(-50%, -50%);
113121
cursor: pointer;
114122
padding: 10px;
123+
color: #333;
115124
font-weight: bold;
116-
font-size: 1.2rem;
125+
font-size: 1.4rem;
126+
text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
117127
}
118128

119129
.tick {
@@ -125,6 +135,7 @@ p {
125135
transform-origin: center center;
126136
cursor: pointer;
127137
box-sizing: content-box;
138+
border-radius: 1px;
128139
background: var(--text);
129140
background-clip: content-box;
130141
padding: 10px;
@@ -135,17 +146,17 @@ p {
135146
/* Digital input */
136147
input[type="time"] {
137148
box-sizing: border-box;
138-
border: 2px solid var(--border);
139-
border-radius: 8px;
149+
border: 5px solid var(--border);
150+
border-radius: 10px;
140151
background: var(--card);
141-
padding: 8px 12px;
152+
padding: 6px 25px;
142153
width: 12ch;
143154
min-width: 0;
144155
height: 40px;
145156
min-inline-size: 0;
146157
color: var(--text);
147158
font-weight: bold;
148-
font-size: 1rem;
159+
font-size: 1.2rem;
149160
line-height: normal;
150161
}
151162

0 commit comments

Comments
 (0)