|
| 1 | +<script lang="ts"> |
| 2 | +import type { RadioGroupRootProps, RadioGroupRootEmits } from 'reka-ui' |
| 3 | +import type { ColorType } from '../types' |
| 4 | +
|
| 5 | +export interface RadioCardsRootProps extends RadioGroupRootProps { |
| 6 | + /** |
| 7 | + * The visual variant of the radio group. |
| 8 | + * @default "surface" |
| 9 | + */ |
| 10 | + variant?: 'surface' | 'classic' |
| 11 | + /** |
| 12 | + * Control the size of the radio group. |
| 13 | + * @default "2" |
| 14 | + */ |
| 15 | + size?: '1' | '2' | '3' |
| 16 | + /** Overrides the accent color inherited from the ThemeProvider. */ |
| 17 | + color?: ColorType |
| 18 | + /** Uses a higher contrast color for the component. */ |
| 19 | + highContrast?: boolean |
| 20 | +} |
| 21 | +</script> |
| 22 | + |
| 23 | +<script setup lang="ts"> |
| 24 | +import { RadioGroupRoot } from 'reka-ui' |
| 25 | +import { useForwardPropsEmitsWithout, buildPropsClass } from '../util' |
| 26 | +
|
| 27 | +const emits = defineEmits<RadioGroupRootEmits>() |
| 28 | +
|
| 29 | +const props = withDefaults(defineProps<RadioCardsRootProps>(), { |
| 30 | + size: '2', |
| 31 | + variant: 'surface', |
| 32 | +}) |
| 33 | +const forwarded = useForwardPropsEmitsWithout(props, emits, ['color', 'size', 'variant', 'highContrast']) |
| 34 | +const resetClass = buildPropsClass(props, ['size', 'variant', 'highContrast']) |
| 35 | +</script> |
| 36 | + |
| 37 | +<template> |
| 38 | + <RadioGroupRoot |
| 39 | + class="ui-RadioCardsRoot" |
| 40 | + :class="resetClass" |
| 41 | + :data-accent-color="props.color" |
| 42 | + v-bind="forwarded" |
| 43 | + > |
| 44 | + <slot></slot> |
| 45 | + </RadioGroupRoot> |
| 46 | +</template> |
| 47 | + |
| 48 | +<style> |
| 49 | +.ui-RadioCardsRoot:where(.r-size-1) { |
| 50 | + --card-padding: var(--space-3); |
| 51 | + --card-border-radius: max(var(--radius-4), var(--radius-full)); |
| 52 | +} |
| 53 | +.ui-RadioCardsRoot:where(.r-size-2) { |
| 54 | + --card-padding: var(--space-4); |
| 55 | + --card-border-radius: max(var(--radius-4), var(--radius-full)); |
| 56 | +} |
| 57 | +.ui-RadioCardsRoot:where(.r-size-3) { |
| 58 | + --card-padding: var(--space-5); |
| 59 | + --card-border-radius: max(var(--radius-5), var(--radius-full)); |
| 60 | +} |
| 61 | +</style> |
0 commit comments