Skip to content

[Feature]: Add accessible Carousel Counter block #138

@theMasudRana

Description

@theMasudRana

Title: Add accessible Carousel Counter block

Description

Add a new Carousel Counter block for displaying the active carousel position in a compact current/total format, for example 1/6.

The counter should integrate with the existing Embla Carousel v8 setup and WordPress Interactivity API state so it updates as the carousel selection changes.

Requirements

  • Add a new child block: rt-carousel/carousel-counter
  • Display the counter as current/total, for example 1/6
  • Use Embla v8 APIs for count state:
    • selectedScrollSnap() for the current index
    • scrollSnapList() for the total snap count
  • Include the counter in the default carousel navigation group
  • Add frontend styles using BEM classes:
    • .rt-carousel-counter
    • .rt-carousel-counter__current
    • .rt-carousel-counter__separator
    • .rt-carousel-counter__total
  • Provide CSS variables for customization
  • Ensure the block is accessible:
    • Visible text remains compact, e.g. 1/6
    • Screen readers get a descriptive label, e.g. Slide 1 of 6
    • Avoid duplicate live announcements because the carousel already has a live region
  • Register the block in PHP
  • Add/update tests for frontend counter callbacks and block registration
  • Ensure compiled build assets are generated

Acceptance Criteria

  • A new Carousel Counter block is available inside carousel blocks
  • New carousels include the counter by default
  • Counter updates correctly when navigating slides
  • Total count reflects Embla scroll snaps, not just raw slide nodes
  • Screen readers can identify the counter as Slide X of Y
  • npm run build passes
  • Relevant JS/PHP tests pass
  • CSS lint passes

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions