Rename Detachable.detach to detached

This commit is contained in:
Henrik Giesel 2021-05-07 14:31:08 +02:00
parent 6a804f6775
commit 9e747a5744
3 changed files with 12 additions and 12 deletions

View file

@ -16,7 +16,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let id: string | undefined = undefined;
export let registration: ButtonRegistration | undefined = undefined;
let detach_: boolean;
let detached: boolean;
let position_: ButtonPosition;
let style: string;
@ -41,24 +41,24 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
if (registration) {
const { detach, position } = registration;
detach.subscribe((value: boolean) => (detach_ = value));
detach.subscribe((value: boolean) => (detached = value));
position.subscribe((value: ButtonPosition) => (position_ = value));
} else if (hasContext(buttonGroupKey)) {
const registerComponent = getContext<Register<ButtonRegistration>>(
buttonGroupKey
);
const { detach, position } = registerComponent();
detach.subscribe((value: boolean) => (detach_ = value));
detach.subscribe((value: boolean) => (detached = value));
position.subscribe((value: ButtonPosition) => (position_ = value));
} else {
detach_ = false;
detached = false;
position_ = ButtonPosition.Standalone;
}
</script>
<!-- div in WithTheming is necessary to preserve item position -->
<WithTheming {id} {style}>
<Detachable detach={detach_}>
<Detachable {detached}>
<slot />
</Detachable>
</WithTheming>

View file

@ -14,19 +14,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let id: string | undefined = undefined;
export let registration: ButtonGroupRegistration | undefined = undefined;
let detach_: boolean;
let detached: boolean;
if (registration) {
const { detach } = registration;
detach.subscribe((value: boolean) => (detach_ = value));
detach.subscribe((value: boolean) => (detached = value));
} else if (hasContext(buttonToolbarKey)) {
const registerComponent = getContext<Register<ButtonGroupRegistration>>(
buttonToolbarKey
);
const { detach } = registerComponent();
detach.subscribe((value: boolean) => (detach_ = value));
detach.subscribe((value: boolean) => (detached = value));
} else {
detach_ = false;
detached = false;
}
</script>
@ -38,7 +38,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<!-- div is necessary to preserve item position -->
<div {id}>
<Detachable detach={detach_}>
<Detachable {detached}>
<slot />
</Detachable>
</div>

View file

@ -3,9 +3,9 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
export let detach = false;
export let detached = false;
</script>
{#if !detach}
{#if !detached}
<slot />
{/if}