addAbsoluteFloatingLabel.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. * Creates classes for a floating input label. Here we don't have a problem, where
  6. * we might need to display several rows of information on the screen, so we can use "absolute".
  7. */
  8. export const addAbsoluteFloatingLabel = (classes: Classes = {}) => {
  9. return extendClasses(classes, {
  10. outer: clean(`
  11. absolute-floating-input
  12. relative flex flex-col px-2
  13. `),
  14. wrapper: 'relative flex-1',
  15. inner: 'flex ltr:pr-2 rtl:pl-2',
  16. block: 'flex',
  17. // text-base ensures there is no zoom when you click on the input on iOS
  18. input: clean(`
  19. formkit-populated:pt-8
  20. formkit-label-hidden:pt-2
  21. h-14
  22. w-full
  23. border-none
  24. bg-transparent
  25. text-base
  26. placeholder:text-transparent
  27. focus-within:pt-8
  28. focus:outline-none
  29. `),
  30. label: clean(`
  31. pointer-events-none absolute top-0 h-14
  32. origin-left px-2 py-4
  33. text-base
  34. transition-all duration-100 ease-in-out ltr:left-0
  35. rtl:right-0
  36. `),
  37. })
  38. }