diff --git a/resources/css/components/group.css b/resources/css/components/group.css index ad4b7cb3..699ac720 100644 --- a/resources/css/components/group.css +++ b/resources/css/components/group.css @@ -13,8 +13,14 @@ * secondary), `filled` (surface-container behind on-surface-variant, chosen in primary) or * `outlined` (an outline-variant edge, chosen in inverse-surface). A checked input picks the * chosen colours (`:has(:checked)`), a disabled one the disabled treatment — on-surface at 10% - * behind 38% text — and keyboard focus on the input draws M3's focus ring around its segment. - * Corners move on the fast spatial spring and colours on the fast effects spring beside it. + * behind 38% text. Corners move on the fast spatial spring and colours on the fast effects spring + * beside it. + * + * A segment renders the foundation's `md-state-layer` (foundation/interaction.css) on the label + * itself, which reaches the same `:hover`/`:active` as the class expects; below `medium`'s smallest + * two sizes it renders `md-touch-target` too. The real control is the `` inside, not the + * label, so keyboard focus and the disabled state are read off it with `:has()` — the one + * difference the class cannot draw, kept here as a refinement. * * The legend is label-large and the hint body-small, both in on-surface-variant; a validation * message takes the hint's place in error. `hint-class` lands on the hint, where a caller's class @@ -53,8 +59,6 @@ --md-group-container: var(--md-sys-color-secondary-container); --md-group-label: var(--md-sys-color-on-secondary-container); - position: relative; - isolation: isolate; display: flex; flex: 1 1 0%; align-items: center; @@ -76,31 +80,21 @@ var(--md-sys-motion-spatial-fast), var(--md-sys-motion-spatial-fast), var(--md-sys-motion-effects-fast), var(--md-sys-motion-effects-fast), var(--md-sys-motion-effects-fast); - &::before { - content: ''; - position: absolute; - inset: 0; - z-index: -1; - border-radius: inherit; - background-color: currentColor; - opacity: 0; - pointer-events: none; - transition: opacity var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast); - } - - @media (hover: hover) { - &:hover::before { - opacity: var(--md-sys-state-hover-state-layer-opacity); - } - } - + /* Focus lands on the input inside, not the label, so it is read with :has(); the state + layer's own opacity joins the ring, as the foundation class draws for a focused control. */ &:has(:focus-visible) { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; + + &::before { + opacity: var(--md-sys-state-focus-state-layer-opacity); + } } - &:active::before { - opacity: var(--md-sys-state-pressed-state-layer-opacity); + /* Disabled is read off the input too: the class's own :disabled/aria-disabled rule never + fires on the label it never reaches. */ + &:has(:disabled)::before { + display: none; } /* The radio or checkbox stays in the page, for the form, the keyboard and a screen reader. */ @@ -123,18 +117,6 @@ [data-md-group]:is([data-md-size='xs'], [data-md-size='sm']) [data-md-group-segment] { min-inline-size: var(--md-sys-measurement-space600); - - &::after { - content: ''; - position: absolute; - top: 50%; - left: 50%; - width: 100%; - height: 100%; - min-width: var(--md-sys-measurement-space600); - min-height: var(--md-sys-measurement-space600); - transform: translate(-50%, -50%); - } } [data-md-group][data-md-size='xs'] [data-md-group-segment] { diff --git a/resources/views/components/group.blade.php b/resources/views/components/group.blade.php index f87815a8..b302f723 100644 --- a/resources/views/components/group.blade.php +++ b/resources/views/components/group.blade.php @@ -60,6 +60,8 @@ // A 20px glyph comes from M3's 20px cut, which the icon component picks from the size. $iconSize = ['xs' => 20, 'sm' => 20, 'md' => 24, 'lg' => 32, 'xl' => 40][$size]; + // Below `medium` a segment draws under 48px, so it needs the foundation's touch target too. + $segmentNeedsTouchTarget = in_array($size, ['xs', 'sm'], true); $root = $attributes->only(['class', 'wire:key'])->merge(array_filter([ 'data-md-group' => true, @@ -78,7 +80,7 @@
@foreach ($options as $option) -