feat(settings,admin): every tab and popup in the planner's design

This commit is contained in:
Maurice
2026-10-01 16:00:37 +02:00
parent 4bc7c5cf68
commit 788a58679e
75 changed files with 8134 additions and 8023 deletions
@@ -1,57 +1,62 @@
import { AlertTriangle, Check } from 'lucide-react'
import { useTranslation } from '../../i18n'
import { NumericInput } from '../shared/NumericInput'
import { fs } from '../shared/DialogShell'
import { INPUT } from '../shared/dialogParts'
import { SETTINGS_BUTTON_PRIMARY, StatusPill } from '../Settings/settingsKit'
import { useGoogleQuota } from './useGoogleQuota'
/**
* The daily ceiling on Google calls (#1582), as one row of the Google options:
* today's count as a badge beside the name, the number on the right, a save
* button only while there is something to save.
* today's count as a pill beside the name, the number on the right, a save
* button only while there is something to save. Laid out like settingsKit's
* SettingRow, but with the pill outside the <label> so the field keeps the
* plain name as its accessible name.
*/
export default function GoogleDailyLimitRow() {
const { t } = useTranslation()
const { status, draft, setDraft, dirty, saving, save } = useGoogleQuota()
return (
<div className="flex flex-wrap items-start justify-between gap-x-4 gap-y-2 py-3">
<div className="min-w-0 flex-1 basis-60">
<div className="flex flex-wrap items-center gap-2">
<label htmlFor="admin-google-daily-limit" className="text-sm font-medium text-content-secondary">{t('admin.googleQuota.title')}</label>
{/* Today's count beside the name it belongs to: green while there is room, amber once the day is used up. */}
{status && (
status.exhausted ? (
<span className="inline-flex items-center gap-1 rounded-full bg-warning-soft px-2 py-[2px] text-caption font-semibold tabular-nums text-warning">
<AlertTriangle size={11} strokeWidth={2.4} />
{t('admin.googleQuota.reached', { used: status.used_today })}
</span>
) : (
<span className="inline-flex items-center gap-1.5 rounded-full border border-edge-faint bg-surface-secondary px-2 py-[2px] text-caption font-semibold tabular-nums text-content-secondary">
<span aria-hidden className="h-1.5 w-1.5 rounded-full bg-success" />
{status.daily_limit == null
? t('admin.googleQuota.usedToday', { used: status.used_today })
: t('admin.googleQuota.usedOfLimit', { used: status.used_today, limit: status.daily_limit })}
</span>
)
)}
<div className={`px-3.5 py-3 ${saving ? 'opacity-60' : ''}`}>
<div className="flex flex-wrap items-center gap-x-4 gap-y-2">
<div className="min-w-0 flex-1 basis-56">
<div className="flex flex-wrap items-center gap-2">
<label htmlFor="admin-google-daily-limit" className="font-medium text-content" style={fs(13, 'body')}>{t('admin.googleQuota.title')}</label>
{/* Today's count beside the name it belongs to: a green dot while there is room, amber once the day is used up. */}
{status && (
status.exhausted ? (
<StatusPill tone="warning" icon={<AlertTriangle size={11} strokeWidth={2.4} />}>
{t('admin.googleQuota.reached', { used: status.used_today })}
</StatusPill>
) : (
<StatusPill icon={<span aria-hidden className="mr-0.5 h-1.5 w-1.5 rounded-full bg-success" />}>
{status.daily_limit == null
? t('admin.googleQuota.usedToday', { used: status.used_today })
: t('admin.googleQuota.usedOfLimit', { used: status.used_today, limit: status.daily_limit })}
</StatusPill>
)
)}
</div>
<p className="m-0 mt-0.5 leading-snug text-content-faint" style={fs(11.5)}>{t('admin.googleQuota.subtitle')}</p>
</div>
<p className="text-xs text-content-faint mt-0.5">{t('admin.googleQuota.subtitle')}</p>
</div>
<div className="flex flex-col items-end">
<div className="flex items-center gap-2">
<NumericInput
id="admin-google-daily-limit"
mode="integer"
value={draft}
onValueChange={setDraft}
onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); void save() } }}
placeholder={t('admin.googleQuota.placeholder')}
disabled={status === null || saving}
className="w-32 px-3 py-1.5 border border-edge rounded-lg text-sm text-right tabular-nums bg-surface-input text-content focus:ring-2 focus:ring-accent focus:border-transparent disabled:opacity-60"
/>
<div className="flex flex-none items-center gap-2">
<div className="w-32">
<NumericInput
id="admin-google-daily-limit"
mode="integer"
value={draft}
onValueChange={setDraft}
onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); void save() } }}
placeholder={t('admin.googleQuota.placeholder')}
disabled={status === null || saving}
className={`${INPUT} text-right font-geist tabular-nums`}
/>
</div>
{dirty && (
<button type="button" onClick={() => void save()} disabled={saving}
className="inline-flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-sm font-medium text-accent-text hover:opacity-90 disabled:opacity-60">
<Check size={14} />
className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
<Check size={14} strokeWidth={2.2} />
{t('common.save')}
</button>
)}