Files
livewire-material/resources/css/components/navigation-item.css
T
Andreas Reinhold / reiniandClaude Sonnet 5 63d421ccb6 Draw the navigation bar and bar item without Tailwind
Plan step 36 (navigation group, second batch): <x-navigation-bar>'s and
<x-navigation-bar-item>'s class lists move into
resources/css/components/navigation-bar.css and navigation-bar-item.css,
keyed on data-md-navigation-bar (data-md-tall, data-md-hide-on-scroll/
-hidden) and data-md-navigation-bar-item (data-md-active), both in
material.components. The indicator's growing fill and its state layer,
shared with the rail's item, move into a new navigation-item.css both
files import — the day's own layer in datepicker.css is the precedent
for keeping it out of the shared foundation classes: the element
focused and pressed is the whole item, the layer drawn only on the
smaller indicator or pill inside it, which md-state-layer cannot do and
:focus-visible never matches. The wash colour moves from a dead
on-surface base overridden by both items to a shared on-secondary-
container declaration, and its opacities from literal 0.08/0.1 to
state.css's own tokens — no visible change, since the numbers matched.

Every size is px (16dp Tailwind quirks aside, this file had none); the
bar's own item-count and container-query layout, N-08's label-medium
fix and N-19's on-secondary-container wash already matched the audit,
so only hooks, units and layer needed to change.

The scaffold's hide-on-scroll offset rule (`--material-bottom-bar`,
navigation-bar.css) stays unlayered: <x-scaffold> still publishes that
variable with a Tailwind utility until its own rewrite, and a rule in
any layer loses to it regardless of specificity — unlike the FAB
overrides the rail commit moves into material.components, which only
have to beat another material.components rule.

navigation.css is not deleted yet (still Tailwind's for the rail); its
"Navigation" comment in tailwind.css narrows as each stream leaves.
navigation-bar.css is not in NavigationStylesheetsTest.php's dataset:
its one unlayered rule breaks that test's "every block is
material.components" assumption, so the same checks are in
NavigationBarTest.php instead, the same reason ErrorPagesTest.php
carries error-page.css's.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
2026-09-15 00:08:34 +02:00

71 lines
3.6 KiB
CSS

/*
* Shared between `<x-navigation-bar-item>` and `<x-navigation-rail-item>` (imported by both
* navigation-bar-item.css and navigation-rail-item.css): the destination indicator's growing fill
* and its state layer, on androidx's one stated colour for a navigation item's layer.
*
* `NavigationRailColorTokens.kt` gives one colour for all six states, active or not:
* `ItemActiveHoveredStateLayer = … = ItemInactivePressedStateLayer = OnSecondaryContainer`.
* `NavigationBarTokens.kt` states no state-layer tokens of its own, so the bar's item takes the
* rail's (N-19). Hover only where a pointer can hover, so a touch screen does not keep the last
* hover after a tap; state.css's own opacities (8% hover, 10% focus and press) rather than the
* package's `md-state-layer` class, because the element focused and pressed is the whole item
* while the layer is drawn only on the smaller indicator or pill inside it — `md-state-layer`
* cannot draw on a different element than the one it decorates, and `:focus-visible` never
* matches a child (the same reason datepicker.css keeps the day's own layer).
*
* The active indicator itself is a secondary-container fill painted as a background image so it
* can grow out of its centre without stretching the icon: when a page arrives through
* wire:navigate, resources/js/navigation.js starts it at zero width for a moment and it springs
* open on the default spatial spring, as Compose's indicator does when the selection changes
* (NavigationItem.kt). A full page load draws it at once; reduced motion zeroes the transition.
*/
@layer material.reset, material.tokens, material.base, material.layout, material.components, material.text, material.visibility;
@layer material.components {
[data-md-navigation-bar-item] :is([data-md-navigation-indicator], [data-md-navigation-pill]),
[data-md-navigation-rail-item],
[data-md-navigation-rail-item] [data-md-navigation-indicator] {
background-position: center;
background-repeat: no-repeat;
background-size: 100% 100%;
transition: background-size var(--md-sys-motion-spatial-default-duration) var(--md-sys-motion-spatial-default);
}
@media (hover: hover) {
:is([data-md-navigation-bar-item], [data-md-navigation-rail-item]):hover {
--navigation-layer: var(--md-sys-state-hover-state-layer-opacity);
}
}
:is([data-md-navigation-bar-item], [data-md-navigation-rail-item]):focus-visible {
--navigation-layer: var(--md-sys-state-focus-state-layer-opacity);
}
:is([data-md-navigation-bar-item], [data-md-navigation-rail-item]):active {
--navigation-layer: var(--md-sys-state-pressed-state-layer-opacity);
}
[data-md-navigation-bar-item] [data-md-navigation-indicator]::before,
[data-md-navigation-bar-item] [data-md-navigation-pill]::before,
[data-md-navigation-rail-item]::before,
[data-md-navigation-rail-item] [data-md-navigation-indicator]::before {
content: '';
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background-color: var(--md-sys-color-on-secondary-container);
opacity: var(--navigation-layer, 0);
pointer-events: none;
transition: opacity var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast);
}
/* The wrapper a floating badge anchors to: tight around the glyph alone, not the wider
indicator or pill around it, so the badge sits at the icon's own corner (badge.css). */
[data-md-navigation-icon] {
position: relative;
display: inline-flex;
}
}