Spaces:
Runtime error
Runtime error
File size: 1,188 Bytes
ca5bd83 72db8a4 ca5bd83 72db8a4 ca5bd83 |
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 |
<script lang="ts">
export let options: Record<string, string>;
const keys: string[] = Object.keys(options);
export let selection: string = keys[1];
</script>
<div class="options">
{#each keys as key}
<label data-selected={key === selection}>
{options[key]}
<input type="radio" bind:group={selection} value={key} />
</label>
{/each}
</div>
<style>
.options {
display: flex;
flex-direction: row;
justify-content: center;
width: 100%;
margin: auto;
}
label {
display: block;
margin-bottom: 1rem;
padding: 0.5rem 0.5rem;
border: 2px solid hsl(0 0% 97%);
border-right: none;
text-align: center;
transition: background-color 0.25s;
cursor: pointer;
}
label:nth-of-type(1) {
border-top-left-radius: 0.375rem;
border-bottom-left-radius: 0.375rem;
border-right-width: 0;
}
label:last-of-type {
border-top-right-radius: 0.375rem;
border-bottom-right-radius: 0.375rem;
border-right: 2px solid hsl(0 0% 97%);
}
label[data-selected='true'] {
background-color: hsl(0 0% 100%);
color: hsl(0 0% 20%);
font-weight: 700;
}
label:focus {
outline: red;
}
input {
position: fixed;
opacity: 0;
pointer-events: none;
}
</style>
|