Christchurch Meningitis: Student Contracts Disease at Rugby Tournament
This HTML snippet represents a navigation menu with a horizontal scrolling feature and a search button. let’s break down the key parts:
1. Horizontal Scrolling Menu (First Block)
div class="tw-relative tw-w-full" tabindex="-1": This is the container for the scrolling menu. tw-relative sets the positioning context for its children. tw-w-full makes it take up the full width of its parent. tabindex="-1" makes it focusable via keyboard navigation but doesn’t include it in the natural tab order.
div class="tw-absolute tw-right-0 tw-top-[50%] tw--mt-[4.5rem] tw-mr-8" x-show="isSlideable": This contains the navigation buttons (previous and next).
tw-absolute: Positions the buttons absolutely within the parent container.
tw-right-0: Aligns the buttons to the right edge. tw-top-[50%]: Positions the top edge of the buttons at the vertical center of the parent.
tw--mt-[4.5rem]: Adjusts the vertical position by moving it up by 4.5rem (likely to fine-tune the centering).
tw-mr-8: Adds a right margin of 8 units.
x-show="isSlideable": This is an Alpine.js directive. The buttons are only displayed if the isSlideable variable is true. This suggests the menu only shows scroll buttons when there’s content to scroll. ul class="tw-flex tw-space-x-1 tw-items-center": An unordered list to hold the navigation buttons.
tw-flex: Uses flexbox layout. tw-space-x-1: Adds horizontal space between the list items (buttons).
tw-items-center: Vertically aligns the items to the center.
li data-test-ui="menu-scroll-prev" and li data-test-ui="menu-scroll-next": List items containing the “Previous” and “next” buttons. data-test-ui attributes are used for testing purposes.
button class="tw-p-7 c-btn-icon c-btn-icon--lg" ...: The actual buttons.
tw-p-7: Adds padding.
c-btn-icon and c-btn-icon--lg: Custom CSS classes for styling the buttons as icons. data-track-action: Attributes for tracking user interactions (e.g., “menu slider previous”).
x-on:click="slidePrevious" and x-on:click="slideNext": Alpine.js directives that call the slidePrevious and slideNext functions when the buttons are clicked.
x-on:keydown.enter="slidePrevious" and x-on:keydown.enter="slideNext": Alpine.js directives that call the functions when the Enter key is pressed while the button has focus.
x-bind:disabled="atStart" and x-bind:disabled="atEnd": Alpine.js directives that disable the buttons based on the atStart and atEnd variables. This prevents scrolling past the beginning or end of the menu.
: The SVG icon for the arrow. The href attribute points to a sprite sheet containing the icon. tw-rotate-90 and tw-rotate-270 rotate the arrow to point left and right, respectively.
Slide previous and Slide next: Screen reader-only text providing accessibility facts.2. Search button (Second Block)
The search button.
tw-shrink-0: Prevents the button from shrinking if there's extra space
