diff --git a/src/app/components/settings-select/SettingsSelect.tsx b/src/app/components/settings-select/SettingsSelect.tsx new file mode 100644 index 000000000..8bb91bb98 --- /dev/null +++ b/src/app/components/settings-select/SettingsSelect.tsx @@ -0,0 +1,95 @@ +import React, { MouseEventHandler, useState } from 'react'; +import { Box, Button, config, Icon, Icons, Menu, MenuItem, PopOut, RectCords, Text } from 'folds'; +import FocusTrap from 'focus-trap-react'; +import { stopPropagation } from '../../utils/keyboard'; + +export type SettingsSelectOption = { + value: T; + label: string; + disabled?: boolean; +}; + +/** + * A folds-native dropdown (Button + PopOut + Menu) matching Cinny's select + * pattern — used instead of a raw ` setClearAfter(e.target.value)} + options={CLEAR_AFTER_OPTIONS} + onChange={setClearAfter} aria-label="Auto-clear status after" - style={{ - background: color.SurfaceVariant.Container, - border: `1px solid ${color.SurfaceVariant.ContainerLine}`, - borderRadius: config.radii.R300, - color: color.SurfaceVariant.OnContainer, - colorScheme: 'dark', - fontSize: '0.82rem', - padding: `${config.space.S100} ${config.space.S200}`, - cursor: 'pointer', - outline: 'none', - }} - > - {CLEAR_AFTER_OPTIONS.map((opt) => ( - - ))} - + /> {(presence?.status || statusMsg) && ( - setMenuCords(undefined), - clickOutsideDeactivates: true, - isKeyForward: (evt: KeyboardEvent) => - evt.key === 'ArrowDown' || evt.key === 'ArrowRight', - isKeyBackward: (evt: KeyboardEvent) => - evt.key === 'ArrowUp' || evt.key === 'ArrowLeft', - escapeDeactivates: stopPropagation, - }} - > - - - {options.map((opt) => ( - !opt.disabled && handleSelect(opt.value)} - > - {opt.label} - - ))} - - - - } - /> - - ); -} - function SystemThemePreferences() { const themeKind = useSystemThemeKind(); const themeNames = useThemeNames(); diff --git a/src/app/features/settings/notifications/PushRuleEditor.tsx b/src/app/features/settings/notifications/PushRuleEditor.tsx index 95594446b..df57676db 100644 --- a/src/app/features/settings/notifications/PushRuleEditor.tsx +++ b/src/app/features/settings/notifications/PushRuleEditor.tsx @@ -1,6 +1,7 @@ import React, { ChangeEventHandler, FormEventHandler, useCallback, useMemo, useState } from 'react'; import { IPushRule, IPushRules, PushRuleKind } from 'matrix-js-sdk'; import { Box, Text, Button, Input, config, IconButton, Icons, Icon, Spinner, Switch } from 'folds'; +import { SettingsSelect } from '../../../components/settings-select/SettingsSelect'; import { useAccountData } from '../../../hooks/useAccountData'; import { AccountDataEvent } from '../../../../types/matrix/accountData'; import { SequenceCard } from '../../../components/sequence-card'; @@ -193,10 +194,6 @@ function AddRuleForm({ kind, placeholder, label }: AddRuleFormProps) { setRuleId(evt.currentTarget.value); }; - const handleModeChange: ChangeEventHandler = (evt) => { - setMode(evt.target.value as NotificationMode); - }; - return ( @@ -217,24 +214,12 @@ function AddRuleForm({ kind, placeholder, label }: AddRuleFormProps) { /> - + options={ADD_MODES.map((m) => ({ value: m, label: MODE_LABELS[m] }))} + onChange={setMode} + aria-label="Notification mode" + />