FormGroup.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, useSlots } from 'vue'
  4. const props = defineProps<{ help?: string; showDirtyMark?: boolean }>()
  5. const slots = useSlots()
  6. const hasHelp = computed(() => slots.help || props.help)
  7. </script>
  8. <template>
  9. <div
  10. v-bind="$attrs"
  11. class="form-group overflow-hidden rounded-xl bg-gray-500"
  12. :class="{ 'mb-4': !hasHelp, 'form-group-mark-dirty': showDirtyMark }"
  13. >
  14. <slot />
  15. </div>
  16. <div v-if="hasHelp" class="mb-4 pt-1 text-xs text-gray-100 ltr:pl-3 rtl:pr-3">
  17. <slot name="help">
  18. {{ help }}
  19. </slot>
  20. </div>
  21. </template>
  22. <style lang="scss">
  23. .form-group {
  24. &.form-group-mark-dirty .formkit-outer[data-dirty]::before {
  25. content: '';
  26. position: absolute;
  27. top: 0;
  28. left: 0;
  29. bottom: 0;
  30. width: 0.25rem;
  31. background: repeating-linear-gradient(
  32. 45deg,
  33. rgba(255, 255, 255, 0.1),
  34. rgba(255, 255, 255, 0.1) 5px,
  35. transparent 5px,
  36. transparent 9px
  37. )
  38. repeat center;
  39. background-size: 11px 11px;
  40. }
  41. .formkit-outer:not(:last-child) {
  42. > :last-child {
  43. @apply border-b border-white/10;
  44. }
  45. }
  46. }
  47. </style>