tabledrag.pcss.css

Same filename in this branch
  1. main core/misc/dialog/off-canvas/css/tabledrag.pcss.css
  2. main core/themes/olivero/css/components/tabledrag.pcss.css
  3. main core/themes/claro/css/components/tabledrag.pcss.css
  4. main core/themes/admin/css/components/tabledrag.pcss.css
Same filename and directory in other branches
  1. 10 core/misc/dialog/off-canvas/css/tabledrag.pcss.css
  2. 10 core/themes/olivero/css/components/tabledrag.pcss.css
  3. 10 core/themes/claro/css/components/tabledrag.pcss.css
  4. 11.x core/misc/dialog/off-canvas/css/tabledrag.pcss.css
  5. 11.x core/themes/olivero/css/components/tabledrag.pcss.css
  6. 11.x core/themes/claro/css/components/tabledrag.pcss.css
  7. 9 core/themes/olivero/css/components/tabledrag.pcss.css
  8. 9 core/themes/claro/css/components/tabledrag.pcss.css
  9. 8.9.x core/themes/claro/css/components/tabledrag.pcss.css
  10. 11.x core/themes/admin/css/components/tabledrag.pcss.css
  11. 11.x core/themes/default_admin/css/components/tabledrag.pcss.css

Replacement styles for table drag.

Replaces core's tabledrag.module.css.

See also

tabledrag.js

File

core/themes/default_admin/css/components/tabledrag.pcss.css

