Skip to content

Commit 1535bd6

Browse files
committed
fix: alignment issues on different breakpoints
1 parent 5dda8be commit 1535bd6

2 files changed

Lines changed: 41 additions & 24 deletions

File tree

src/lib/components/Clock.svelte

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,58 +69,63 @@
6969
interval = setInterval(() => {
7070
[timeHours, timeMinutes] = getTime(hasTemporal);
7171
updateMarker();
72-
}, 10000);
72+
totalMinutes += 20;
73+
}, 1000);
7374
});
7475
7576
onDestroy(() => {
7677
clearInterval(interval);
7778
});
7879
</script>
7980

80-
<div class="absolute top-0">
81+
<div class="absolute top-1">
8182
<svg
82-
class="absolute z-[-1] w-auto h-[70vw] -translate-x-1/2 -translate-y-1/2"
83-
viewBox="-0 0 100 100"
83+
class="absolute z-[-1] w-xs md:w-3xl lg:w-4xl h-auto -translate-x-1/2"
84+
viewBox="0 0 100 100"
8485
>
8586
<circle
8687
cx="50"
87-
cy="100"
88-
r="46"
88+
cy="50"
89+
r="45"
8990
fill="transparent"
9091
stroke={textColour}
91-
stroke-width="0.5"
92-
stroke-dasharray="1,10,1"
92+
stroke-width="5"
93+
stroke-dasharray="10 100 10"
94+
vector-effect="non-scaling-stroke"
9395
>
9496
<animateTransform
9597
attributeName="transform"
9698
begin="0s"
9799
dur="60s"
98100
type="rotate"
99-
from="0 50 100"
100-
to="360 50 100"
101+
from="0 50 50"
102+
to="360 50 50"
101103
repeatCount="indefinite"
102104
/>
103105
</circle>
104-
<!-- <circle cx="50" cy="100.5" r="1" fill="magenta" /> -->
106+
<!-- <circle cx="50" cy="50" r="0.1" fill="magenta" /> -->
105107
</svg>
106-
<div bind:this={marker} class="clock">
108+
<div bind:this={marker} class="clock origin-[center_10rem] md:origin-[center_24rem] lg:origin-[center_28rem]">
107109
<ThemeToggle />
108-
<!-- <div -->
109-
<!-- class="absolute h-100 bg-blue-500 rounded-full clock-arm" -->
110-
<!-- ></div> -->
110+
<!-- <div class="bg-blue-500 rounded-full clock-arm"></div> -->
111111
</div>
112-
<!-- <div -->
113-
<!-- class="absolute w-2 h-2 bg-red-500 rounded-full" -->
114-
<!-- style="top: 35vw; left: 50%; transform: translate(-50%, -50%);" -->
115-
<!-- ></div> -->
116112
</div>
117113

118114
<style>
119115
.clock {
120116
position: absolute;
121117
width: max-content;
122-
transform-origin: center 35vw;
123118
transform: translateX(-32px) rotate(-90deg);
124119
transition: transform 1s ease-in-out;
125120
}
126121
</style>
122+
<!-- .clock-arm { -->
123+
<!-- position: absolute; -->
124+
<!-- top: 50%; -->
125+
<!-- left: 50%; -->
126+
<!-- width: 2px; -->
127+
<!-- height: 500px; -->
128+
<!---->
129+
<!-- transform-origin: bottom center; -->
130+
<!-- transform: translate(-50%, 0); -->
131+
<!-- } -->

src/lib/components/ThemeToggle.svelte

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,25 @@
5454
</script>
5555

5656
<button bind:this={sunButton} onclick={toggleTheme}>
57-
<img src="/icons/sun.svg" alt="Sun" class="hover-expand w-[5vw]" />
57+
<img src="/icons/sun.svg" alt="Sun" class="hover-expand w-16" />
5858
</button>
5959
<button bind:this={moonButton} onclick={toggleTheme}>
60-
<img src="/icons/moon.svg" width="64" alt="Moon" class="hover-expand w-[5vw]" />
60+
<img src="/icons/moon.svg" alt="Moon" class="hover-expand w-16" />
6161
</button>
6262

6363
<style>
64-
.hover-expand { transition: all 0.5s; transform: rotate(45deg); }
65-
.hover-expand:hover { scale: 110%; }
64+
.hover-expand {
65+
transition: all 0.5s;
66+
transform: translateY(-20%) rotate(45deg);
67+
68+
@media (width >= 48rem) {
69+
transform: translateY(10%) rotate(45deg);
70+
}
71+
@media (width >= 64rem) {
72+
transform: translateY(20%) rotate(45deg);
73+
}
74+
}
75+
.hover-expand:hover {
76+
scale: 110%;
77+
}
6678
</style>

0 commit comments

Comments
 (0)