| 1 |
// Dashed "add" button for the bottom-of-canvas "Add field" and the "Add |
| 2 |
// sub-field" appenders. One shared |
| 3 |
// look applied to: |
| 4 |
// • the AddFieldButton component (Columns / Repeater field appenders), and |
| 5 |
// • the ROOT canvas block appender (the bottom-of-form "Add field" button), |
| 6 |
// so every "add" affordance reads identically. Tokens: style/_tokens.scss. |
| 7 |
|
| 8 |
@mixin wppb-fb-add-btn { |
| 9 |
align-items: center; |
| 10 |
background: transparent; |
| 11 |
border: 1px dashed var(--wppb-fb-border-strong); |
| 12 |
border-radius: var(--wppb-fb-radius-md); |
| 13 |
box-shadow: none; |
| 14 |
box-sizing: border-box; |
| 15 |
color: var(--wppb-fb-text-muted); |
| 16 |
cursor: pointer; |
| 17 |
display: flex; |
| 18 |
// Force row so the icon + label sit inline. Core's root block appender |
| 19 |
// (`.block-editor-button-block-appender`) sets `flex-direction: column`, |
| 20 |
// which would otherwise stack the "Add field" label below the "+". |
| 21 |
flex-direction: row; |
| 22 |
flex-wrap: nowrap; |
| 23 |
font-size: var(--wppb-fb-font-md); |
| 24 |
font-weight: 500; |
| 25 |
gap: var(--wppb-fb-space-sm); |
| 26 |
height: 44px; |
| 27 |
justify-content: center; |
| 28 |
white-space: nowrap; |
| 29 |
width: 100%; |
| 30 |
|
| 31 |
&:hover, |
| 32 |
&:focus { |
| 33 |
background: transparent; |
| 34 |
border-color: var(--wppb-fb-accent); |
| 35 |
color: var(--wppb-fb-accent); |
| 36 |
} |
| 37 |
|
| 38 |
svg { |
| 39 |
flex: 0 0 auto; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
// Component button used as the Columns / Repeater appender. `button.` + |
| 44 |
// `.components-button` both reached so it beats the @wordpress/components |
| 45 |
// default Button sizing (height/padding/box-shadow). |
| 46 |
button.wppb-fb-add-button, |
| 47 |
.wppb-fb-add-button.components-button { |
| 48 |
@include wppb-fb-add-btn; |
| 49 |
margin-top: var(--wppb-fb-space-sm); |
| 50 |
} |
| 51 |
|
| 52 |
// <Inserter> wraps the toggle button in a `.block-editor-inserter` dropdown |
| 53 |
// that's inline-block by default, so the button's `width: 100%` only fills the |
| 54 |
// shrink-wrapped wrapper. Make the wrapper block-level so the button spans the |
| 55 |
// container width like the mockup's full-width add buttons. |
| 56 |
.block-editor-inserter:has( .wppb-fb-add-button ) { |
| 57 |
display: block; |
| 58 |
width: 100%; |
| 59 |
} |
| 60 |
|
| 61 |
// The rule below uses a bare generic Gutenberg selector (the ROOT canvas |
| 62 |
// appender), so it is scoped to PB form CPT screens via `.wppb-fb-block-editor` |
| 63 |
// (see _editor-chrome.scss header) — the bundle stylesheet loads on every |
| 64 |
// block-editor screen. The appender is inside the canvas iframe, so the marker is |
| 65 |
// stamped on the iframe <body> too (components/EditorBodyClass.js), not only the |
| 66 |
// main <body>. Without the scope, EVERY post/page root appender would be restyled |
| 67 |
// into an "Add field" button and lose its "Browse all". The `.wppb-fb-add-button` |
| 68 |
// rules above are self-scoped (our own class) and need no wrapper. |
| 69 |
// |
| 70 |
// Two quick-inserter rules used to sit here (hide "Browse all", border the |
| 71 |
// popover). No PB affordance opens core's quick inserter any more: AddFieldButton |
| 72 |
// omits `__experimentalIsQuick`, RootCanvasAppender replaces core's appender, and |
| 73 |
// CanvasPointInserter swallows the click on both remaining core "+"s. |
| 74 |
|
| 75 |
// Root canvas appender → the bottom-of-form "Add field" button. The node is |
| 76 |
// ours (components/RootCanvasAppender.js appends it to the root block list — |
| 77 |
// core's own `.block-list-appender` only exists while nothing is selected, and |
| 78 |
// is hidden in _mini-inserter.scss), so it only needs the gap that separated |
| 79 |
// core's appender from the last field; the button inside carries the dashed |
| 80 |
// look already. |
| 81 |
.wppb-fb-block-editor .block-editor-block-list__layout.is-root-container > .wppb-fb-root-appender { |
| 82 |
margin-top: 18px; |
| 83 |
|
| 84 |
// The button's own `margin-top` would stack on top of that gap. |
| 85 |
button.wppb-fb-add-button, |
| 86 |
.wppb-fb-add-button.components-button { |
| 87 |
margin-top: 0; |
| 88 |
} |
| 89 |
} |
| 90 |
|