Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Changed to use Svelte actions & DOM event forward #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
</script>

<MaterialButton
id="one"
text="first button"
onClickFunction={() => {
on:click={() => {
console.log("you just clicked the first button");
}}
/>
<MaterialButton
id="two"
text="second button"
onClickFunction={() => {
on:click={() => {
console.log("you just clicked the second button");
}}
/>
Expand Down
13 changes: 5 additions & 8 deletions src/MaterialButton.svelte
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<script>
import { onMount } from "svelte";
import { MDCRipple } from "@material/ripple";

onMount(() => {
const buttonRipple = new MDCRipple(document.getElementById(id));
});

export let id;
function materialButton(element) {
const buttonRipple = new MDCRipple(element);
}
export let text;
export let onClickFunction;

</script>

<button class="mdc-button" {id} on:click={onClickFunction}>
<button class="mdc-button" use:materialButton on:click>
<span class="mdc-button__ripple" />
<span class="mdc-button__label">{text}</span>
</button>