Tag.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <span class="font-mono text-[0.625rem] font-semibold leading-6"
  3. :class="[ variantStyles[ variant ], colorStyles[ color ][ variant ] ]">
  4. <slot/>
  5. </span>
  6. </template>
  7. <script setup>
  8. const props = defineProps({
  9. variant: {
  10. default: 'medium'
  11. },
  12. color: {
  13. default: 'emerald'
  14. }
  15. });
  16. const variantStyles = ref({
  17. medium: 'rounded-lg px-1.5 ring-1 ring-inset'
  18. })
  19. const colorStyles = ref({
  20. emerald: {
  21. small: 'text-emerald-400',
  22. medium: 'ring-emerald-400/30 bg-emerald-400/10 text-emerald-500 text-emerald-400',
  23. },
  24. sky: {
  25. small: 'text-sky-500',
  26. medium: 'ring-sky-400/30 bg-sky-400/10 text-sky-400',
  27. },
  28. amber: {
  29. small: 'text-amber-500',
  30. medium: 'ring-amber-400/30 bg-amber-400/10 text-amber-400',
  31. },
  32. rose: {
  33. small: 'text-red-500 text-rose-500',
  34. medium: 'ring-rose-500/20 bg-rose-400/10 text-rose-400',
  35. },
  36. zinc: {
  37. small: 'text-zinc-400 text-zinc-500',
  38. medium: 'ring-zinc-500/20 bg-zinc-400/10 text-zinc-400',
  39. },
  40. })
  41. const valueColorMap = ref({
  42. get: 'emerald',
  43. post: 'sky',
  44. put: 'amber',
  45. delete: 'rose',
  46. })
  47. </script>