/** * Setting row — one named setting laid out as a line: an icon tile, the label * with its one-line description, and the control itself at the end. The * sibling of ToggleRow for controls that aren't switches (a dropdown, a text * box, a slider), so a card mixing both reads as one list of settings rather * than switches in rows and everything else stacked under a heading. * * The control sits beside the text while the card is wide enough for both and * drops under it otherwise — see `.aureon-settingrow` in style.scss, which * decides that against the card's width, not the viewport's. */ import type { ReactNode } from 'react'; import { FormToggle } from '@wordpress/components'; import { useId } from '@wordpress/element'; import type { LucideIcon } from '../icons'; interface SettingRowProps { icon: LucideIcon; label: string; help?: string; /** * `compact` keeps the control beside the text at every width — for a * control narrow enough to always fit there (a switch). */ size?: 'default' | 'compact'; /** Id of the control, so the visible label can point at it. */ htmlFor?: string; children: ReactNode; } export default function SettingRow( { icon: Icon, label, help, size = 'default', htmlFor, children, }: SettingRowProps ) { return (
{ htmlFor ? ( ) : ( { label } ) } { help &&

{ help }

}
{ children }
); } interface SettingToggleProps { icon: LucideIcon; label: string; help?: string; checked: boolean; onChange: ( checked: boolean ) => void; /** * Visible word beside the switch ("Show"), boxed with it — for a switch * that governs a whole block below it rather than one detail. */ text?: string; } // A setting row whose control is a switch — the unbordered, in-card sibling of // ToggleRow's bordered card, for a switch sitting among other setting rows. export function SettingToggle( { icon, label, help, checked, onChange, text, }: SettingToggleProps ) { const id = `aureon-settingtoggle-${ useId() }`; const toggle = ( onChange( event.target.checked ) } /> ); return ( { text ? ( { toggle } ) : ( toggle ) } ); }