Skip to content

Commit 0ac4408

Browse files
jdamcdclaude
andcommitted
Improve form layout on narrow screens
Date inputs no longer overflow on small devices. Selected country fills available width. Period filter uses short labels (1Y, 5Y) below the sm breakpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7d5dfd5 commit 0ac4408

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/components/AddVisitForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function AddVisitForm({ onAdd, onCancel }: AddVisitFormProps) {
4444
</label>
4545
{selectedCountry ? (
4646
<div className="flex items-center gap-2">
47-
<span className="px-3 py-2 bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 rounded">
47+
<span className="flex-1 px-3 py-2 bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 rounded">
4848
{selectedCountry.name}
4949
</span>
5050
<button
@@ -113,7 +113,7 @@ export function AddVisitForm({ onAdd, onCancel }: AddVisitFormProps) {
113113
type="date"
114114
value={startDate}
115115
onChange={(e) => setStartDate(e.target.value)}
116-
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
116+
className="w-full min-w-0 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
117117
required
118118
/>
119119
</div>
@@ -126,7 +126,7 @@ export function AddVisitForm({ onAdd, onCancel }: AddVisitFormProps) {
126126
value={endDate}
127127
onChange={(e) => setEndDate(e.target.value)}
128128
min={startDate}
129-
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
129+
className="w-full min-w-0 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
130130
/>
131131
</div>
132132
</div>

src/components/DateRangeFilter.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export function DateRangeFilter({ dateRange, onChange }: DateRangeFilterProps) {
1313
const now = useMemo(() => new Date(), []);
1414
const [showCustom, setShowCustom] = useState(false);
1515

16-
const presets: { value: PresetOption; label: string }[] = [
17-
{ value: '1y', label: '1 year' },
18-
{ value: '5y', label: '5 years' },
19-
{ value: 'all', label: 'All' },
20-
{ value: 'custom', label: 'Custom' },
16+
const presets: { value: PresetOption; label: string; shortLabel: string }[] = [
17+
{ value: '1y', label: '1 year', shortLabel: '1Y' },
18+
{ value: '5y', label: '5 years', shortLabel: '5Y' },
19+
{ value: 'all', label: 'All', shortLabel: 'All' },
20+
{ value: 'custom', label: 'Custom', shortLabel: 'Custom' },
2121
];
2222

2323
const currentPreset = useMemo((): PresetOption => {
@@ -83,7 +83,7 @@ export function DateRangeFilter({ dateRange, onChange }: DateRangeFilterProps) {
8383
<span className="w-12 shrink-0 text-sm text-gray-500 dark:text-gray-400">Period</span>
8484

8585
<div className="flex flex-wrap gap-2">
86-
{presets.map(({ value, label }) => (
86+
{presets.map(({ value, label, shortLabel }) => (
8787
<button
8888
key={value}
8989
onClick={() => handlePresetChange(value)}
@@ -93,7 +93,8 @@ export function DateRangeFilter({ dateRange, onChange }: DateRangeFilterProps) {
9393
: 'border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:border-gray-400 dark:hover:border-gray-500'
9494
}`}
9595
>
96-
{label}
96+
<span className="sm:hidden">{shortLabel}</span>
97+
<span className="hidden sm:inline">{label}</span>
9798
</button>
9899
))}
99100
</div>

0 commit comments

Comments
 (0)