_mixins.guide-line.scss 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * Vertical and horizontal divider lines to visualise nesting in
  3. * StreamField and InlinePanel.
  4. */
  5. $guide-line-default-color: theme('colors.border-furniture');
  6. $stroke-width: 1px;
  7. @mixin guide-line-vertical() {
  8. // 3px dash height, 3px space, 1px dash width.
  9. background-size: $stroke-width 6px;
  10. background-repeat: repeat-y;
  11. background-image: linear-gradient(
  12. to bottom,
  13. var(--guide-line-color, $guide-line-default-color) 50%,
  14. rgba(255, 255, 255, 0) 0%
  15. );
  16. @media (forced-colors: active) {
  17. border-inline-start: $stroke-width dashed
  18. var(--guide-line-color, CanvasText);
  19. background: none;
  20. }
  21. }
  22. @mixin guide-line-vertical-stop() {
  23. &::after {
  24. content: '';
  25. display: inline-block;
  26. width: 9px;
  27. height: $stroke-width;
  28. position: relative;
  29. top: theme('spacing.[2.5]');
  30. inset-inline-start: calc(-1 * (var(--nesting-indent) - $stroke-width));
  31. transform: translateX(calc(var(--w-direction-factor) * -50%));
  32. border-bottom: $stroke-width solid
  33. var(--guide-line-color, $guide-line-default-color);
  34. }
  35. }
  36. @mixin guide-line-horizontal() {
  37. min-height: $stroke-width;
  38. // 3px dash width, 3px space, $stroke-width dash height.
  39. background-size: 6px $stroke-width;
  40. background-repeat: repeat-x;
  41. background-image: linear-gradient(
  42. to right,
  43. var(--guide-line-color, $guide-line-default-color) 50%,
  44. rgba(255, 255, 255, 0) 0%
  45. );
  46. // Guide lines are always shown in forced-colors mode, as it’s
  47. // not possible to have transparent borders there.
  48. @media (forced-colors: active) {
  49. border-top: $stroke-width dashed var(--guide-line-color, CanvasText);
  50. background: none;
  51. }
  52. }
  53. // More visible guide line for nested panels in the currently-active DOM tree.
  54. @mixin guide-line-nested() {
  55. &:is(:hover, :focus-within) {
  56. --guide-line-color: theme('colors.icon-primary');
  57. @media (forced-colors: active) {
  58. --guide-line-color: Highlight;
  59. }
  60. }
  61. // Avoid highlighting descendant panels.
  62. &:is(:hover, :focus-within) .w-panel:not(:hover, :focus-within),
  63. // For browsers supporting :has, avoid highlighting parent panels.
  64. &:has(.w-panel:is(:hover, :focus-within)) {
  65. --guide-line-color: #{$guide-line-default-color};
  66. @media (forced-colors: active) {
  67. --guide-line-color: CanvasText;
  68. }
  69. }
  70. }