Skip to content

Commit

Permalink
add listeners to stories
Browse files Browse the repository at this point in the history
  • Loading branch information
fivaz committed Apr 28, 2024
1 parent aabd125 commit 5558a59
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
<Template let:args>
<CalendarBody
{...args}
on:createTask={(args) => console.log('create', args)}
on:editTask={(args) => console.log('edit', args)}
on:createTask={(args) => console.log('createTask', args.detail)}
on:editTask={(args) => console.log('editTask', args.detail)}
on:moveEvent={(args) => console.log('moveEvent', args.detail)}
on:toggleEvent={(args) => console.log('toggleEvent', args.detail)}
{tasks}
weekStart={startOfWeek(new Date())}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
{date}
on:click={(e) => dispatch('createTask', buildDate(date, e.detail))}
on:editTask
on:moveEvent
on:toggleEvent
{tasks}
/>
Expand All @@ -49,6 +50,7 @@
date={selectedDate}
on:click={(e) => dispatch('createTask', buildDate(selectedDate, e.detail))}
on:editTask
on:moveEvent
on:toggleEvent
{tasks}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<CalendarColumns
{...args}
dates={Array.from({ length: 7 }, (_, i) => addDays(new Date(), i))}
on:createTask={(args) => console.log('createTask', args.detail)}
on:editTask={(args) => console.log('editTask', args.detail)}
on:moveEvent={(args) => console.log('moveEvent', args.detail)}
on:toggleEvent={(args) => console.log('toggleEvent', args.detail)}
selectedDate={new Date()}
tasks={events}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@
</script>

<Template let:args>
<CalendarRows {...args} date={new Date()} {tasks} />
<CalendarRows
{...args}
date={new Date()}
on:click={(args) => console.log('click', args.detail)}
on:editTask={(args) => console.log('editTask', args.detail)}
on:moveEvent={(args) => console.log('moveEvent', args.detail)}
on:toggleEvent={(args) => console.log('toggleEvent', args.detail)}
{tasks}
/>
</Template>

<Story args={{}} name="Primary" />
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@

<Template let:args>
<div class="relative h-48 w-48">
<EventPanelCore {...args} />
<EventPanelCore
{...args}
isSelected={false}
on:toggleEvent={(args) => console.log('toggleEvent', args.detail)}
targetDate={new Date()}
/>
</div>
</Template>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script context="module" lang="ts">
import type { Meta } from '@storybook/svelte';
import { getTimeSlots } from '$lib/components/calendar/calendar-body/calendar-columns/calendar-rows/service';
import { done, long, normalWithoutDescription, shortWithoutDescription } from '$lib/task/seed';
import { Story, Template } from '@storybook/addon-svelte-csf';
Expand All @@ -15,9 +16,21 @@
} satisfies Meta<EventPanel>;
</script>

<script>
import { tasks } from '$lib/task/seed';
</script>

<Template let:args>
<div class="!relative w-52">
<EventPanel {...args} class="!static" />
<EventPanel
{...args}
class="!static"
on:editTask={(args) => console.log('editTask', args.detail)}
on:moveEvent={(args) => console.log('moveEvent', args.detail)}
on:toggleEvent={(args) => console.log('toggleEvent', args.detail)}
targetDate={new Date()}
timeSlots={getTimeSlots(tasks, new Date())}
/>
</div>
</Template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
</script>

<Template let:args>
<WeekList {...args} dates={Array.from({ length: 7 }, (_, i) => addDays(new Date(), i))} />
<WeekList
{...args}
dates={Array.from({ length: 7 }, (_, i) => addDays(new Date(), i))}
selectedDate={new Date()}
/>
</Template>

<Story args={{}} name="Primary" />
9 changes: 8 additions & 1 deletion src/lib/components/calendar/calendar.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@

<Template let:args>
<div class="h-screen">
<Calendar {...args} {tasks} />
<Calendar
{...args}
on:createTask={(args) => console.log('createTask', args.detail)}
on:editTask={(args) => console.log('editTask', args.detail)}
on:moveEvent={(args) => console.log('moveEvent', args.detail)}
on:toggleEvent={(args) => console.log('toggleEvent', args.detail)}
{tasks}
/>
</div>
</Template>

Expand Down

0 comments on commit 5558a59

Please sign in to comment.