form--managed-file.css

Styles for the managed file widget.

This includes the styles for the file widgets and the image widgets.

File

core/themes/claro/css/components/form--managed-file.css

View source
  1. /*
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/3084859
  5. * @preserve
  6. */
  7. /**
  8. * @file
  9. * Styles for the managed file widget.
  10. *
  11. * This includes the styles for the file widgets and the image widgets.
  12. */
  13. :root {
  14. --file-widget-form-item-min-width: 16rem;
  15. --file-widget-form-item-max-width: 32rem;
  16. }
  17. /**
  18. * The root element of the file/image widget.
  19. */
  20. .form-managed-file {
  21. &.no-upload {
  22. display: inline-flex;
  23. flex-direction: column;
  24. max-width: 100%;
  25. }
  26. &.has-value.is-multiple {
  27. display: block;
  28. }
  29. /**
  30. * Modify component defaults for file/image widgets.
  31. */
  32. /**
  33. * File component style overrides for managed file widgets.
  34. */
  35. & .file {
  36. word-break: break-all;
  37. }
  38. & .file__size {
  39. word-break: normal;
  40. }
  41. }
  42. /**
  43. * The 'meta' element of the file/image widget.
  44. *
  45. * This element is available only if the file widget has a value AND when there
  46. * are other input options than the ones rendered in the 'main' element.
  47. * These inputs are:
  48. * - File description and/or the file display checkbox of file widgets
  49. * - Image alt and/or title text as well as the preview image of the image
  50. * widgets.
  51. *
  52. * The trick here is that we will display the alt/title inputs next to the image
  53. * preview if there is enough space left. Enough space means the value of the
  54. * '--file-widget-form-item-min-width' variable.
  55. */
  56. .form-managed-file__meta {
  57. display: flex;
  58. flex-wrap: wrap;
  59. align-items: flex-start;
  60. margin-block-start: var(--space-m); /* Bottom margin will be added by the child elements: because of we use flex display here, our margins won't collapse. */
  61. & .form-element {
  62. width: 100%;
  63. }
  64. /**
  65. * Limiting the width of form items inside the meta element.
  66. */
  67. & .form-item {
  68. max-width: var(--file-widget-form-item-max-width);
  69. margin-block: 0 var(--space-m); /* Top margin is added by the parent element */
  70. /**
  71. * Reduce the bottom margin of the last 'meta' form-item for field multiple
  72. * tables.
  73. */
  74. &:last-child {
  75. margin-block-end: var(--space-xs);
  76. }
  77. }
  78. .draggable .form-managed-file.has-value
  79. }
  80. /**
  81. * The 'image preview' element.
  82. *
  83. * This is used and display only by the image widget.
  84. */
  85. .form-managed-file__image-preview {
  86. flex: 0 0 auto;
  87. max-width: 100%;
  88. margin-block-end: var(--space-m);
  89. .form-managed-file.has-meta
  90. /**
  91. * If this is rendered inside a file multiple table and there are no alt or
  92. * title, we have to reduce the amount of the bottom margin.
  93. */
  94. td .form-managed-file.no-meta
  95. }
  96. /**
  97. * The children of the 'meta items' element are the inputs that were described
  98. * at the 'meta' element '.form-managed-file__meta', except of the image
  99. * preview.
  100. *
  101. * The flex-basis is set to the minimal width where we can display these inputs
  102. * next tho the preview image.
  103. *
  104. * We limit the max width directly on the '.form-item' elements.
  105. */
  106. .form-managed-file__meta-items {
  107. flex: 1 1 var(--file-widget-form-item-min-width);
  108. max-width: 100%;
  109. }
  110. /**
  111. * The main element of the file/image widget.
  112. *
  113. * This contains the upload input and the upload of the empty file/image
  114. * widgets, or the file name (with icon and size) and the remove button of
  115. * filled widgets.
  116. *
  117. * The inline-flex display shrinks the width to the minimal needed amount. This
  118. * helps to keep the remove as close to the other elements as possible.
  119. */
  120. .form-managed-file__main {
  121. display: inline-flex;
  122. align-items: center;
  123. max-width: 100%;
  124. & .file {
  125. flex: 1 1 auto;
  126. margin-block: var(--space-xs);
  127. margin-inline: 0 var(--space-m);
  128. }
  129. /* The file upload input. */
  130. & .form-element--api-file {
  131. flex: 1 1 auto;
  132. }
  133. /**
  134. * Remove the default button margins and prevent shrinking or growing buttons.
  135. * This applies both on the 'no-js' upload button and the remove button. The
  136. * weight of this ruleset has been increase for this to take effect on RTL.
  137. */
  138. & .button.button {
  139. flex: 0 0 auto;
  140. margin: 0;
  141. }
  142. /* Add some bottom margin for single widgets if no meta is present. */
  143. .form-managed-file.is-single.has-value &:last-child {
  144. margin-block-end: var(--space-m);
  145. }
  146. .draggable .form-managed-file.has-value
  147. }
  148. /**
  149. * Add side margins if a table precedes the managed file form element.
  150. */
  151. .file-widget-multiple.has-table .form-type--managed-file {
  152. margin-inline: var(--space-m);
  153. }

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.