MethodShadowControl
Overview
Multi‑layer box shadow editor with per‑layer controls for offset, blur, spread, color, and inset.
- File:
lib/blocks/components/MethodShadowControl.jsx - Panel label: “Shadow”
- Base breakpoint only — this component returns
nullfor non‑base breakpoints.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
breakpoint | string | (required) | Must be base; returns null otherwise |
attributes | object | (required) | The block’s full attributes object |
setAttributes | function | (required) | WordPress setAttributes function |
Controls
Shadow Layers
- Settings key:
responsiveSettings.base.shadows - Value type:
arrayof shadow layer objects
Each shadow layer has the following properties:
| Property | Type | Default | Range | Description |
|---|---|---|---|---|
x | number | 0 | -125 to 125 | Horizontal offset in pixels |
y | number | 4 | -125 to 125 | Vertical offset in pixels |
blur | number | 8 | 0 to 200 | Blur radius in pixels |
spread | number | 0 | -64 to 64 | Spread radius in pixels |
color | string | 'rgba(0,0,0,0.15)' | — | Shadow color (supports alpha via ColorPicker) |
inset | boolean | false | — | Whether the shadow is inset |
Each property is controlled by its own RangeControl (with labeled marks) or a ColorPicker. The inset toggle is a CheckboxControl.
Adding/Removing Layers
- Add Shadow Layer: A “Add Shadow Layer” button appends a new layer with default values.
- Remove: Each layer (when more than one exists) shows a “Remove” button.
- Last layer removal: When the last layer is removed, the
shadowskey is deleted entirely from the breakpoint settings. - Multiple layers: Shadow layers are rendered with visual dividers between them and “Shadow {n}” labels.
CSS Output
MethodStyleTag processes the shadows array into a comma‑separated box-shadow CSS value:
CSS
box-shadow: 0px 4px 8px 0px rgba(0,0,0,0.15), inset 2px 2px 4px 0px rgba(0,0,0,0.1);ToolsPanel Behavior
- Box Shadow onSelect: Initializes
shadowsto a single‑element array with default values - Box Shadow onDeselect: Removes the
shadowskey entirely - resetAll: Same as onDeselect
Usage by Blocks
| Block | Notes |
|---|---|
| Section | Base breakpoint only |
| Container | Base breakpoint only |
| Button | Base breakpoint only |
| Fitted Image | Base breakpoint only |