Commit 9072cdc
fix(demo): restore the theme menu's swatch rail
PR #15 rebuilt the theme picker as `mat-menu-item` rows and styled them as
if the icon, the name and the colour swatch were flex children of the
button:
.theme-option .theme-option-name { flex: 1; }
.color-swatch { flex-shrink: 0; margin-left: 12px; }
They are not. `MatMenuItem` projects into two slots -- `mat-icon,
[matMenuItemIcon]` for the leading icon and `*` for everything else -- and
the second slot is wrapped in a `<span class="mat-mdc-menu-item-text">`
that Material renders as a block. So the name and the swatch both land
inside that block, `flex: 1` applies to a span whose parent is not a flex
container and does nothing, and the swatch simply flows 12px after the
label. Its position then tracks the label's length: measured across the
13 rows, the gap from the swatch to the panel's right edge ranged from
26.7px (Spring Green) to 79.5px (Red) -- a ragged column where the design
wants a flush rail.
The published 22.1.0 demo predates that rewrite, which is why it still
looks right.
Wrap the name and swatch in a `.theme-option-row` span and make that the
flex container. The Material wrapper is already `flex: 1`, so a block-level
child fills the row and the existing rules start working as written. This
keeps the whole fix inside the component's own markup and styles: no
`::ng-deep`, no global rule reaching for `.mat-mdc-menu-item-text`, and no
borrowing the `matMenuItemIcon` slot for a trailing element -- the sort of
coupling to MDC internals #15 was itself removing.
`display: inline-block` on `.color-swatch` goes with it; the swatch is a
flex item now, so it was blockified anyway.
Verified in a headless browser: all 13 swatches sit at 26.9px from the
panel edge, each at full width and its own palette colour, with the
checked row's primary tint unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PuiyqrcbMudio9AAQpNNBe1 parent cf70e52 commit 9072cdc
2 files changed
Lines changed: 20 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
131 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
132 | 144 | | |
133 | 145 | | |
134 | 146 | | |
| |||
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
146 | | - | |
147 | 158 | | |
148 | 159 | | |
149 | 160 | | |
| |||
0 commit comments