Sort control

On a branch in the app

Port of Ui::SortControlComponent from roastertools-app's origin/jon-dev-3250-shared-list-controls branch (app/components/ui/sort_control_component.{rb,html.erb}). Toolbar Sort split button: both halves toggle a popover menu of sort entries. Overlaps Button split (conflict 12); kept verbatim for the branch review. Classes are the branch's verbatim, respelled: tw- stripped; border-0 border-solid dropped (the caret keeps its border-l / border-l-2); sizes by pixel at the app's 14px root (conflict 13): text-sm → text-ui-xs; hover:bg-opacity-90 → hover:bg-navy/90, border-opacity-20 → border-white/20. Entry path → href (a link) or onSelect (a button). Both halves open one popover: in the app the group <div> is data-popover-target="anchor" and each <button> is a data-popover-target="trigger" with click->popover#toggle. Here the group <div> is the Popover's trigger (Radix asChild), so a click on either half bubbles to it and toggles, and the panel anchors to the whole group as the app's anchor does. Radix puts aria-expanded / aria-controls / aria-haspopup on the group; the buttons carry the same attributes by hand so the markup reads like the app's. The control carries its own ml-auto so it sits at the right end of the Toolbar.

App: Ui::SortControlComponent (origin/jon-dev-3250-shared-list-controls)

Page default applies

#idle

active_key={null}: nothing was chosen, so the split button reads Sort with the sort-alt icon in the idle style (white, stone-dark border, a border-l-2 caret). effective_key marks the page default (Newest first) in the menu with a navy check. Either half opens the menu.

A sort chosen

#active

active_key set: the button goes navy with the entry's control_label and icon, and the caret's divider becomes border-l border-white/20. The menu marks the same entry.

Menu open

#open

default_open (Lookbook only) starts with the popover open, anchored bottom-end to the whole group as the app's anchor target. The effective entry has the surface-warm background and the check; each entry is a link to its href (the app's path), or a button with onSelect as mock behaviour.

Props

NameTypeDefaultNotes
idstring—Required. The popover id (the app's aria-controls target)
entriesSortEntry[]—Required. The menu entries
entries[].keystring—Matched against active_key and effective_key
entries[].labelstring—Menu item text ("Newest first")
entries[].control_labelstring—Text on the button while this entry is active ("Newest")
entries[].titlestring—The menu item's title attribute
entries[].iconstring—Vendored Font Awesome name, rendered light
entries[].hrefstring—The sorted list path (the app's path)
entries[].onSelect() => void—Mock behaviour: renders a <button> instead of the link
active_keystring | null—Required. The explicitly chosen sort; styles the button navy. null when the page default applies
effective_keystring—Required. The sort applied to the table (the page default when nothing is chosen); marks the menu entry
default_openbooleanfalseLookbook only: start with the menu open
classNamestring—On the ml-auto wrapper <div>