feat: add arrow position options (below/overlay/outside) to Controls block - #187
Open
sanketio wants to merge 5 commits into
Open
feat: add arrow position options (below/overlay/outside) to Controls block#187sanketio wants to merge 5 commits into
sanketio wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds a new Controls-block “Position” option to let carousel arrows render below (default), overlaying the slide edges, or outside in side gutters, while keeping the default output byte-identical for existing content.
Changes:
- Introduces a new
positionattribute forrt-carousel/carousel-controlsplus editor UI (SelectControl) to configure it. - Adds a shared
getPositionClassNamehelper used by botheditandsaveto avoid class drift. - Adds CSS for overlay/outside positioning (including
:has()-based gutters) and updates/extends unit tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/blocks/carousel/types.ts | Adds the position attribute typing for Controls. |
| src/blocks/carousel/controls/block.json | Declares the new position attribute with default below. |
| src/blocks/carousel/controls/get-position-class.ts | New helper to compute wrapper classes consistently. |
| src/blocks/carousel/controls/edit.tsx | Adds Inspector control + uses helper-driven class name. |
| src/blocks/carousel/controls/save.tsx | Uses helper-driven class name in saved markup. |
| src/blocks/carousel/controls/style.scss | Implements overlay/outside arrow positioning and gutters. |
| src/blocks/carousel/controls/tests/get-position-class.test.ts | Unit tests for the helper. |
| src/blocks/carousel/controls/tests/edit.test.tsx | Updates editor tests for new UI + class behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+36
to
+37
| export type CarouselControlsPosition = 'below' | 'overlay' | 'outside'; | ||
| export type CarouselControlsAttributes = { position: CarouselControlsPosition }; |
Comment on lines
+78
to
+82
| onChange={ ( value ) => | ||
| setAttributes( { | ||
| position: value as CarouselControlsPosition, | ||
| } ) | ||
| } |
Comment on lines
+63
to
+71
| .rt-carousel:not([data-axis="y"]) .rt-carousel-controls.is-position-overlay, | ||
| .rt-carousel:not([data-axis="y"]) .rt-carousel-controls.is-position-outside { | ||
| position: absolute; | ||
| inset: 0; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| pointer-events: none; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Position option to the Carousel Controls block so the prev/next arrows can sit Below the slides (current default, unchanged), Overlay on the slide edges, or Outside flanking the slides. This is the common "arrows left/right of / over the cards" slider layout requested in #143.
The setting lives on the Controls block as a new
positionattribute, exposed via aSelectControlin the block inspector. A shared pure helper derives the wrapper class soeditandsavecan't drift, and CSS positions the arrows against the ancestor.rt-carousel(alreadyposition: relative), using:has()for the Outside gutter — the same:has()pattern already used for tabs mode.Type of change
Related issue(s)
Closes #143
What changed
positionattribute (belowdefault /overlay/outside) onrt-carousel/carousel-controlswith a labelled PositionSelectControlin the inspector (plus a hint to place Controls as a direct child of the carousel for overlay/outside).getPositionClassNamehelper used by bothedit.tsxandsave.tsx→belowemits onlyrt-carousel-controls; overlay/outside addis-position-overlay/is-position-outside.controls/style.scss): overlay floats arrows over the slide edges (absolute, vertically centered); outside adds side gutters via:has()so arrows flank the slides. Horizontal-only (:not([data-axis="y"])); RTL handled by existing logical-property + icon-flip rules. Tunable via--rt-carousel-control-inset/--rt-carousel-control-gutter/--rt-carousel-control-gutter-mobile.Breaking changes
Default is
below, which is not serialized and emits byte-identical markup to the current output (class="rt-carousel-controls", no modifier). Existing saved Controls blocks re-parse as valid — no block-validation errors, no deprecation entry, no forced re-save. New CSS activates only on the opt-in classes, so sites that just update the plugin look pixel-for-pixel the same.Testing
Describe how this was tested.
:has()for the Outside gutter — already used by tabs mode; overlay does not use:has())Test details — run from the plugin root after checking out this branch:
Manual (in a WordPress editor): insert a Carousel → select the Controls block → set Position to Overlay then Outside, and verify on the front end:
Full step-by-step How-to-test lives on the issue: #143.
Note on overlay centering
Overlay/outside arrows center on the slide track (
.rt-carousel/ viewport). If slide media carries a trailing margin — e.g. WordPress core/theme's:where(figure){margin:0 0 1em}on image slides — the track is taller than the visible media, so the arrows read as ~8px low. This is theme/content styling (the author controls it), not the feature's CSS, which adds no vertical margin/padding. Slides that fill their height (Cover blocks, vertically-centered content) don't show it.Screenshots / recordings
Verified on a local site with three carousels (below / overlay / outside); the compiled overlay/outside rules are served and applied on the front end. (Local dev env — no public URL to link.)
Checklist