Skip to content

Commit

Permalink
Merge pull request writer#574 from madeindjs/WF-81
Browse files Browse the repository at this point in the history
fix(ui): make `CoreSwitchInput` reactive to state change - WF-81
  • Loading branch information
ramedina86 authored Oct 16, 2024
2 parents 0f610d4 + 4139882 commit 25b6c2d
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/ui/src/components/core/input/CoreSwitchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
>
<div
class="switch"
:class="{ on: toggleValue }"
:class="{ on: !!formValue }"
tabindex="0"
role="switch"
:aria-checked="toggleValue"
:aria-checked="!!formValue"
@click="handleToggle"
@keydown.enter.space.prevent="handleToggle"
>
Expand All @@ -29,7 +29,6 @@ import {
separatorColor,
cssClasses,
} from "@/renderer/sharedStyleFields";
import { onMounted } from "vue";
import BaseInputWrapper from "../base/BaseInputWrapper.vue";
import { ComponentPublicInstance } from "vue";
Expand Down Expand Up @@ -82,25 +81,16 @@ const { formValue, handleInput } = useFormValueBroker(
instancePath,
rootInstance,
);
const toggleValue = ref(false);
function handleToggle() {
toggleValue.value = !toggleValue.value;
handleInput(toggleValue.value, "wf-toggle");
handleInput(!formValue.value, "wf-toggle");
}
onMounted(() => {
toggleValue.value = !!formValue.value;
});
</script>

<style scoped>
@import "@/renderer/sharedStyles.css";
@import "@/renderer/colorTransformations.css";
.CoreSwitchInput {
}
.switch {
background: var(--separatorColor);
width: 34px;
Expand Down

0 comments on commit 25b6c2d

Please sign in to comment.