Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app-typescript/components/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ interface IDatePickerBase extends IInputWrapper {
locale?: {type: 'code-only'; code: string} | {type: 'full'; payload: Omit<LocaleSettings, 'today' | 'clear'>};

hideClearButton?: boolean;

minYearRange?: string;
maxYearRange?: string;
}

interface IDatePicker extends IDatePickerBase {
Expand Down Expand Up @@ -176,6 +179,15 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {

const showClearButton = this.props.required === true ? false : this.props.hideClearButton !== true;

const navigatorsProps = {
monthNavigator: true,
yearNavigator: true,
yearRange:
this.props.minYearRange && this.props.maxYearRange
? `${this.props.minYearRange}:${this.props.maxYearRange}`
: `1900:${new Date().getFullYear() + 10}`,
};

return (
<InputWrapper
label={this.props.label}
Expand Down Expand Up @@ -279,6 +291,7 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
this.setState({valid: true, value: parseToPrimeReactCalendarFormat(this.props.value)});
}
}}
{...navigatorsProps}
/>
</InputWrapper>
);
Expand Down Expand Up @@ -315,6 +328,8 @@ export class DatePickerISO extends React.PureComponent<IDatePickerISO> {
label={this.props.label}
info={this.props.info}
error={this.props.error}
minYearRange={this.props.minYearRange}
maxYearRange={this.props.maxYearRange}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions app/img/chevron-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 33 additions & 1 deletion app/styles/primereact/_pr-datepicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
line-height: 1;
margin: 0 auto;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
gap: $sd-base-increment;
}

.p-datepicker-header {
Expand Down Expand Up @@ -75,14 +79,42 @@
.p-datepicker-year {
display: block;
text-align: center;
border: none;
appearance: none;
text-align-last: center;
padding: $sd-base-increment;
padding-inline-end: 2rem;
background: url(../img/chevron-down.svg) no-repeat right 0 center;
background-size: 2rem;
transition: all 0.2s ease-out, color 0.1s ease-out;

&:active {
background-color: hsla(214, 13%, 55%, 0.3);
color: var(--sd-colour-interactive);
}

&:hover,
&:focus {
cursor: pointer;
background-color: hsla(214, 13%, 55%, 0.2);
}

&:focus-visible {
background-color: hsla(214, 13%, 55%, 0.2);
box-shadow: $icn-button-focus-box-shadow;
}
}

.p-datepicker-year {
font-weight: 400;
margin-block-start: 4px;
color: var(--color-text-light);
}

.p-datepicker-month {
text-transform: uppercase;
font-weight: bold;
}

.p-datepicker {
td, th {
border: 0;
Expand Down