-
Notifications
You must be signed in to change notification settings - Fork 2
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
3 changed files
with
70 additions
and
43 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,45 @@ | ||
<script lang="ts"> | ||
import TextInput from '$lib/components/input/Text.svelte'; | ||
import { i } from '$lib/i18n/store'; | ||
import { asyncRequestAnimationFrame } from '$lib/utils/dom'; | ||
import { svocal } from '$lib/utils/store/svocal'; | ||
import type { TimetableWeekday } from '../settings/timetable/types'; | ||
import { addRow, countMaxLessons, getLastLessons } from '../settings/timetable/utils'; | ||
export let isToday: boolean; | ||
export let elements: Record<string, HTMLInputElement | undefined>; | ||
export let day: TimetableWeekday; | ||
export let dayIndex: number; | ||
export let lessonIndex: number; | ||
const timetable = svocal('settings.timetable'); | ||
</script> | ||
|
||
<td | ||
class="bg-opacity-20 px-1 py-3 dark:bg-opacity-10" | ||
class:bg-emerald-200={isToday} | ||
class:dark:bg-emerald-800={isToday} | ||
> | ||
<TextInput | ||
minimal | ||
placeholder={i('settings.timetable.subject.placeholder')} | ||
value={$timetable[day][lessonIndex] ?? undefined} | ||
on:input={({ detail }) => { | ||
$timetable[day][lessonIndex] = detail; | ||
}} | ||
on:enter={async () => { | ||
const isOnlyNull = getLastLessons($timetable).every((x) => x === null); | ||
const hasLessons = countMaxLessons($timetable) > 0; | ||
if (!(isOnlyNull && hasLessons)) { | ||
timetable.update(addRow); | ||
await asyncRequestAnimationFrame(); | ||
} | ||
|
||
const nextEle = elements[`${lessonIndex + 1}-${dayIndex}`]; | ||
if (!nextEle) return; | ||
|
||
nextEle.focus(); | ||
}} | ||
bind:element={elements[`${lessonIndex}-${dayIndex}`]} | ||
/> | ||
</td> |
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,22 @@ | ||
<script lang="ts"> | ||
import { svocal } from '$lib/utils/store/svocal'; | ||
import { WEEKDAYS } from '../settings/timetable/weekdays'; | ||
import TimetableCell from './TimetableCell.svelte'; | ||
export let elements: Record<string, HTMLInputElement | undefined>; | ||
export let lessonIndex: number; | ||
const weekStartsOn = svocal('settings.weekStartsOn'); | ||
const showWeekend = svocal('settings.timetable.showWeekend'); | ||
const currentWeekday = WEEKDAYS[new Date().getDay()]; | ||
</script> | ||
|
||
{#each WEEKDAYS as _, ind} | ||
{@const day = WEEKDAYS[(ind + $weekStartsOn) % 7]} | ||
{@const show = $showWeekend ? true : !(day === 'sat' || day === 'sun')} | ||
|
||
{#if show} | ||
<TimetableCell {day} {elements} {lessonIndex} dayIndex={ind} isToday={currentWeekday === day} /> | ||
{/if} | ||
{/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