2021-08-04 23:31:54 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
|
|
|
export let on: boolean = false
|
2023-02-28 18:36:00 +00:00
|
|
|
export let disabled: boolean = false
|
2021-08-04 23:31:54 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<label class="toggle">
|
2023-02-28 18:36:00 +00:00
|
|
|
<input class="chBox" type="checkbox" {disabled} bind:checked={on} on:change />
|
2022-04-29 05:27:17 +00:00
|
|
|
<span class="toggle-switch" />
|
2021-08-04 23:31:54 +00:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.toggle {
|
|
|
|
display: inline-block;
|
2022-04-02 04:06:48 +00:00
|
|
|
width: 2rem;
|
|
|
|
min-width: 2rem;
|
|
|
|
height: 1.5rem;
|
|
|
|
// line-height: 1.75rem;
|
2021-08-04 23:31:54 +00:00
|
|
|
vertical-align: middle;
|
2021-08-17 14:46:06 +00:00
|
|
|
font-size: inherit;
|
2021-08-04 23:31:54 +00:00
|
|
|
user-select: none;
|
|
|
|
.chBox {
|
|
|
|
position: absolute;
|
|
|
|
width: 1px;
|
|
|
|
height: 1px;
|
|
|
|
margin: -1px;
|
|
|
|
border: 0;
|
|
|
|
padding: 0;
|
|
|
|
clip: rect(0 0 0 0);
|
|
|
|
overflow: hidden;
|
2022-04-29 05:27:17 +00:00
|
|
|
|
2021-08-04 23:31:54 +00:00
|
|
|
&:checked + .toggle-switch {
|
2022-04-16 03:03:31 +00:00
|
|
|
background-color: var(--toggle-on-bg-color);
|
2022-04-29 05:27:17 +00:00
|
|
|
&:hover {
|
|
|
|
background-color: var(--toggle-on-bg-hover);
|
|
|
|
}
|
2022-04-02 04:06:48 +00:00
|
|
|
&:before {
|
2022-04-29 05:27:17 +00:00
|
|
|
left: 0.75rem;
|
2022-04-16 03:03:31 +00:00
|
|
|
background: var(--toggle-on-sw-color);
|
2022-04-02 04:06:48 +00:00
|
|
|
}
|
2021-08-04 23:31:54 +00:00
|
|
|
}
|
2022-04-29 05:27:17 +00:00
|
|
|
&:not(:disabled) + .toggle-switch {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2021-08-04 23:31:54 +00:00
|
|
|
&:disabled + .toggle-switch {
|
|
|
|
filter: grayscale(70%);
|
2022-04-29 05:27:17 +00:00
|
|
|
&:before {
|
|
|
|
background: #eee;
|
|
|
|
}
|
2021-08-04 23:31:54 +00:00
|
|
|
}
|
2021-12-08 09:24:24 +00:00
|
|
|
// &:focus-within + .toggle-switch { box-shadow: 0 0 0 2px var(--primary-button-outline); }
|
2021-08-04 23:31:54 +00:00
|
|
|
}
|
2021-12-08 09:24:24 +00:00
|
|
|
// &:active > .toggle-switch { box-shadow: 0 0 0 2px var(--primary-button-outline); }
|
2021-08-04 23:31:54 +00:00
|
|
|
.toggle-switch {
|
|
|
|
position: relative;
|
|
|
|
display: inline-block;
|
2022-04-02 04:06:48 +00:00
|
|
|
width: 2rem;
|
|
|
|
height: 1.5rem;
|
|
|
|
border-radius: 4.5rem;
|
2022-04-16 03:03:31 +00:00
|
|
|
background-color: var(--toggle-bg-color);
|
2022-04-29 05:27:17 +00:00
|
|
|
transition: left 0.2s, background-color 0.2s;
|
2021-08-04 23:31:54 +00:00
|
|
|
&:before {
|
|
|
|
content: '';
|
|
|
|
position: absolute;
|
2022-04-29 05:27:17 +00:00
|
|
|
top: 0.25rem;
|
|
|
|
left: 0.25rem;
|
2021-08-04 23:31:54 +00:00
|
|
|
display: inline-block;
|
2022-04-02 04:06:48 +00:00
|
|
|
width: 1rem;
|
|
|
|
height: 1rem;
|
2021-08-04 23:31:54 +00:00
|
|
|
border-radius: 50%;
|
2022-04-16 03:03:31 +00:00
|
|
|
background: var(--toggle-sw-color);
|
2021-08-04 23:31:54 +00:00
|
|
|
box-shadow: 1px 2px 7px rgba(119, 129, 142, 0.1);
|
2022-04-29 05:27:17 +00:00
|
|
|
transition: 0.15s;
|
|
|
|
}
|
|
|
|
&:hover {
|
|
|
|
background-color: var(--toggle-bg-hover);
|
2021-08-04 23:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|