Skip to content

Commit cce9b98

Browse files
nattb8claude
andcommitted
fix(audience-sample): stack status bar vertically on all narrow screens (SDK-314)
Move status bar vertical stacking from the phone breakpoint (<480px) to the narrow breakpoint (<1024px). UUID values in the status bar were overflowing horizontally on devices wider than 480px because the phone class was never applied. Also toggle .narrow on _root (in addition to .sample-app-grid) so the narrow selectors can reach the sticky header which sits outside the grid. Font/touch-target changes remain phone-only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e8e6826 commit cce9b98

2 files changed

Lines changed: 48 additions & 35 deletions

File tree

examples/audience/Assets/SampleApp/Resources/AudienceSample.uss

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -521,64 +521,72 @@
521521
width: 100%;
522522
}
523523

524-
/* Phone breakpoint (< 480 px) — .phone is toggled on the root VisualElement
525-
by RegisterResponsiveLayout so selectors here reach the full page tree,
526-
including the sticky header that sits outside .sample-app-grid.
527-
Goal: LARGER text for legibility, 44 px touch targets throughout, single-
528-
column status bar. Vertical height grows and is absorbed by scrolling. */
529-
530-
.phone .sticky-top-main {
531-
padding-top: 12px;
532-
}
533-
534-
/* Slight title reduction frees header height; 24 px is still prominent. */
535-
.phone .title {
536-
font-size: 24px;
537-
}
524+
/* Narrow breakpoint (< 1024 px) — .narrow is toggled on the root VisualElement
525+
(and on .sample-app-grid) by RegisterResponsiveLayout so selectors here reach
526+
the sticky header. Status bar switches to a vertical stack so UUID values
527+
never overflow sideways regardless of device width. */
538528

539-
/* Status bar: bigger font, stack all cells in one column so nothing clips. */
540-
.phone .status-bar {
529+
.narrow .status-bar {
541530
padding-left: 16px;
542531
padding-right: 16px;
543-
padding-top: 12px;
544-
padding-bottom: 12px;
545-
font-size: 14px;
546532
}
547533

548-
.phone .status-top-row {
534+
.narrow .status-top-row {
549535
flex-direction: column;
550536
flex-wrap: nowrap;
551537
align-items: stretch;
552538
}
553539

554-
.phone .status-group {
540+
.narrow .status-group {
555541
flex-direction: column;
556542
margin-right: 0;
557-
/* min-width: 0 lets align-items: stretch on the parent column constrain
558-
this group to the container width rather than expanding to content width. */
559543
min-width: 0;
560544
}
561545

562-
.phone .status-cell {
546+
.narrow .status-cell {
563547
margin-right: 0;
564548
margin-bottom: 6px;
565549
min-width: 0;
566550
overflow: hidden;
567551
}
568552

569-
/* Value fills the remaining row width and clips if still too long — the user
570-
can tap any cell to copy the full string. */
571-
.phone .status-value {
553+
/* Value clips to available width — user taps to copy the full string. */
554+
.narrow .status-value {
572555
flex-grow: 1;
573556
flex-shrink: 1;
574557
overflow: hidden;
575558
min-width: 0;
576559
}
577560

578-
.phone .status-vertical-rule {
561+
.narrow .status-vertical-rule {
579562
display: none;
580563
}
581564

565+
/* Phone breakpoint (< 480 px) — .phone is toggled on the root VisualElement
566+
by RegisterResponsiveLayout so selectors here reach the full page tree.
567+
Goal: LARGER text for legibility, 44 px touch targets throughout.
568+
Status bar vertical layout is already handled by .narrow above. */
569+
570+
.phone .sticky-top-main {
571+
padding-top: 12px;
572+
}
573+
574+
/* Slight title reduction frees header height; 24 px is still prominent. */
575+
.phone .title {
576+
font-size: 24px;
577+
}
578+
579+
/* Status bar: bigger font on phone. */
580+
.phone .status-bar {
581+
padding-top: 12px;
582+
padding-bottom: 12px;
583+
font-size: 14px;
584+
}
585+
586+
.phone .status-cell {
587+
margin-bottom: 6px;
588+
}
589+
582590
/* Tabs: 13 px text, reduced letter-spacing and padding so all four fit on
583591
375 px while staying close to the 44 px touch-target guideline. */
584592
.phone .tab-bar .tab {

examples/audience/Assets/SampleApp/Scripts/AudienceSample.UI.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,13 @@ void Update()
430430

431431
// Mirrors the web sample's `@media` breakpoints. USS 2021.3 has no
432432
// @media; toggle class names via GeometryChangedEvent instead.
433-
// .narrow on sample-app-grid : < 1024 px — stacks columns vertically.
434-
// .phone on _root : < 480 px — compact status bar, tabs,
435-
// title, and panel padding.
433+
// .narrow on sample-app-grid AND _root : < 1024 px — stacks grid
434+
// columns vertically and
435+
// switches status bar to a
436+
// vertical stack so UUIDs
437+
// never overflow sideways.
438+
// .phone on _root : < 480 px — larger text,
439+
// 44 px touch targets.
436440
// Each breakpoint is evaluated independently so toggling one does not
437441
// suppress the other. Both are idempotent — only mutate on a boolean flip.
438442
private void RegisterResponsiveLayout()
@@ -447,16 +451,17 @@ void Update()
447451
var isNarrow = grid.ClassListContains("narrow");
448452
if (shouldBeNarrow != isNarrow)
449453
{
450-
if (shouldBeNarrow) grid.AddToClassList("narrow");
451-
else grid.RemoveFromClassList("narrow");
454+
grid.EnableInClassList("narrow", shouldBeNarrow);
455+
// Also on _root so .narrow selectors can reach the sticky
456+
// header (status bar) which sits outside .sample-app-grid.
457+
_root.EnableInClassList("narrow", shouldBeNarrow);
452458
}
453459

454460
var shouldBePhone = w < PhoneBreakpointPx;
455461
var isPhone = _root.ClassListContains("phone");
456462
if (shouldBePhone != isPhone)
457463
{
458-
if (shouldBePhone) _root.AddToClassList("phone");
459-
else _root.RemoveFromClassList("phone");
464+
_root.EnableInClassList("phone", shouldBePhone);
460465
}
461466
}
462467
_root.RegisterCallback<GeometryChangedEvent>(_ => Update());

0 commit comments

Comments
 (0)