2022-02-07 22:34:53 +08:00
|
|
|
<script lang="ts">
|
|
|
|
export let value: string;
|
|
|
|
export let setValue: (val: string) => string;
|
|
|
|
export let theme: string;
|
|
|
|
export let choices: Array<string>;
|
2022-02-01 21:45:55 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="input-radio flex flex-wrap gap-2" {theme}>
|
2022-02-01 23:46:50 +08:00
|
|
|
{#each choices as choice, i}
|
|
|
|
<button
|
|
|
|
class="radio-item py-2 px-3 font-semibold rounded cursor-pointer flex items-center gap-2"
|
|
|
|
class:selected={value === choice}
|
|
|
|
on:click={() => setValue(choice)}
|
|
|
|
>
|
|
|
|
<div class="radio-circle w-4 h-4 rounded-full box-border" />
|
|
|
|
{choice}
|
|
|
|
</button>
|
|
|
|
{/each}
|
2022-02-01 21:45:55 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="postcss">
|
2022-02-01 23:46:50 +08:00
|
|
|
.input-radio[theme="default"] {
|
|
|
|
.radio-item {
|
|
|
|
@apply bg-white dark:bg-gray-800 shadow transition hover:shadow-md;
|
|
|
|
}
|
|
|
|
.radio-circle {
|
|
|
|
@apply bg-gray-50 dark:bg-gray-400 border-4 border-gray-200 dark:border-gray-600;
|
|
|
|
}
|
|
|
|
.radio-item.selected {
|
2022-02-15 07:27:29 +08:00
|
|
|
@apply bg-amber-500 dark:bg-red-600 text-white shadow;
|
2022-02-01 23:46:50 +08:00
|
|
|
}
|
|
|
|
.radio-circle {
|
|
|
|
@apply w-4 h-4 bg-white transition rounded-full box-border;
|
|
|
|
}
|
|
|
|
.selected .radio-circle {
|
2022-02-15 07:27:29 +08:00
|
|
|
@apply border-amber-600 dark:border-red-700;
|
2022-02-01 23:46:50 +08:00
|
|
|
}
|
|
|
|
}
|
2022-02-01 21:45:55 +08:00
|
|
|
</style>
|