You are here

form--managed-file.css in Drupal 10

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.no-upload {
  21. display: inline-flex;
  22. flex-direction: column;
  23. max-width: 100%;
  24. }
  25. .form-managed-file.has-value.is-multiple {
  26. display: block;
  27. }
  28. /**
  29. * The main element of the file/image widget.
  30. *
  31. * This contains the upload input and the upload of the empty file/image
  32. * widgets, or the file name (with icon and size) and the remove button of
  33. * filled widgets.
  34. *
  35. * The inline-flex display shrinks the width to the minimal needed amount. This
  36. * helps to keep the remove as close to the other elements as possible.
  37. */
  38. .form-managed-file__main {
  39. display: inline-flex;
  40. align-items: center;
  41. max-width: 100%;
  42. }
  43. /**
  44. * Inside (draggable) tables, this should be flex-displayed. This keeps even
  45. * long file names in the same visual line where the drag handle is.
  46. */
  47. .draggable .form-managed-file.has-value .form-managed-file__main {
  48. display: flex;
  49. }
  50. /* Add some bottom margin for single widgets if no meta is present. */
  51. .form-managed-file.is-single.has-value .form-managed-file__main:last-child {
  52. margin-bottom: var(--space-m);
  53. }
  54. /**
  55. * The 'meta' element of the file/image widget.
  56. *
  57. * This element is available only if the file widget has a value AND when there
  58. * are other input options than the ones rendered in the 'main' element.
  59. * These inputs are:
  60. * - File description and/or the file display checkbox of file widgets
  61. * - Image alt and/or title text as well as the preview image of the image
  62. * widgets.
  63. *
  64. * The trick here is that we will display the alt/title inputs next to the image
  65. * preview if there is enough space left. Enough space means the value of the
  66. * '--file-widget-form-item-min-width' variable.
  67. */
  68. .form-managed-file__meta {
  69. display: flex;
  70. flex-wrap: wrap;
  71. align-items: flex-start;
  72. margin-top: var(--space-m); /* Bottom margin will be added by the child elements: because of we use flex display here, our margins won't collapse. */
  73. }
  74. /**
  75. * In tables, this should be inline-flex. This is needed to make this element be
  76. * pushed to a new line, to the bottom of the drag handle.
  77. */
  78. .draggable .form-managed-file.has-value .form-managed-file__meta {
  79. display: inline-flex;
  80. }
  81. /**
  82. * Internet Explorer 11 does not shrinks our meta elements if one of its parent
  83. * element is a table. Without this fix, the file widgets table cell would have
  84. * the same width that is needed for displaying the file name in a single line.
  85. *
  86. * @see https://github.com/philipwalton/flexbugs/issues/179
  87. */
  88. @media all and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  89. *::-ms-backdrop,
  90. td .form-managed-file__meta {
  91. flex-basis: 100%;
  92. }
  93. }
  94. /**
  95. * The 'image preview' element.
  96. *
  97. * This is used and display only by the image widget.
  98. */
  99. .form-managed-file__image-preview {
  100. flex: 0 0 auto;
  101. max-width: 100%;
  102. margin-bottom: var(--space-m);
  103. }
  104. /* Add some 'end' margin if there are other meta inputs. */
  105. .form-managed-file.has-meta .form-managed-file__image-preview {
  106. margin-right: var(--space-m); /* LTR */
  107. }
  108. [dir="rtl"] .form-managed-file.has-meta .form-managed-file__image-preview {
  109. margin-right: 0;
  110. margin-left: var(--space-m);
  111. }
  112. /**
  113. * If this is rendered inside a file multiple table and there are no alt or
  114. * title, we have to reduce the amount of the bottom margin.
  115. */
  116. td .form-managed-file.no-meta .form-managed-file__image-preview {
  117. margin-bottom: var(--space-xs);
  118. }
  119. /**
  120. * The children of the 'meta items' element are the inputs that were described
  121. * at the 'meta' element '.form-managed-file__meta', except of the image
  122. * preview.
  123. *
  124. * The flex-basis is set to the minimal width where we can display these inputs
  125. * next tho the preview image.
  126. *
  127. * We limit the max width directly on the '.form-item' elements.
  128. */
  129. .form-managed-file__meta-items {
  130. flex: 1 1 var(--file-widget-form-item-min-width);
  131. max-width: 100%;
  132. }
  133. /**
  134. * Internet Explorer 11 does not increase the width of those flex items that are
  135. * allowed to be wrapped. We just simply change the basis to the max-width.
  136. */
  137. @media all and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  138. *::-ms-backdrop,
  139. .form-managed-file__meta-items {
  140. flex-basis: var(--file-widget-form-item-max-width);
  141. }
  142. }
  143. /**
  144. * Meta items wrapper.
  145. * This markup element is needed only for working around the same IE 11 bug that
  146. * is described above, at the 'meta' element.
  147. *
  148. * @see https://github.com/philipwalton/flexbugs/issues/179
  149. */
  150. @media all and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  151. *::-ms-backdrop,
  152. td .form-managed-file__meta-wrapper {
  153. display: flex;
  154. }
  155. }
  156. /**
  157. * Modify component defaults for file/image widgets.
  158. */
  159. /**
  160. * File component style overrides for managed file widgets.
  161. */
  162. .form-managed-file .file {
  163. word-break: break-all;
  164. -webkit-hyphens: auto;
  165. hyphens: auto;
  166. }
  167. .form-managed-file .file__size {
  168. word-break: normal;
  169. }
  170. .form-managed-file__main .file {
  171. flex: 1 1 auto;
  172. margin: var(--space-xs) var(--space-m) var(--space-xs) 0; /* LTR */
  173. }
  174. [dir="rtl"] .form-managed-file__main .file {
  175. margin-right: 0;
  176. margin-left: var(--space-m);
  177. }
  178. /**
  179. * Fix and override the table-related bug of Internet Explorer 11 (described at
  180. * the 'meta' element).
  181. *
  182. * @see https://github.com/philipwalton/flexbugs/issues/179
  183. */
  184. @media all and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  185. *::-ms-backdrop,
  186. td .form-managed-file__main .file {
  187. flex: 0 1 100%;
  188. }
  189. }
  190. /**
  191. * The file upload input.
  192. */
  193. .form-managed-file__main .form-element--api-file {
  194. flex: 1 1 auto;
  195. min-width: 1px; /* This makes the element shrink on IE11 */
  196. }
  197. /**
  198. * Remove the default button margins and prevent shrinking or growing buttons.
  199. * This applies both on the 'no-js' upload button and the remove button. The
  200. * weight of this ruleset has been increase for this to take effect on RTL.
  201. */
  202. .form-managed-file__main .button.button {
  203. flex: 0 0 auto;
  204. margin: 0;
  205. }
  206. /**
  207. * Limiting the width of form items inside the meta element.
  208. */
  209. .form-managed-file__meta .form-item {
  210. max-width: var(--file-widget-form-item-max-width);
  211. margin-top: 0; /* Top margin is added by the parent element */
  212. margin-bottom: var(--space-m);
  213. }
  214. /**
  215. * Reduce the bottom margin of the last 'meta' form-item for field multiple
  216. * tables.
  217. */
  218. .form-managed-file__meta .form-item:last-child {
  219. margin-bottom: var(--space-xs);
  220. }
  221. .form-managed-file__meta .form-element {
  222. width: 100%;
  223. }
  224. /**
  225. * Add side margins if a table precedes the managed file form element.
  226. */
  227. .file-widget-multiple.has-table .form-type--managed-file {
  228. margin-right: var(--space-m);
  229. margin-left: var(--space-m);
  230. }