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