This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
209 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { IntRange } from '../types/utils'; | ||
|
||
export type SpecialDate = { | ||
month: IntRange<0, 13>; | ||
day: IntRange<0, 32>; | ||
}; | ||
|
||
export type specialDateRange = { | ||
start: SpecialDate; | ||
end: SpecialDate; | ||
}; | ||
|
||
const specialDateNames = ['helloween', 'christmas'] as const; | ||
|
||
export type SpecialDates = (typeof specialDateNames)[number]; | ||
|
||
export const dates: Record<SpecialDates, specialDateRange> = { | ||
helloween: { | ||
start: { | ||
month: 10, | ||
day: 29 | ||
}, | ||
end: { | ||
month: 11, | ||
day: 1 | ||
} | ||
}, | ||
christmas: { | ||
start: { | ||
month: 12, | ||
day: 22 | ||
}, | ||
end: { | ||
month: 12, | ||
day: 26 | ||
} | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts"> | ||
let height: number; | ||
let width: number; | ||
let offsetHeight: number; | ||
let offsetWidth: number; | ||
let showTooltip = false; | ||
</script> | ||
|
||
<a href="/"> | ||
<div | ||
class="h-full" | ||
bind:clientHeight={height} | ||
bind:clientWidth={width} | ||
bind:offsetHeight | ||
bind:offsetWidth | ||
on:mouseleave={() => (showTooltip = false)} | ||
on:mouseenter={() => (showTooltip = true)} | ||
role="img" | ||
aria-label="Halloween" | ||
> | ||
<img | ||
src="/assets/pumpkin.svg" | ||
alt="Halloween" | ||
title="Dlool - Halloween" | ||
class="h-full object-contain" | ||
/> | ||
</div> | ||
</a> | ||
|
||
<div | ||
style="--offsetHeight: {height + offsetHeight / 2}px; --offsetWidth: {width}px;" | ||
class="fixed bg-gray-200 dark:bg-gray-800 px-3 py-1 rounded-md shadow-lg top-[var(--offsetHeight)] left-[var(--offsetWidth)]" | ||
class:hidden={!showTooltip} | ||
class:inline-block={showTooltip} | ||
> | ||
<p> | ||
" | ||
<a | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
href="https://svgsilh.com/ja/ffc107/image/1298797.html">かぼちゃ</a | ||
> | ||
" is marked with | ||
<a | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
href="https://creativecommons.org/publicdomain/zero/1.0/?ref=openverse">CC0 1.0</a | ||
>. | ||
</p> | ||
</div> |
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,39 @@ | ||
import { | ||
dates, | ||
type SpecialDate, | ||
type specialDateRange, | ||
type SpecialDates | ||
} from '../../constants/dates'; | ||
|
||
const isAfterDate = (date: SpecialDate): boolean => { | ||
const currentDay = new Date().getDate(); | ||
const currentMonth = new Date().getMonth() + 1; | ||
return currentMonth > date.month || (currentMonth === date.month && currentDay >= date.day); | ||
}; | ||
|
||
const isBeforeDate = (date: SpecialDate): boolean => { | ||
const currentDay = new Date().getDate(); | ||
const currentMonth = new Date().getMonth() + 1; | ||
return currentMonth < date.month || (currentMonth === date.month && currentDay <= date.day); | ||
}; | ||
|
||
const isDate = (date: SpecialDate): boolean => { | ||
const currentDay = new Date().getDate(); | ||
const currentMonth = new Date().getMonth() + 1; | ||
return currentMonth === date.month && currentDay === date.day; | ||
}; | ||
|
||
const isInRange = (date: specialDateRange): boolean => { | ||
const { start, end } = date; | ||
return (isAfterDate(start) && isBeforeDate(end)) || isDate(start) || isDate(end); | ||
}; | ||
|
||
export const currentSpecialDates = (d: Record<SpecialDates, specialDateRange> = dates) => { | ||
const currentDates = Object.values(d).filter(isInRange); | ||
const currentDatesNames = Object.keys(d).filter((key) => | ||
currentDates.includes(d[key as SpecialDates]) | ||
); | ||
return currentDatesNames as SpecialDates[]; | ||
}; | ||
|
||
export const isSpecialDate = (date: SpecialDates): boolean => currentSpecialDates().includes(date); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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