Get rid of types.d.ts in favor of DynamicSvelteComponent
This commit is contained in:
parent
86c57d5b75
commit
f88b9d64d3
@ -1,5 +1,5 @@
|
||||
<script lang="typescript">
|
||||
import type { Buttons } from "./types";
|
||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||
import ButtonGroup from "./ButtonGroup.svelte";
|
||||
|
||||
export let id = "";
|
||||
@ -10,7 +10,7 @@
|
||||
return `dropdown-menu bg-transparent border-0 ${className}`;
|
||||
}
|
||||
|
||||
export let buttons: Buttons;
|
||||
export let buttons: DynamicSvelteComponent[];
|
||||
</script>
|
||||
|
||||
<ButtonGroup {id} className={extendClassName(className)} {props} {buttons} />
|
||||
|
4
ts/editor-toolbar/ButtonGroup.d.ts
vendored
4
ts/editor-toolbar/ButtonGroup.d.ts
vendored
@ -1,7 +1,7 @@
|
||||
import type { Buttons } from "./types";
|
||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||
|
||||
export interface ButtonGroupProps {
|
||||
id: string;
|
||||
className?: string;
|
||||
buttons: Buttons;
|
||||
buttons: DynamicSvelteComponent[];
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
<script lang="typescript">
|
||||
import type { Buttons } from "./types";
|
||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||
|
||||
export let id = "";
|
||||
export let id;
|
||||
export let className = "";
|
||||
export let props: Record<string, string> = {};
|
||||
|
||||
export let buttons: Buttons;
|
||||
export let buttons: DynamicSvelteComponent[];
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@ -53,11 +53,7 @@
|
||||
<ul {id} class={className} {...props}>
|
||||
{#each buttons as button}
|
||||
<li>
|
||||
{#if Array.isArray(button)}
|
||||
<svelte:self buttons={button} />
|
||||
{:else}
|
||||
<svelte:component this={button.component} {...button} />
|
||||
{/if}
|
||||
<svelte:component this={button.component} {...button} />
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
@ -13,16 +13,15 @@
|
||||
</script>
|
||||
|
||||
<script lang="typescript">
|
||||
import type { SvelteComponent } from "svelte";
|
||||
import type { Readable } from "svelte/store";
|
||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||
import { setContext } from "svelte";
|
||||
import { disabledKey, nightModeKey } from "./contextKeys";
|
||||
|
||||
import ButtonGroup from "./ButtonGroup.svelte";
|
||||
import type { Buttons } from "./types";
|
||||
|
||||
export let buttons: Readable<Buttons>;
|
||||
export let menus: Readable<SvelteComponent[]>;
|
||||
export let buttons: Readable<DynamicSvelteComponent[]>;
|
||||
export let menus: Readable<DynamicSvelteComponent[]>;
|
||||
|
||||
$: _buttons = $buttons;
|
||||
$: _menus = $menus;
|
||||
|
4
ts/editor-toolbar/WithDropdownMenu.d.ts
vendored
4
ts/editor-toolbar/WithDropdownMenu.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import type { ButtonDefinition } from "./types";
|
||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||
|
||||
export interface WithDropdownMenuProps {
|
||||
button: ButtonDefinition;
|
||||
button: DynamicSvelteComponent;
|
||||
menuId: string;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<script lang="typescript">
|
||||
import type { ButtonDefinition } from "./types";
|
||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||
|
||||
export let button: ButtonDefinition;
|
||||
export let button: DynamicSvelteComponent;
|
||||
export let menuId: string;
|
||||
|
||||
function extend({ className, props, ...rest }: ButtonDefinition): ButtonDefinition {
|
||||
function extend({ className, props, ...rest }: DynamicSvelteComponent): DynamicSvelteComponent {
|
||||
return {
|
||||
className: `${className} dropdown-toggle`,
|
||||
props: {
|
||||
|
8
ts/editor-toolbar/types.d.ts
vendored
8
ts/editor-toolbar/types.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||
|
||||
export interface ButtonDefinition extends DynamicSvelteComponent {
|
||||
id?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export type Buttons = ButtonDefinition | Buttons[];
|
Loading…
Reference in New Issue
Block a user