feat: replace checkboxes with Switch component for better UI consistency
- Updated DoctorDetailPage, MySecretariesPage, RecordNumberSettingsPage, RepresentationsPage, ResourcePoolsPage, ResourceTypesPage, SecretariesPage, SecretaryDetailPage, SettingsPage, SkillsPage, SmsWalletPage, and TagsSettingsPage to use the new Switch component instead of native checkboxes. - Enhanced accessibility by ensuring the Switch component uses appropriate roles and labels. - Added tests for the new Switch component to ensure functionality and accessibility compliance. - Updated styles to accommodate the new Switch component design.
This commit is contained in:
@@ -3,6 +3,7 @@ import SettingsLayout from '../components/layout/SettingsLayout';
|
||||
import SearchableSelect from '../components/ui/SearchableSelect';
|
||||
import { useRecordNumberSettings } from '../hooks/useRecordNumberSettings';
|
||||
import type { RecordNumberResetPolicy } from '../hooks/useRecordNumberSettings';
|
||||
import Switch from '../components/ui/Switch';
|
||||
|
||||
const RESET_OPTIONS: { value: RecordNumberResetPolicy; label: string }[] = [
|
||||
{ value: 'none', label: 'هرگز — شمارنده پیوسته جلو میرود' },
|
||||
@@ -71,29 +72,13 @@ export default function RecordNumberSettingsPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<label style={{ display: 'inline-flex', alignItems: 'center', gap: 10, fontSize: 14, cursor: readOnly ? 'not-allowed' : 'pointer' }}>
|
||||
<span style={{
|
||||
position: 'relative', width: 42, height: 22, borderRadius: 999, flexShrink: 0,
|
||||
background: enabled ? 'var(--primary)' : 'var(--border-2)', transition: 'background .2s',
|
||||
opacity: readOnly ? 0.6 : 1,
|
||||
}}>
|
||||
<input
|
||||
type="checkbox"
|
||||
role="switch"
|
||||
aria-label="شمارهگذاری خودکار پرونده"
|
||||
checked={enabled}
|
||||
disabled={readOnly}
|
||||
onChange={(e) => setEnabled(e.target.checked)}
|
||||
style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', margin: 0, opacity: 0, cursor: 'inherit' }}
|
||||
/>
|
||||
<span style={{
|
||||
position: 'absolute', top: 2, insetInlineStart: enabled ? 22 : 2, width: 18, height: 18,
|
||||
borderRadius: 999, background: 'var(--surface)', transition: 'inset-inline-start .2s',
|
||||
boxShadow: '0 1px 2px rgba(0,0,0,.2)',
|
||||
}} />
|
||||
</span>
|
||||
شمارهگذاری خودکار پرونده
|
||||
</label>
|
||||
<Switch
|
||||
inline
|
||||
checked={enabled}
|
||||
disabled={readOnly}
|
||||
onChange={setEnabled}
|
||||
label="شمارهگذاری خودکار پرونده"
|
||||
/>
|
||||
|
||||
<div style={{ maxWidth: 420, marginTop: 18 }}>
|
||||
<label className="field-label" htmlFor="record-number-pattern">الگوی شماره</label>
|
||||
|
||||
Reference in New Issue
Block a user