Skip to content

Commit

Permalink
fix(Accordion): removed forwardEvents as I cant prevent event bubble …
Browse files Browse the repository at this point in the history
…currently
  • Loading branch information
Craig Howell authored and Craig Howell committed Oct 13, 2022
1 parent 19f3ced commit 62c3b00
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/lib/actions/forward-events-builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function forwardEventsBuilder(component: SvelteComponent) {

if (oldModifierMatch && console) {
console.warn(
'Event modifiers in SMUI now use "$" instead of ":", so that ' +
'Event modifiers in STWUI now use "$" instead of ":", so that ' +
'all events can be bound with modifiers. Please update your ' +
'event binding: ',
eventType
Expand Down Expand Up @@ -62,7 +62,7 @@ export default function forwardEventsBuilder(component: SvelteComponent) {
const oldModifierMatch = eventType.match(oldModifierRegex);
const newModifierMatch = eventType.match(newModifierRegex);
const modifierMatch = oldModifierMatch || newModifierMatch;
if (eventType.match(/^SMUI:\w+:/)) {
if (eventType.match(/^STWUI:\w+:/)) {
const newEventTypeParts = eventType.split(':');
let newEventType = '';
for (let i = 0; i < newEventTypeParts.length; i++) {
Expand Down
13 changes: 1 addition & 12 deletions src/lib/components/accordion/Accordion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
<script lang="ts">
import { setContext } from 'svelte';
import { twMerge } from 'tailwind-merge';
import { current_component } from 'svelte/internal';
import { forwardEventsBuilder, useActions, type ActionArray } from '../../actions';
import { exclude } from '../../utils/exclude';
export let use: ActionArray = [];
const forwardEvents = forwardEventsBuilder(current_component);
setContext(ACCORDION_CONTEXT_ID, {
accordion: true
Expand All @@ -19,12 +14,6 @@
$: finalClass = twMerge(defaultClass, $$props.class);
</script>

<div
class={finalClass}
style={$$props.style}
use:useActions={use}
use:forwardEvents
{...exclude($$props, ['use', 'class'])}
>
<div class={finalClass} style={$$props.style}>
<slot />
</div>
14 changes: 1 addition & 13 deletions src/lib/components/accordion/Content.svelte
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
<script lang="ts">
import { slide } from 'svelte/transition';
import { twMerge } from 'tailwind-merge';
import { current_component } from 'svelte/internal';
import { forwardEventsBuilder, useActions, type ActionArray } from '../../actions';
import { exclude } from '../../utils/exclude';
export let use: ActionArray = [];
const forwardEvents = forwardEventsBuilder(current_component);
const defaultClass =
'border-t border-light-border dark:border-dark-border text-light-secondary-content dark:text-dark-secondary-content';
$: finalClass = twMerge(defaultClass, $$props.class);
</script>

<div
transition:slide|local
class={finalClass}
style={$$props.style}
use:useActions={use}
use:forwardEvents
{...exclude($$props, ['use', 'class'])}
>
<div transition:slide|local class={finalClass} style={$$props.style}>
<slot />
</div>
13 changes: 1 addition & 12 deletions src/lib/components/accordion/Item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
import { useContext } from '../../utils/useContext';
import { twMerge } from 'tailwind-merge';
import { writable } from 'svelte/store';
import { current_component } from 'svelte/internal';
import { forwardEventsBuilder, useActions, type ActionArray } from '../../actions';
import { exclude } from '../../utils/exclude';
export let use: ActionArray = [];
const forwardEvents = forwardEventsBuilder(current_component);
export let open = false;
let isOpen = writable(open);
Expand All @@ -34,13 +29,7 @@
$: finalClass = twMerge(defaultClass, $$props.class);
</script>

<div
class={finalClass}
style={$$props.style}
use:useActions={use}
use:forwardEvents
{...exclude($$props, ['use', 'class'])}
>
<div class={finalClass} style={$$props.style}>
<slot name="title" />
{#if open}
<slot name="content" />
Expand Down

0 comments on commit 62c3b00

Please sign in to comment.