Spaces:
Sleeping
Sleeping
File size: 2,635 Bytes
43a06dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
<script lang="ts">
export let big: boolean = false;
export let description: string = "";
</script>
<div class="switcher-parent">
<div class="switcher" class:big={big} role="listbox">
<slot></slot>
</div>
{#if description}
<div class="settings-content-description subtext">{description}</div>
{/if}
</div>
<style>
.switcher-parent {
display: flex;
flex-direction: column;
gap: 8px;
}
.switcher {
display: flex;
width: auto;
flex-direction: row;
flex-wrap: nowrap;
scrollbar-width: none;
overflow-x: scroll;
border-radius: var(--border-radius);
}
.switcher :global(.button) {
white-space: nowrap;
}
.switcher:not(.big) :global(.button:first-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.switcher:not(.big) :global(.button:last-child) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.switcher:not(.big):dir(rtl) :global(.button:first-child) {
border-top-right-radius: inherit;
border-bottom-right-radius: inherit;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.switcher:not(.big):dir(rtl) :global(.button:last-child) {
border-top-left-radius: inherit;
border-bottom-left-radius: inherit;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.switcher.big {
background: var(--button);
box-shadow: var(--button-box-shadow);
padding: var(--switcher-padding);
gap: calc(var(--switcher-padding) - 1.5px);
}
.switcher :global(.button.active) {
pointer-events: none;
}
.switcher :global(.button.active:hover) {
background: var(--secondary);
}
.switcher.big :global(.button) {
width: 100%;
/* [base button height] - ([switcher padding] * [padding factor to accommodate for]) */
height: calc(40px - var(--switcher-padding) * 1.5);
border-radius: calc(var(--border-radius) - var(--switcher-padding));;
}
.switcher.big :global(.button:not(:focus-visible)) {
box-shadow: none;
}
.switcher.big :global(.button:not(.active, :hover, :active)) {
background-color: transparent;
}
.switcher:not(.big) :global(.button:not(:first-child, :last-child)) {
border-radius: 0;
}
/* hack to get rid of double border in a list of switches */
.switcher:not(.big) :global(:not(.button:first-child)) {
margin-left: -1.5px;
}
</style>
|