generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
103ada6
commit a06f88c
Showing
5 changed files
with
143 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script lang="ts"> | ||
import { ButtonComponent, setIcon } from "obsidian"; | ||
import { onMount } from "svelte"; | ||
export let tooltip: string | undefined = undefined; | ||
export let icon: "trash" | "clipboard-copy" | "pencil" | undefined = | ||
undefined; | ||
export let text: string | undefined = undefined; | ||
export let variant: "regular" | "danger" | "primary" = "regular"; | ||
export let onClick: () => void; | ||
const variants: Record<typeof variant, string> = { | ||
regular: "modal-form-regular", | ||
danger: "modal-form-danger", | ||
primary: "modal-form-primary", | ||
}; | ||
let root: HTMLElement; | ||
onMount(() => { | ||
const btn = new ButtonComponent(root); | ||
console.log({ root, btn }); | ||
if (icon) btn.setIcon(icon); | ||
if (tooltip) btn.setTooltip(tooltip); | ||
if (text) btn.setButtonText(text); | ||
btn.onClick(onClick); | ||
btn.setClass(variants[variant]); | ||
}); | ||
</script> | ||
|
||
<span bind:this={root}></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
export let key: string; | ||
</script> | ||
|
||
<div> | ||
<span class="key">{key}:</span> | ||
<slot /> | ||
</div> | ||
|
||
<style> | ||
div { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: flex-start; | ||
gap: var(--mf-spacing); | ||
} | ||
.key { | ||
color: var(--text-faint); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters