Skip to content

Commit

Permalink
refactor: update class names and styles
Browse files Browse the repository at this point in the history
  • Loading branch information
PunGrumpy committed Jun 24, 2024
1 parent ce314ee commit ef9142f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 52 deletions.
19 changes: 6 additions & 13 deletions src/components/CardSubject.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,18 @@
class="bg-white dark:bg-gray-800 shadow-md rounded-lg p-4 hover:shadow-lg transition-shadow flex flex-col justify-between h-full"
>
<div
class="flex justify-between text-sm md:text-md text-gray-400 dark:text-gray-500"
class="flex justify-between text-sm md:text-md text-gray-500 dark:text-gray-400"
>
<p>{subject.time.type}</p>
<p class="whitespace-nowrap">
{subject.time.start} - {subject.time.end}
</p>
<p class="whitespace-nowrap">{subject.time.start} - {subject.time.end}</p>
</div>
<h3 class="text-orange-500 font-bold text-lg dark:text-orange-400">
<h3 class="text-orange-500 font-bold text-lg dark:text-orange-400 mt-2">
{subject.name}
</h3>
<div
class="flex justify-between text-sm md:text-md text-gray-600 dark:text-gray-400"
class="flex justify-between text-sm md:text-md text-gray-700 dark:text-gray-300 mt-2"
>
<p class="whitespace-nowrap">
section({getSectionType()})
</p>
<p class="whitespace-nowrap">
{subject.building}
{displayRoom()}
</p>
<p class="whitespace-nowrap">Section ({getSectionType()})</p>
<p class="whitespace-nowrap">{subject.building} {displayRoom()}</p>
</div>
</div>
4 changes: 2 additions & 2 deletions src/components/Head.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
</script>

<div
class="bg-orange-100/50 dark:bg-orange-900/50 text-orange-500 dark:text-orange-400 rounded-lg font-mplus px-4 py-4 border border-orange-200 dark:border-orange-700 flex flex-col md:flex-row justify-between items-center"
class="bg-orange-100/50 dark:bg-orange-900/50 text-orange-500 dark:text-orange-400 rounded-lg font-mplus px-4 py-4 border border-orange-200 dark:border-orange-700 flex flex-col md:flex-row justify-between items-center space-y-2 md:space-y-0 md:space-x-4"
>
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/94/KMITL_Sublogo.svg/1024px-KMITL_Sublogo.svg.png"
alt="kmitl logo"
class="w-16 h-16 md:w-24 md:h-24 object-contain"
/>
<div class="text-center md:text-right mt-2 md:mt-0">
<div class="text-center md:text-right">
<h1 class="text-xl md:text-2xl font-bold">
ตารางเรียน {information.Semester}/{information.year}
</h1>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ScheduleTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{#if hour < 20 - 1}
<th
scope="col"
class="border-x border-gray-200 dark:border-gray-700 p-2"
class="border-x border-gray-200 dark:border-gray-700 p-2 text-xs md:text-sm"
colspan="4"
>
{`${formatTime(hour)} - ${formatTime(hour + 1)}`}
Expand Down
48 changes: 22 additions & 26 deletions src/components/ThemeToggle.svelte
Original file line number Diff line number Diff line change
@@ -1,49 +1,45 @@
<script lang="ts">
import Icon from '@iconify/svelte'
import { onMount } from 'svelte'
let theme = 'system'
let theme = 'dark'
onMount(() => {
theme = localStorage.getItem('theme') || 'system'
theme = localStorage.getItem('theme') || 'dark'
applyTheme(theme)
})
function applyTheme(theme: string) {
const root = document.documentElement
root.classList.remove('light', 'dark')
if (theme === 'system') {
const prefersDark = window.matchMedia(
'(prefers-color-scheme: dark)'
).matches
root.classList.add(prefersDark ? 'dark' : 'light')
if (theme === 'light') {
root.classList.add('light')
} else {
root.classList.add(theme)
root.classList.add('dark')
}
localStorage.setItem('theme', theme)
}
function handleThemeChange(event: Event) {
if (event.target instanceof HTMLSelectElement) {
theme = event.target.value
}
applyTheme(theme)
function toggleTheme() {
const newTheme = theme === 'light' ? 'dark' : 'light'
theme = newTheme
applyTheme(newTheme)
}
</script>

<div>
<label for="theme-toggle" class="text-xs md:text-sm text-orange-500"
>Theme:
</label>
<select
id="theme-toggle"
on:change={handleThemeChange}
bind:value={theme}
class="border rounded px-2 py-1"
<div
class="rounded-lg py-2 px-4 bg-orange-500 text-white text-xs md:text-sm hover:bg-orange-600 transition-colors flex items-center"
>
<button
on:click={toggleTheme}
class="rounded-lg bg-orange-500 text-white text-xs md:text-sm hover:bg-orange-600 transition-colors flex items-center"
>
<option value="system">System</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
<Icon
icon={theme === 'light' ? 'ph:moon-stars-fill' : 'ph:sun-fill'}
class="mr-2"
/>
{theme === 'light' ? 'Dark Mode' : 'Light Mode'}
</button>
</div>
16 changes: 6 additions & 10 deletions src/pages/StudentTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
const screenshotToClipboard = async () => {
const blob = await toBlob(captureScreen)
if (blob == null) return
navigator.clipboard.write([
new ClipboardItem({
'image/png': blob
})
])
navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })])
}
const exportPng = async () => {
Expand Down Expand Up @@ -50,8 +46,10 @@
<ScheduleTable {schedule} />
</div>
</div>
<footer class="flex flex-col md:flex-row justify-between items-center mt-4">
<div class="flex space-x-3 mb-2 md:mb-0">
<footer
class="flex flex-col md:flex-row justify-between items-center mt-4 space-y-2 md:space-y-0 md:space-x-4"
>
<div class="flex space-x-3">
<button
on:click={screenshotToClipboard}
class="rounded-lg py-2 px-4 bg-orange-500 text-white text-xs md:text-sm hover:bg-orange-600 transition-colors flex items-center"
Expand All @@ -71,6 +69,7 @@
>
<Icon icon="mdi:github" class="mr-2" /> Contribute
</button>
<ThemeToggle />
</div>
<div
class="text-center md:text-right text-xs md:text-sm text-orange-500 dark:text-orange-400"
Expand All @@ -83,7 +82,4 @@
</p>
</div>
</footer>
<div class="fixed bottom-4 right-4">
<ThemeToggle />
</div>
</main>

0 comments on commit ef9142f

Please sign in to comment.