View source
  1. /**
  2. * @file
  3. * Replacement styles for table drag.
  4. *
  5. * Replaces core's tabledrag.module.css.
  6. *
  7. * @see tabledrag.js
  8. */
  9. @import "../base/media-queries.pcss.css";
  10. /*
  11. * When mouse is pressed, scrollbar disappears. This prevents the horizontal
  12. * layout shift from occurring
  13. */
  14. html {
  15. scrollbar-gutter: stable;
  16. }
  17. body {
  18. &.drag {
  19. cursor: move;
  20. }
  21. &.drag-y {
  22. cursor: row-resize;
  23. }
  24. }
  25. .draggable-table {
  26. --table-row--dragging-bg-color: #fe7;
  27. --table-row--last-dragged-bg-color: #ffb;
  28. --tabledrag-handle-icon-size: 17px;
  29. /*
  30. * We remove all padding and hard-code the height of the elements to
  31. * ensure that the "tree" icons span full height. You can replicate this in
  32. * the UI by clicking and holding down the drag icon. The tree icons will
  33. * become visible underneath.
  34. */
  35. :is(th, td) {
  36. height: 60px;
  37. html[data-gin-layout-density="medium"]
  38. html[data-gin-layout-density="small"]
  39. .layer-wrapper {
  40. margin-block: var(--gin-spacing-density-s);
  41. }
  42. .draggable-table {
  43. margin-block: 0;
  44. }
  45. :is(th, td) {
  46. height: auto;
  47. }
  48. }
  49. /**
  50. * Reduce the spacing of draggable table cells.
  51. */
  52. & :is(th, td):first-child ~ :is(th, td) {
  53. padding-inline-start: 0;
  54. }
  55. }
  56. /* The block region's title row in table. */
  57. .region-title {
  58. font-weight: bold;
  59. }
  60. /* Empty region message row in table. */
  61. .region-message {
  62. color: var(--color-gray-600);
  63. &.region-populated {
  64. /* If the region is populated, we shouldn't display the empty message. */
  65. display: none;
  66. }
  67. }
  68. /**
  69. * Remove border-bottom from abbr element. Class is duplicated in the selector
  70. * to increase weight to be able to win normalize.css selectors.
  71. */
  72. .tabledrag-changed.tabledrag-changed {
  73. border-bottom: none;
  74. }
  75. .tabledrag-changed {
  76. /* Don't display the abbreviation of 'add-new' table rows. */
  77. .add-new
  78. .draggable
  79. .tabledrag-cell--only-drag
  80. }
  81. /**
  82. * Draggable row state colors.
  83. */
  84. .draggable {
  85. &.region-title,
  86. &.region-title:focus {
  87. background-color: var(--table-row--dragging-bg-color);
  88. }
  89. &.region-title-previous {
  90. background-color: var(--table-row--last-dragged-bg-color);
  91. }
  92. &.drag-previous {
  93. background-color: var(--gin-bg-layer2);
  94. box-shadow: inset 6px 0 0 0 var(--gin-color-warning);
  95. &:dir(rtl) {
  96. box-shadow: inset -6px 0 0 0 var(--gin-color-warning);
  97. }
  98. &::after {
  99. position: absolute;
  100. width: 6px;
  101. height: 100%;
  102. content: "";
  103. }
  104. @media (forced-colors: active) {
  105. position: relative;
  106. &::after {
  107. border-inline-start: 6px solid linktext;
  108. inset-inline-start: 0;
  109. }
  110. }
  111. }
  112. &.drag,
  113. &.drag:focus {
  114. background-color: var(--gin-bg-layer2);
  115. .gin--dark-mode
  116. }
  117. /* Auto width for weight selects and number inputs. */
  118. td .form-element--type-select[name$="][_weight]"], /* Multiple field */
  119. td .term-weight, /* Taxonomy term list */
  120. td .field-weight /* Field UI table */ {
  121. width: auto;
  122. }
  123. a.tabledrag-handle {
  124. float: none;
  125. vertical-align: middle;
  126. }
  127. }
  128. /**
  129. * Handle styles.
  130. */
  131. .tabledrag-handle {
  132. position: relative;
  133. z-index: 1;
  134. display: flex;
  135. overflow: visible;
  136. place-content: center;
  137. box-sizing: border-box;
  138. height: 44px;
  139. cursor: move;
  140. text-align: center;
  141. vertical-align: text-top;
  142. margin-inline: calc(-1 * var(--space-s)) var(--space-s);
  143. padding-inline: var(--space-s);
  144. &::after {
  145. display: inline-block;
  146. box-sizing: border-box;
  147. width: var(--tabledrag-handle-icon-size);
  148. height: var(--tabledrag-handle-icon-size);
  149. padding: var(--space-xs);
  150. content: "";
  151. transition: transform 0.1s ease-in-out 0s;
  152. background-color: var(--gin-color-text-light);
  153. mask-image: var(--admin-icon-drag);
  154. mask-repeat: no-repeat;
  155. mask-position: center center;
  156. mask-size: 16px 16px;
  157. @media (forced-colors: active) {
  158. background: linktext;
  159. mask-image: url(../../images/icons/000f33/tabledrag-handle.svg);
  160. mask-repeat: no-repeat;
  161. mask-position: center;
  162. @supports (mask-composite: source-over) {
  163. background-color: var(--gin-color-text-light);
  164. }
  165. }
  166. }
  167. &:focus {
  168. outline-offset: calc(-1 * var(--outline-size, 0px));
  169. }
  170. &:hover {
  171. &::after {
  172. transform: scale(1);
  173. @media (forced-colors: none) {
  174. background-color: var(--gin-color-primary);
  175. }
  176. }
  177. }
  178. }
  179. /* Change icon and cursor if only vertical drag is allowed. */
  180. .tabledrag-handle.tabledrag-handle-y {
  181. cursor: row-resize;
  182. &::after {
  183. mask-image: var(--admin-icon-drag-y);
  184. }
  185. }
  186. .tabledrag-handle::after,
  187. .tabledrag-disabled .tabledrag-handle.tabledrag-handle.tabledrag-handle::after {
  188. transform: scale(1);
  189. }
  190. .tabledrag-handle:is(:hover, :focus)::after,
  191. .draggable.drag .tabledrag-handle::after {
  192. transform: scale(1.25);
  193. }
  194. /* Disabled tabledrag handle. */
  195. .tabledrag-disabled {
  196. & .tabledrag-handle {
  197. cursor: default;
  198. opacity: 0.4;
  199. &.tabledrag-handle::before {
  200. content: none;
  201. }
  202. }
  203. }
  204. /**
  205. * Enhancements for touch-capable screens.
  206. */
  207. /**
  208. * Increase handle size.
  209. */
  210. .touchevents {
  211. & .tabledrag-handle::after {
  212. padding-block: var(--space-s);
  213. }
  214. & .draggable .menu-item__link {
  215. padding-block: var(--space-xs);
  216. }
  217. }
  218. /**
  219. * Wrapper of the toggle weight button (styled as a link).
  220. */
  221. .tabledrag-toggle-weight-wrapper {
  222. text-align: end;
  223. line-height: calc(28rem / 16);
  224. & + table,
  225. & + .tableresponsive-toggle-columns + table {
  226. margin-block-start: 0;
  227. }
  228. /* Hide nested weight toggles as they are redundant. */
  229. .draggable-table
  230. #field-display-overview,
  231. #field-display-overview-wrapper,
  232. .field--widget-entity-reference-paragraphs,
  233. .field--type-link,
  234. .field--type-smartdate {
  235. .gin-layer-wrapper >
  236. @media (--admin-medium) {
  237. position: relative;
  238. z-index: 1;
  239. margin-block-end: calc(var(--gin-spacing-xxl) * -1);
  240. pointer-events: none;
  241. }
  242. }
  243. }
  244. .action-link {
  245. margin-block-end: var(--gin-spacing-xs);
  246. .action-link {
  247. margin-block-end: 0;
  248. }
  249. }
  250. }
  251. /**
  252. * If the first table cell is empty (like in a multiple field widget table),
  253. * we can save some space for the following cells.
  254. * If it isn't empty (Field UI table, taxonomy term overview page), this CSS
  255. * class won't be added.
  256. */
  257. .tabledrag-cell--only-drag {
  258. width: 1px; /* This forces this cell to use the smallest possible width. */
  259. padding-inline-end: 0;
  260. }
  261. .tabledrag-cell-content {
  262. display: flex;
  263. align-items: center;
  264. height: 100%;
  265. & > * {
  266. display: table-cell;
  267. vertical-align: middle;
  268. }
  269. & .tree {
  270. flex-grow: 1;
  271. }
  272. & .tabledrag-handle::after {
  273. vertical-align: middle;
  274. }
  275. .table-file-multiple-widget
  276. }
  277. .tabledrag-cell-content__item {
  278. display: flex;
  279. align-items: center;
  280. padding-inline-end: var(--space-xs);
  281. &:empty {
  282. display: none;
  283. }
  284. }
  285. /**
  286. * Indentation.
  287. */
  288. .indentation {
  289. position: relative;
  290. display: inline-flex;
  291. overflow: clip;
  292. flex-direction: column;
  293. height: calc(100% + var(--cell-padding-y) * 2);
  294. inset-inline-start: calc(var(--space-xs) * -0.5);
  295. margin-block: calc(-1 * var(--cell-padding-y));
  296. }
  297. /**
  298. * Tree is the visual representation for the simultaneously moved draggable
  299. * rows.
  300. *
  301. * These rules are styling the inline SVG that is placed inside the .indentation
  302. * element.
  303. */
  304. .tree {
  305. width: 25px;
  306. height: 25px;
  307. }
  308. .tree__item {
  309. display: none;
  310. }
  311. /* LTR tree child. */
  312. .tree-child path {
  313. &:not(.tree__item-child-ltr) {
  314. display: none;
  315. }
  316. &.tree__item-child-ltr {
  317. display: block;
  318. }
  319. }
  320. /* RTL tree child. */
  321. [dir="rtl"] {
  322. & .tree-child path {
  323. &:not(.tree__item-child-rtl) {
  324. display: none;
  325. }
  326. &.tree__item-child-rtl {
  327. display: block;
  328. }
  329. }
  330. /* Last RTL tree child. */
  331. & .tree-child-last path {
  332. &:not(.tree__item-child-last-rtl) {
  333. display: none;
  334. }
  335. &.tree__item-child-last-rtl {
  336. display: block;
  337. }
  338. }
  339. }
  340. /* Last LTR tree child. */
  341. .tree-child-last path {
  342. &:not(.tree__item-child-last-ltr) {
  343. display: none;
  344. }
  345. &.tree__item-child-last-ltr {
  346. display: block;
  347. }
  348. }
  349. /* Horizontal line. */
  350. .tree-child-horizontal path {
  351. &:not(.tree__item-horizontal) {
  352. display: none;
  353. }
  354. &.tree__item-horizontal {
  355. display: block;
  356. }
  357. }
  358. /* @todo do these styles belong here? They were migrated from Gin. */
  359. .field-plugin-settings-edit-wrapper,
  360. .field-plugin-settings-edit-wrapper + a {
  361. margin-block: var(--gin-spacing-m);
  362. }
  363. .field-plugin-settings-edit-wrapper + a {
  364. margin-block-start: var(--gin-spacing-s);
  365. }
  366. /* Correctly align bulk action checkboxes when used in combination with tabledrag */
  367. table:has(.tabledrag-cell-content__item .form-checkbox) th.select-all .form-checkbox {
  368. margin-inline-start: calc(var(--tabledrag-handle-icon-size, calc(17rem / 16)) + var(--gin-spacing-m));
  369. }

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