_nested-panel.scss 2.7 KB

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