-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FEAT: Grayscale past prayer * CHORE: Move prayerTitle to props * FIX: Handle theme light
- Loading branch information
Showing
7 changed files
with
124 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,11 @@ | |
"prettier-plugin-svelte": "^3.2.7", | ||
"schema-dts": "^1.1.2", | ||
"sitemaps": "^2.0.6", | ||
"svelte-check": "^4.0.0", | ||
"svelte-check": "^4.0.5", | ||
"tailwindcss": "^3.4.14", | ||
"tslib": "^2.8.0", | ||
"typescript": "^5.6.3", | ||
"vite": "^5.4.9" | ||
"vite": "^5.4.10" | ||
}, | ||
"type": "module", | ||
"packageManager": "[email protected]", | ||
|
@@ -46,8 +46,9 @@ | |
"pnpm": "^9.12.2" | ||
}, | ||
"dependencies": { | ||
"tw-colors": "^3.3.2", | ||
"dayjs": "^1.11.13", | ||
"firebase": "^11.0.1", | ||
"svelte": "^5.0.0" | ||
"svelte": "^5.0.0", | ||
"tw-colors": "^3.3.2" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,52 @@ | ||
<script lang="ts"> | ||
import CardShadow from './CardShadow.svelte'; | ||
import type { PrayerTimings } from './types'; | ||
import type { PrayerKey, PrayerTimings } from './types'; | ||
import dayjs from 'dayjs'; | ||
import relativeTime from "dayjs/plugin/relativeTime"; | ||
import duration from "dayjs/plugin/duration"; | ||
import 'dayjs/locale/id' | ||
import { onMount } from 'svelte'; | ||
const TITLE_MAP = { | ||
Fajr: 'Subuh', | ||
Dhuhr: 'Dzuhur', | ||
Asr: 'Ashar', | ||
Maghrib: 'Maghrib', | ||
Isha: 'Isya' | ||
}; | ||
import { activeTheme } from '../store'; | ||
dayjs.locale('id') | ||
dayjs.extend(relativeTime); | ||
dayjs.extend(duration); | ||
interface Props { | ||
timings?: PrayerTimings | null; | ||
prayerKey?: 'Fajr' | 'Dhuhr' | 'Asr' | 'Maghrib' | 'Isha'; | ||
prayerKey: PrayerKey; | ||
prayerTitle: string | ||
} | ||
let { timings = null, prayerKey = 'Fajr' }: Props = $props(); | ||
let { timings = null, prayerKey, prayerTitle = '' }: Props = $props(); | ||
let isPast: boolean = $state(false); | ||
let durationText: string = $state(''); | ||
onMount(async () => { | ||
const now = dayjs(); | ||
const timeStr = `${timings?.[prayerKey] || ''}`.substring(0, 5); | ||
const prayerTime = dayjs(`${now.format('YYYY-MM-DD')} ${timeStr}`, 'YYYY-MM-DD HH:mm'); | ||
const diffTime = prayerTime.diff(now, 'minute'); | ||
isPast = diffTime < 0; | ||
durationText = dayjs.duration(diffTime, "minutes").humanize(true); | ||
}); | ||
</script> | ||
|
||
{#if timings} | ||
<CardShadow> | ||
<div class="flex justify-between items-center gap-2"> | ||
<span>{TITLE_MAP[prayerKey]}</span> | ||
<span>{timings[prayerKey]}</span> | ||
<CardShadow class={`${isPast ? $activeTheme === 'light' ? '!bg-gray-400' : 'grayscale' : ''}`}> | ||
<div class="flex justify-between gap-2 relative"> | ||
<div> | ||
<p>{prayerTitle}</p> | ||
</div> | ||
<div> | ||
<p>{timings[prayerKey]}</p> | ||
{#if !isPast} | ||
<small>{durationText}</small> | ||
{/if} | ||
</div> | ||
</div> | ||
</CardShadow> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts"> | ||
import PrayerTimeCard from "./PrayerTimeCard.svelte"; | ||
import type { PrayerKey, PrayerTimings } from "./types"; | ||
interface Props { | ||
timings?: PrayerTimings | null; | ||
} | ||
const PRAYER_LIST: Array<{ | ||
key: PrayerKey; | ||
title: string; | ||
}> = [{ | ||
key: 'Fajr', | ||
title: 'Subuh' | ||
}, { | ||
key: 'Dhuhr', | ||
title: 'Dzuhur' | ||
}, { | ||
key: 'Asr', | ||
title: 'Ashar' | ||
}, { | ||
key: 'Maghrib', | ||
title: 'Maghrib' | ||
}, { | ||
key: 'Isha', | ||
title: 'Isya' | ||
}]; | ||
let { timings = null }: Props = $props(); | ||
</script> | ||
|
||
{#each PRAYER_LIST as prayer (prayer.key)} | ||
<PrayerTimeCard timings={timings} prayerKey={prayer.key} prayerTitle={prayer.title} /> | ||
{/each} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters