Skip to content

Commit

Permalink
fix(Timeline): forward all events including child components
Browse files Browse the repository at this point in the history
  • Loading branch information
N00nDay committed Oct 15, 2022
1 parent d7dddca commit f29c7ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/lib/components/timeline/Item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import type { MaterialIcon } from '../../types';
import Avatar from '../avatar';
import { formatDate } from '../../utils';
import { get_current_component } from 'svelte/internal';
import { forwardEventsBuilder, useActions, type ActionArray } from '../../actions';
export let use: ActionArray = [];
import { exclude } from '../../utils/exclude';
const forwardEvents = forwardEventsBuilder(get_current_component());
export let type: 'comment' | undefined = undefined;
export let avatar: string | undefined = undefined;
Expand All @@ -12,7 +17,7 @@
</script>

{#if type === 'comment'}
<li>
<li use:useActions={use} use:forwardEvents {...exclude($$props, ['use'])}>
<div class="relative pb-8">
<span
class="divider absolute top-5 left-5 -ml-px h-full w-0.5 bg-light-border dark:bg-dark-border"
Expand Down Expand Up @@ -53,7 +58,7 @@
</div>
</li>
{:else}
<li>
<li use:useActions={use} use:forwardEvents {...exclude($$props, ['use'])}>
<div class="relative pb-8">
<span
class="divider absolute top-5 left-5 -ml-px h-full w-0.5 bg-light-border dark:bg-dark-border"
Expand Down
15 changes: 14 additions & 1 deletion src/lib/components/timeline/Timeline.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<div class="flow-root">
<script lang="ts">
import { get_current_component } from 'svelte/internal';
import { forwardEventsBuilder, useActions, type ActionArray } from '../../actions';
export let use: ActionArray = [];
import { exclude } from '../../utils/exclude';
const forwardEvents = forwardEventsBuilder(get_current_component());
</script>

<div
class="flow-root{$$props.class ? ` ${$$props.class}` : ''}"
use:useActions={use}
use:forwardEvents
{...exclude($$props, ['use', 'class'])}
>
<ul class="-mb-8">
<slot />
</ul>
Expand Down

0 comments on commit f29c7ba

Please sign in to comment.