2021-06-12 10:25:11 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2021-11-24 22:17:41 +01:00
|
|
|
import { pageTheme } from "../sveltelib/theme";
|
2021-06-21 21:16:40 +02:00
|
|
|
|
2021-06-21 18:15:41 +02:00
|
|
|
export let id: string | undefined;
|
2021-06-12 10:25:11 +02:00
|
|
|
export let value: boolean;
|
|
|
|
export let disabled = false;
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="form-check form-switch">
|
2021-06-21 18:15:41 +02:00
|
|
|
<input
|
|
|
|
{id}
|
|
|
|
type="checkbox"
|
2021-06-21 21:16:40 +02:00
|
|
|
class="form-check-input"
|
2021-11-24 22:17:41 +01:00
|
|
|
class:nightMode={$pageTheme.isDark}
|
2021-06-21 18:15:41 +02:00
|
|
|
bind:checked={value}
|
|
|
|
{disabled}
|
|
|
|
/>
|
2021-06-12 10:25:11 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2021-06-17 14:11:32 +02:00
|
|
|
.form-switch {
|
2021-06-21 21:16:40 +02:00
|
|
|
/* bootstrap adds a default 2.5em left pad, which causes */
|
|
|
|
/* text to wrap prematurely */
|
2021-06-17 14:11:32 +02:00
|
|
|
padding-left: 0.5em;
|
|
|
|
}
|
2021-06-21 21:16:40 +02:00
|
|
|
|
2021-06-12 10:25:11 +02:00
|
|
|
.form-check-input {
|
|
|
|
-webkit-appearance: none;
|
|
|
|
height: 1.6em;
|
|
|
|
/* otherwise the switch circle shows slightly off-centered */
|
|
|
|
margin-top: 0;
|
|
|
|
|
|
|
|
.form-switch & {
|
|
|
|
width: 3em;
|
|
|
|
margin-left: 1.5em;
|
|
|
|
}
|
|
|
|
}
|
2021-06-21 21:16:40 +02:00
|
|
|
|
2021-06-21 22:37:37 +02:00
|
|
|
.nightMode:not(:checked) {
|
2021-06-21 21:16:40 +02:00
|
|
|
background-color: var(--frame-bg);
|
|
|
|
border-color: var(--border);
|
|
|
|
}
|
2021-06-12 10:25:11 +02:00
|
|
|
</style>
|