mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-22 10:46:19 +01:00
web/Toggle: accommodate for rtl layouts
This commit is contained in:
parent
6e81c55fc1
commit
94e5aad6c0
1 changed files with 9 additions and 3 deletions
|
@ -1,8 +1,8 @@
|
|||
<script lang="ts">
|
||||
export let enabled;
|
||||
export let enabled: boolean;
|
||||
</script>
|
||||
|
||||
<div class="toggle" class:enabled={enabled}>
|
||||
<div class="toggle" class:enabled>
|
||||
<div class="toggle-switcher"></div>
|
||||
</div>
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
|||
.toggle {
|
||||
--base-size: 22px;
|
||||
--ratio-factor: 0.9;
|
||||
--enabled-pos: calc(100% * var(--ratio-factor));
|
||||
|
||||
display: flex;
|
||||
justify-content: start;
|
||||
|
@ -23,6 +24,10 @@
|
|||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.toggle:dir(rtl) {
|
||||
--enabled-pos: calc(-100% * var(--ratio-factor));
|
||||
}
|
||||
|
||||
.toggle-switcher {
|
||||
height: var(--base-size);
|
||||
width: var(--base-size);
|
||||
|
@ -37,6 +42,7 @@
|
|||
}
|
||||
|
||||
.toggle.enabled .toggle-switcher {
|
||||
transform: translateX(calc(100% * var(--ratio-factor)));
|
||||
transform: translateX(var(--enabled-pos));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in a new issue