Skip to content

Commit 9787ff8

Browse files
authored
[ui][monthYearPicker] Add required props and align bottom (yangshun#369)
1 parent 335413f commit 9787ff8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/portal/src/components/shared/MonthYearPicker.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ export type MonthYear = Readonly<{
1111
type Props = Readonly<{
1212
errorMessage?: string;
1313
monthLabel?: string;
14+
monthRequired?: boolean;
1415
onChange: (value: MonthYear) => void;
1516
value: MonthYear;
1617
yearLabel?: string;
18+
yearRequired?: boolean;
1719
}>;
1820

1921
const MONTH_OPTIONS = [
@@ -82,17 +84,20 @@ export default function MonthYearPicker({
8284
value,
8385
onChange,
8486
yearLabel = 'Year',
87+
monthRequired = false,
88+
yearRequired = false,
8589
}: Props) {
8690
const hasError = errorMessage != null;
8791
const errorId = useId();
8892

8993
return (
9094
<div
9195
aria-describedby={hasError ? errorId : undefined}
92-
className="flex space-x-4">
96+
className="flex items-end space-x-4">
9397
<Select
9498
label={monthLabel}
9599
options={MONTH_OPTIONS}
100+
required={monthRequired}
96101
value={value.month}
97102
onChange={(newMonth) =>
98103
onChange({ month: Number(newMonth) as Month, year: value.year })
@@ -101,6 +106,7 @@ export default function MonthYearPicker({
101106
<Select
102107
label={yearLabel}
103108
options={YEAR_OPTIONS}
109+
required={yearRequired}
104110
value={value.year}
105111
onChange={(newYear) =>
106112
onChange({ month: value.month, year: Number(newYear) })

0 commit comments

Comments
 (0)