_nested-panel.scss 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. @use '../../tools' as *;
  2. @use '../../settings' as *;
  3. $header-icon-size: theme('spacing.4');
  4. $icon-center-offset: 2px;
  5. $guide-line-bottom-margin: calc($form-field-spacing / 3);
  6. /**
  7. * Panel styles shared between StreamField and InlinePanel,
  8. * for repeating collapsible panels which can be reordered.
  9. * Top-level and nested panels have guiding borders to show their start and end,
  10. * as well as indentation for nested panels.
  11. */
  12. // Styles for the top-level panel, and any panel within.
  13. .w-panel--nested {
  14. --nesting-indent: #{$nested-field-indent-sm};
  15. @include media-breakpoint-up(sm) {
  16. --nesting-indent: #{$nested-field-indent};
  17. }
  18. .w-panel__content {
  19. // Center the vertical line.
  20. margin-inline-start: calc(-1 * var(--nesting-indent));
  21. padding-inline-start: var(--nesting-indent);
  22. margin-bottom: $guide-line-bottom-margin;
  23. @include guide-line-vertical();
  24. @include media-breakpoint-up(sm) {
  25. // Extra pixels for better alignment with center of icon.
  26. margin-inline-start: calc(
  27. -1 * var(--nesting-indent) + $icon-center-offset
  28. );
  29. }
  30. }
  31. .w-panel__anchor {
  32. // Mask the overlap with the parent panel’s guide line.
  33. background-color: theme('colors.surface-page');
  34. }
  35. .w-field__wrapper {
  36. // Reduced field spacing for nested panels.
  37. // Using both padding and margin so the field guide line extends below.
  38. padding-bottom: calc($form-field-spacing / 2);
  39. margin-bottom: $guide-line-bottom-margin;
  40. }
  41. }
  42. // Styles for nested panels at the top level only.
  43. .w-panel--nested:not(.w-panel .w-panel) {
  44. > .w-panel__content {
  45. @include guide-line-vertical-stop();
  46. }
  47. }
  48. // Styles for nested panels excluding the top level.
  49. .w-panel--nested .w-panel {
  50. margin-inline-start: var(--nesting-indent);
  51. margin-bottom: 0;
  52. @include guide-line-nested();
  53. .w-panel__content {
  54. margin-inline-start: calc(
  55. -1 * (var(--nesting-indent) + $icon-center-offset - var(--header-gap) / 2)
  56. );
  57. }
  58. // Tighter spacing for nested panel headers so their icons align
  59. // with parent panels’ guiding line.
  60. .w-panel__header {
  61. gap: 0;
  62. transform: translateX(
  63. calc(var(--w-direction-factor) * -1 * var(--nesting-indent))
  64. );
  65. @include media-breakpoint-up(sm) {
  66. transform: translateX(
  67. calc(var(--w-direction-factor) * theme('spacing.1'))
  68. );
  69. }
  70. }
  71. .w-panel__divider {
  72. // Slightly nicer text alignment.
  73. margin-top: 1px;
  74. @include guide-line-horizontal();
  75. }
  76. .w-panel__heading--label {
  77. // Use smaller labels within nested panels in InlinePanel.
  78. @apply w-label-2;
  79. }
  80. // For nested panels, there is always enough space for the prefix anchor.
  81. .w-panel__anchor--prefix {
  82. display: inline-grid;
  83. }
  84. // Nested panels never need the suffix anchor.
  85. .w-panel__anchor--suffix {
  86. display: none;
  87. }
  88. }