addStaticFloatingLabel.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { Classes } from '#shared/form/plugins/utils.ts'
  3. import { clean, extendClasses } from '#shared/form/plugins/utils.ts'
  4. /**
  5. * We cannot use absolute positioning for the floating label, because we might need to display
  6. * several rows of information on the screen - so content can depend on the actual label size and not
  7. * overlap.
  8. */
  9. export const addStaticFloatingLabel = (classes: Classes = {}): Classes => {
  10. return extendClasses(classes, {
  11. outer: clean(`
  12. focus-within:bg-blue-highlight relative flex flex-col
  13. px-2
  14. `),
  15. wrapper: 'relative flex flex-1 flex-col justify-center self-start py-1',
  16. inner: 'relative flex pb-1 ltr:pr-2 rtl:pl-2',
  17. block: 'formkit-disabled:cursor-default flex min-h-[3.5rem] cursor-pointer',
  18. // text-base ensures there is no zoom when you click on the input on iOS
  19. input: clean(`
  20. formkit-label-hidden:pt-4
  21. w-full border-none
  22. bg-transparent
  23. pt-6
  24. text-base
  25. placeholder:text-transparent
  26. focus:outline-none
  27. ltr:pl-2
  28. rtl:pr-2
  29. `),
  30. label: clean(`
  31. pointer-events-none absolute top-0 h-14
  32. origin-left px-2 py-4
  33. transition-all duration-100 ease-in-out ltr:left-0
  34. rtl:right-0
  35. `),
  36. })
  37. }