addFloatingTextareaLabel.ts 1.2 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. * Textarea can be scrolled, so if we use "aboslute" positioning for label,
  6. * it will overlap with textarea content. But we still can't use regular solution,
  7. * becase the label text should be on the same row with the textarea, so we have a trick,
  8. * where we use "h-2", so it overlaps with the content, until the textarea is populated.
  9. */
  10. export const addFloatingTextareaLabel = (classes: Classes = {}) => {
  11. return extendClasses(classes, {
  12. outer: clean(`floating-textarea relative px-2`),
  13. wrapper: 'relative',
  14. // text-base ensures there is no zoom when you click on the input on iOS
  15. input: clean(
  16. `w-full border-none bg-transparent text-base placeholder:text-transparent focus:outline-none`,
  17. ),
  18. label: clean(
  19. `formkit-populated:translate-y-0 formkit-populated:text-xs formkit-populated:opacity-75 flex h-2 origin-left translate-y-4 cursor-text items-end px-2 pt-5 text-base transition-all duration-100 ease-in-out`,
  20. ),
  21. })
  22. }