-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
major component and folder structure overhaul
- Loading branch information
1 parent
e739d2e
commit 6109c06
Showing
9 changed files
with
117 additions
and
86 deletions.
There are no files selected for viewing
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ib/components/HabitActivityHistory.svelte → ...ponents/Habit/HabitActivityHistory.svelte
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,30 @@ | ||
<script lang="ts"> | ||
import { enhance } from '$app/forms'; | ||
import { Prisma } from '@prisma/client'; | ||
import dayjs from 'dayjs'; | ||
import HabitActivityHistory from './HabitActivityHistory.svelte'; | ||
let { habit } = $props(); | ||
</script> | ||
|
||
<div class="flex flex-col gap-1"> | ||
<div class="flex flex-row justify-between"> | ||
<a href="/{habit.id}"> | ||
<span class="link-hover link text-lg decoration-accent"> | ||
{habit.name} <span class="text-accent">›</span> | ||
</span></a | ||
> | ||
<form method="post" action="?/addToday" use:enhance> | ||
<input type="hidden" name="habitId" value={habit.id} /> | ||
<button | ||
class="btn btn-outline btn-accent btn-xs" | ||
title="Add Today" | ||
disabled={(habit.dates as Prisma.JsonArray).includes(dayjs().format('YYYY-MM-DD'))} | ||
>+</button | ||
> | ||
</form> | ||
</div> | ||
<a href="/{habit.id}" class="rounded-lg bg-base-200 p-4"> | ||
<HabitActivityHistory dates={habit.dates} showWeeks={12} /> | ||
</a> | ||
</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,50 @@ | ||
<script lang="ts"> | ||
import dayjs from 'dayjs'; | ||
import ActivityBubble from './ActivityBubble.svelte'; | ||
let { summary }: { summary: { id: string; name: string; dates: string[] }[] } = $props(); | ||
const thirtyDaysAgo = dayjs().subtract(30, 'days'); | ||
</script> | ||
|
||
{#snippet summaryDateLabel(date: dayjs.Dayjs, spanDays: number)} | ||
<div class="col-span-{spanDays}"> | ||
<div>{date.format('DD')}</div> | ||
<div>{date.format(' MMM')}</div> | ||
</div> | ||
{/snippet} | ||
|
||
<div class="flex flex-shrink"> | ||
<div class="overflow-hidden rounded-lg bg-base-200 p-4"> | ||
<div class="relative grid items-center gap-1 overflow-x-scroll pb-4 text-[0.5rem]"> | ||
<div class="col-span-1"></div> | ||
{@render summaryDateLabel(thirtyDaysAgo.add(1, 'day'), 5)} | ||
{@render summaryDateLabel(thirtyDaysAgo.add(6, 'day'), 5)} | ||
{@render summaryDateLabel(thirtyDaysAgo.add(11, 'day'), 5)} | ||
{@render summaryDateLabel(thirtyDaysAgo.add(16, 'day'), 5)} | ||
{@render summaryDateLabel(thirtyDaysAgo.add(21, 'day'), 5)} | ||
{@render summaryDateLabel(thirtyDaysAgo.add(26, 'day'), 4)} | ||
{@render summaryDateLabel(thirtyDaysAgo.add(30, 'day'), 1)} | ||
|
||
{#each summary as summaryItem} | ||
<a class="link-hover link link-primary sticky left-0 mr-2 text-sm" href="/{summaryItem.id}" | ||
>{summaryItem.name}</a | ||
> | ||
{#each { length: 30 } as _, i} | ||
<ActivityBubble | ||
active={summaryItem.dates.includes( | ||
thirtyDaysAgo.add(i + 1, 'day').format('YYYY-MM-DD') | ||
)} | ||
title={thirtyDaysAgo.add(i + 1, 'day').format('YYYY-MM-DD')} | ||
/> | ||
{/each} | ||
{/each} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.grid { | ||
grid-template-columns: repeat(31, auto); | ||
} | ||
</style> |
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,5 @@ | ||
import type { LayoutServerLoad } from './$types'; | ||
|
||
export const load: LayoutServerLoad = async (event) => { | ||
return { user: event.locals.user }; | ||
}; |
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,9 +1,24 @@ | ||
<script> | ||
<script lang="ts"> | ||
import { enhance } from '$app/forms'; | ||
import type { Snippet } from 'svelte'; | ||
import '../../app.css'; | ||
import type { LayoutData } from './$types'; | ||
let { children } = $props(); | ||
let { children, data }: { data: LayoutData; children: Snippet } = $props(); | ||
</script> | ||
|
||
<div class="container mx-auto px-3 py-8"> | ||
<div class="mb-7 flex flex-row items-center justify-between"> | ||
<span class="text-4xl font-bold text-primary">Habit<span class="text-accent">Kit</span></span> | ||
<div class="flex flex-col"> | ||
<span class="text-xs"> | ||
Logged in as <span class="text-accent">{data.user?.username ?? 'UNDEFINED'}</span> | ||
</span> | ||
<form method="post" action="?/logout" use:enhance> | ||
<button class="text-md btn btn-link btn-accent btn-xs px-0">Sign out</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
{@render children()} | ||
</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
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