Skip to content

Commit

Permalink
Prune events (#8)
Browse files Browse the repository at this point in the history
* feat: remove mouse, keydown events from Toggle

* chore: formatting

* chore: update docs
  • Loading branch information
metonym authored Dec 5, 2020
1 parent fc2755c commit 068e39b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,8 @@ The `Toggle` component dispatches a "toggle" event.
## Forwarded events

- on:click
- on:mouseover
- on:mouseenter
- on:mouseout
- on:focus
- on:blur
- on:keydown

## TypeScript

Expand Down
6 changes: 1 addition & 5 deletions src/Toggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,8 @@
{disabled}
on:click
on:click={() => (toggled = !toggled)}
on:mouseover
on:mouseenter
on:mouseout
on:focus
on:blur
on:keydown />
on:blur />
<slot {toggled}>
{#if on && off}<span>{toggled ? on : off}</span>{/if}
</slot>
Expand Down
11 changes: 10 additions & 1 deletion test.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
on="On"
off="Off"
on:toggle={(e) => {
console.log(e.detail);
console.log(e.detail); // boolean
}}
on:click={(e) => {
console.log(e); // MouseEvent
}}
on:focus={(e) => {
console.log(e); // FocusEvent
}}
on:blur={(e) => {
console.log(e); // FocusEvent
}} />

<Toggle let:toggled={isToggled}>
Expand Down
4 changes: 0 additions & 4 deletions types/Toggle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ export default class Toggle extends SvelteComponentTyped<
{
toggle: CustomEvent<boolean>;
click: WindowEventMap["click"];
mouseover: WindowEventMap["mouseover"];
mouseenter: WindowEventMap["mouseenter"];
mouseout: WindowEventMap["mouseout"];
focus: WindowEventMap["focus"];
blur: WindowEventMap["blur"];
keydown: WindowEventMap["keydown"];
},
{ default: { toggled: boolean } }
> {}

0 comments on commit 068e39b

Please sign in to comment.