Gates / frontend (push) Successful in 1m57s
Gates / test (push) Successful in 2m34s
Gates / test-aarch64 (push) Successful in 8m9s
Gates / package (push) Successful in 7m14s
Gates / container (push) Successful in 17s
CI / gates (push) Successful in 18m17s
Release / guard (push) Successful in 33s
Gates / test-aarch64 (push) Successful in 7m22s
Gates / container (push) Successful in 11s
Release / gates (push) Successful in 10m35s
Gates / frontend (push) Successful in 2m8s
Gates / test (push) Successful in 2m16s
Gates / package (push) Successful in 44s
Release / publish (push) Successful in 10m4s
The Overview page takes the decided visual language (specs/ui-visual-redesign.md): four centred totals with their Activity links, a smoothed area chart of total and blocked queries with point hover and a tooltip centred beside the point, a stacked client chart in eight distinct hues plus one Other band that is always a series, and a card row with the cache hit rate, the query types as a single-hue ramp ring, and the upstream breakdown. The count axis grows its margin with the widest grouped tick and draws whole-number ticks only. GET /api/overview takes a client parameter; the scoped read uses idx_query_log_ts and the cache keeps scoped slots. The device selector beside the period selector is URL state, so a scoped view is a link, and the tile links carry the scope into Activity. The route reduces a pasted IPv6 scope to the RFC 5952 spelling the logger stores, mapped addresses included, and drops anything that is not an address. A failed device list says so under the selector with a retry. All measured quantities go through admin/src/lib/format.ts: grouped counts, two-decimal percentages, one-decimal rates, durations as the two largest nonzero units. Identifiers, configured values and preset labels render as written; the module header states that scope. A sweep test refuses toFixed, toLocaleString, Intl.NumberFormat and padStart anywhere else. Chrome: one 4px radius from the metrics constants, shared Card with a prominent title and a one-line description on every panel, the settings form sections on the same card with a floated legend, the sidebar grouped into Monitoring and System with a status block (protection, queries per minute on Overview, uptime), keyboard-focusable table scroll wrappers, and the accent darkened to 5.43:1 on its wash. Not built: the spec's ranked-list primitive, which has no consumer and no API rows. Codex reviewed sessions B to D over five rounds (thirty-three findings fixed, thirteen rejected as non-quantities); the owner skipped a sixth round. Claude-Session: https://claude.ai/code/session_01VTgx3a1zz1R78o4K55kkwR
209 lines
6.0 KiB
TypeScript
209 lines
6.0 KiB
TypeScript
/**
|
|
* The single-choice picker (milestone 23, ruling 4), replacing every native
|
|
* `<select>` in the app.
|
|
*
|
|
* RAC composes a Select out of Label, Button, SelectValue, Popover, ListBox and
|
|
* ListBoxItem; those parts are the Select, not extra components adopted beyond
|
|
* ruling 4's scope, and nothing outside this file imports them.
|
|
*
|
|
* Keys are strings because a `<select>`'s value was a string. A call site that
|
|
* models an id converts on both edges.
|
|
*/
|
|
|
|
import { CaretDown } from "@phosphor-icons/react/dist/icons/CaretDown";
|
|
import * as stylex from "@stylexjs/stylex";
|
|
import {
|
|
Button,
|
|
Label,
|
|
ListBox,
|
|
ListBoxItem,
|
|
Popover,
|
|
Select as AriaSelect,
|
|
SelectValue,
|
|
Text,
|
|
} from "react-aria-components";
|
|
import { colors, metrics } from "./tokens.stylex";
|
|
import { styles as shared } from "./styles";
|
|
|
|
export interface SelectOption {
|
|
value: string;
|
|
label: string;
|
|
}
|
|
|
|
interface Props {
|
|
options: readonly SelectOption[];
|
|
value: string;
|
|
onChange: (value: string) => void;
|
|
/** The visible label. Omit it only when `aria-label` names the control. */
|
|
label?: string;
|
|
"aria-label"?: string;
|
|
/**
|
|
* Text under the control that qualifies it. RAC gives it an id and points the
|
|
* trigger's `aria-describedby` at it, which a sibling rendered by the caller
|
|
* cannot be: the trigger is this file's, so only this file can name it.
|
|
*/
|
|
description?: string;
|
|
/**
|
|
* `field` matches a full-width form input, `compactField` the smaller one a
|
|
* dialog uses, `inline` a control sitting in a row of other controls, and
|
|
* `toolbar` the 44px hairline dropdown a page's scope picker is.
|
|
*/
|
|
variant?: "field" | "compactField" | "inline" | "toolbar";
|
|
/** Visible but inert, keeping its value on screen; RAC also drops it from the tab order. */
|
|
isDisabled?: boolean;
|
|
}
|
|
|
|
const styles = stylex.create({
|
|
root: {
|
|
display: "block",
|
|
},
|
|
label: {
|
|
display: "block",
|
|
fontSize: "0.875rem",
|
|
lineHeight: "1.25rem",
|
|
fontWeight: 500,
|
|
},
|
|
trigger: {
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "space-between",
|
|
gap: "0.5rem",
|
|
textAlign: "left",
|
|
// RAC renders a real `<button disabled>`, so the state is reachable as a
|
|
// pseudo-class rather than needing a second style object.
|
|
cursor: { default: "pointer", ":disabled": "not-allowed" },
|
|
opacity: { default: null, ":disabled": 0.55 },
|
|
},
|
|
compact: {
|
|
marginTop: "0.25rem",
|
|
width: "100%",
|
|
},
|
|
/** Rectangular, hairline, full hit height: the decision record's toolbar selector. */
|
|
toolbar: {
|
|
minHeight: metrics.hitTarget,
|
|
borderRadius: metrics.radius,
|
|
borderWidth: 1,
|
|
borderStyle: "solid",
|
|
borderColor: { default: colors.border, ":hover": colors.borderStrong },
|
|
backgroundColor: colors.surfaceRaised,
|
|
color: colors.text,
|
|
paddingInline: "0.9375rem",
|
|
paddingBlock: "0.5rem",
|
|
fontSize: "0.875rem",
|
|
lineHeight: "1.25rem",
|
|
transitionProperty: "border-color",
|
|
transitionDuration: { default: metrics.transitionDuration, "@media (prefers-reduced-motion: reduce)": "0s" },
|
|
},
|
|
/** Explicit, so RAC's default `react-aria-SelectValue` class does not land. */
|
|
value: {
|
|
overflow: "hidden",
|
|
textOverflow: "ellipsis",
|
|
whiteSpace: "nowrap",
|
|
},
|
|
chevron: {
|
|
display: "inline-flex",
|
|
color: colors.textMuted,
|
|
},
|
|
description: {
|
|
display: "block",
|
|
fontSize: "0.75rem",
|
|
lineHeight: "1rem",
|
|
color: colors.textMuted,
|
|
},
|
|
popover: {
|
|
width: "var(--trigger-width)",
|
|
maxHeight: "16rem",
|
|
overflowY: "auto",
|
|
borderRadius: metrics.radius,
|
|
borderWidth: 1,
|
|
borderStyle: "solid",
|
|
borderColor: colors.borderStrong,
|
|
backgroundColor: colors.surfaceRaised,
|
|
color: colors.text,
|
|
boxShadow: "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",
|
|
},
|
|
listBox: {
|
|
outlineStyle: "none",
|
|
paddingBlock: "0.25rem",
|
|
},
|
|
item: {
|
|
paddingInline: "0.75rem",
|
|
paddingBlock: "0.375rem",
|
|
fontSize: "0.875rem",
|
|
lineHeight: "1.25rem",
|
|
cursor: "pointer",
|
|
},
|
|
/**
|
|
* The inverted row is the listbox convention, and the ring is the milestone-9
|
|
* floor; an option gets both. RAC focuses the option's own DOM node, so the
|
|
* shared `:focus-visible` ring does apply here — it is drawn inset because an
|
|
* option flush against a scrolling popover clips an outset one, and recoloured
|
|
* because the focus token is the same blue this row just painted behind it.
|
|
*/
|
|
itemFocused: {
|
|
backgroundColor: colors.primary,
|
|
color: colors.primaryText,
|
|
outlineColor: { default: null, ":focus-visible": colors.primaryText },
|
|
},
|
|
itemSelected: {
|
|
fontWeight: 600,
|
|
},
|
|
});
|
|
|
|
export default function Select({
|
|
options,
|
|
value,
|
|
onChange,
|
|
label,
|
|
"aria-label": ariaLabel,
|
|
description,
|
|
variant = "field",
|
|
isDisabled = false,
|
|
}: Props) {
|
|
const base = variant === "field" ? shared.input : variant === "toolbar" ? styles.toolbar : shared.smallInput;
|
|
const block = variant === "compactField" ? styles.compact : null;
|
|
return (
|
|
<AriaSelect
|
|
aria-label={ariaLabel}
|
|
isDisabled={isDisabled}
|
|
value={value}
|
|
onChange={(key) => onChange(String(key ?? ""))}
|
|
{...stylex.props(styles.root)}
|
|
>
|
|
{label !== undefined && <Label {...stylex.props(styles.label)}>{label}</Label>}
|
|
<Button className={() => stylex.props(base, block, styles.trigger, shared.focusRing).className ?? ""}>
|
|
<SelectValue className={() => stylex.props(styles.value).className ?? ""} />
|
|
<span aria-hidden="true" {...stylex.props(styles.chevron)}>
|
|
<CaretDown size={12} />
|
|
</span>
|
|
</Button>
|
|
{description !== undefined && (
|
|
<Text slot="description" {...stylex.props(styles.description)}>
|
|
{description}
|
|
</Text>
|
|
)}
|
|
<Popover className={() => stylex.props(styles.popover).className ?? ""}>
|
|
<ListBox {...stylex.props(styles.listBox)}>
|
|
{options.map((option) => (
|
|
<ListBoxItem
|
|
key={option.value}
|
|
id={option.value}
|
|
textValue={option.label}
|
|
className={({ isFocused, isSelected }) =>
|
|
stylex.props(
|
|
styles.item,
|
|
shared.insetFocusRing,
|
|
isSelected && styles.itemSelected,
|
|
isFocused && styles.itemFocused,
|
|
).className ?? ""
|
|
}
|
|
>
|
|
{option.label}
|
|
</ListBoxItem>
|
|
))}
|
|
</ListBox>
|
|
</Popover>
|
|
</AriaSelect>
|
|
);
|
|
}
|