form--managed-file.pcss.css

Same filename in other branches
  1. 8.9.x core/themes/claro/css/components/form--managed-file.pcss.css
  2. 10 core/themes/claro/css/components/form--managed-file.pcss.css
  3. 11.x core/themes/claro/css/components/form--managed-file.pcss.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.pcss.css

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

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