addAbsoluteFloatingLabel.ts 1.1 KB

123456789101112131415161718192021222324
  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(`absolute-floating-input relative flex flex-col px-2`),
  11. wrapper: 'relative flex-1',
  12. inner: 'flex ltr:pr-2 rtl:pl-2',
  13. block: 'flex',
  14. // text-base ensures there is no zoom when you click on the input on iOS
  15. input: clean(
  16. `formkit-populated:pt-8 formkit-label-hidden:pt-2 h-14 w-full border-none bg-transparent text-base placeholder:text-transparent focus-within:pt-8 focus:outline-none`,
  17. ),
  18. label: clean(
  19. `pointer-events-none absolute top-0 h-14 origin-left px-2 py-4 text-base transition-all duration-100 ease-in-out ltr:left-0 rtl:right-0`,
  20. ),
  21. })
  22. }