|
| 1 | +<script setup> |
| 2 | +import CheckIcon from '../../../components/icons/CheckIcon.vue' |
| 3 | +import { RadioGroup, RadioGroupDescription, RadioGroupLabel, RadioGroupOption } from '@headlessui/vue' |
| 4 | +import { defineModel, defineProps } from 'vue' |
| 5 | +
|
| 6 | +defineProps({ |
| 7 | + disabled: Boolean, |
| 8 | + singleUserDisabled: Boolean, |
| 9 | + multiuserDisabled: Boolean |
| 10 | +}) |
| 11 | +
|
| 12 | +const model = defineModel() |
| 13 | +</script> |
| 14 | + |
| 15 | +<template> |
| 16 | + <!-- Single/multi-user --> |
| 17 | + <RadioGroup v-model="model"> |
| 18 | + <div class="box__grid mb-8"> |
| 19 | + <RadioGroupOption as="template" :value="false" :disabled="disabled || singleUserDisabled" v-slot="{ active, checked, disabled }"> |
| 20 | + <div :class="{ radioOption: true, active, checked, disabled }"> |
| 21 | + <div :class="{ checkmark: true, active, checked }"> |
| 22 | + <CheckIcon class="checkmark__icon" /> |
| 23 | + </div> |
| 24 | + <div class="optionDetails"> |
| 25 | + <RadioGroupLabel as="h4" class="optionDetails__name"> |
| 26 | + Single-user VPN |
| 27 | + </RadioGroupLabel> |
| 28 | + <RadioGroupDescription as="span" class="optionDetails__description"> |
| 29 | + <span>Ideal for individual use.</span> |
| 30 | + </RadioGroupDescription> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | + </RadioGroupOption> |
| 34 | + |
| 35 | + <RadioGroupOption as="template" :value="true" :disabled="disabled || multiuserDisabled" v-slot="{ active, checked, disabled }"> |
| 36 | + <div :class="{ radioOption: true, active, checked, disabled }"> |
| 37 | + <div :class="{ checkmark: true, active, checked }"> |
| 38 | + <CheckIcon class="checkmark__icon" /> |
| 39 | + </div> |
| 40 | + <div class="optionDetails"> |
| 41 | + <RadioGroupLabel as="h4" class="optionDetails__name"> |
| 42 | + Multi-user VPN |
| 43 | + </RadioGroupLabel> |
| 44 | + <RadioGroupDescription as="span" class="optionDetails__description"> |
| 45 | + <span>Multi-user VPN includes up to five users. You can pay for additional users.</span> |
| 46 | + </RadioGroupDescription> |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + </RadioGroupOption> |
| 50 | + </div> |
| 51 | + </RadioGroup> |
| 52 | +</template> |
| 53 | + |
| 54 | + |
| 55 | +<style scoped> |
| 56 | +.box__grid { |
| 57 | + @apply mt-6 w-full grid grid-cols-1 gap-4; |
| 58 | + @apply sm:grid-cols-2 lg:grid-cols-2; |
| 59 | +} |
| 60 | +
|
| 61 | +/* radio option */ |
| 62 | +.radioOption { |
| 63 | + @apply relative flex space-x-3 items-start p-5 border border-gray-300 rounded-md cursor-pointer; |
| 64 | + @apply hover:bg-gray-100 hover:bg-opacity-50; |
| 65 | + @apply focus:outline-none; |
| 66 | +} |
| 67 | +.radioOption.active { |
| 68 | + @apply border-green border-opacity-40; |
| 69 | +} |
| 70 | +.radioOption.checked { |
| 71 | + @apply bg-gray-100 border-green bg-opacity-75; |
| 72 | + @apply ring-4 ring-green ring-opacity-10; |
| 73 | +} |
| 74 | +.radioOption.disabled { |
| 75 | + @apply cursor-not-allowed opacity-50; |
| 76 | +} |
| 77 | +
|
| 78 | +/* radio option details */ |
| 79 | +.optionDetails { |
| 80 | + @apply flex flex-col flex-1 text-sm; |
| 81 | +} |
| 82 | +.optionDetails__city { |
| 83 | + @apply text-sm text-gray-500; |
| 84 | +} |
| 85 | +
|
| 86 | +/* checkmark */ |
| 87 | +.checkmark { |
| 88 | + @apply flex items-center justify-center text-white flex-shrink-0 rounded-full w-5 h-5 bg-gray-100 border border-gray-300; |
| 89 | +} |
| 90 | +.checkmark.active { |
| 91 | + @apply border-green border-opacity-40 bg-opacity-20; |
| 92 | +} |
| 93 | +.checkmark.checked { |
| 94 | + @apply border-green bg-green; |
| 95 | +} |
| 96 | +.checkmark .checkmark__icon { |
| 97 | + @apply opacity-0 w-3 h-3; |
| 98 | +} |
| 99 | +.checkmark.active .checkmark__icon { |
| 100 | + @apply opacity-40; |
| 101 | +} |
| 102 | +.checkmark.checked .checkmark__icon { |
| 103 | + @apply opacity-100; |
| 104 | +} |
| 105 | +</style> |
0 commit comments