Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DatePicker] add props to set datepicker action bar buttons title #2939

Merged
Merged
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
19 changes: 17 additions & 2 deletions packages/datetime/src/datePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ export interface IDatePickerProps extends IDatePickerBaseProps, IProps {
*/
showActionsBar?: boolean;

/**
* Text for the today button in the action bar.
* @default "Today"
*/
todayButtonText?: string;

/**
* Text for the reset button in the action bar.
* @default "Clear"
*/
clearButtonText?: string;

/**
* The currently selected day. If this prop is provided, the component acts in a controlled manner.
*/
Expand All @@ -71,12 +83,14 @@ export interface IDatePickerState {
export class DatePicker extends AbstractPureComponent<IDatePickerProps, IDatePickerState> {
public static defaultProps: IDatePickerProps = {
canClearSelection: true,
clearButtonText: "Clear",
dayPickerProps: {},
maxDate: getDefaultMaxDate(),
minDate: getDefaultMinDate(),
reverseMonthAndYearMenus: false,
showActionsBar: false,
timePickerProps: {},
todayButtonText: "Today",
};

public static displayName = `${DISPLAYNAME_PREFIX}.DatePicker`;
Expand Down Expand Up @@ -194,11 +208,12 @@ export class DatePicker extends AbstractPureComponent<IDatePickerProps, IDatePic
);

private renderOptionsBar() {
const { clearButtonText, todayButtonText } = this.props;
return [
<Divider key="div" />,
<div className={Classes.DATEPICKER_FOOTER} key="footer">
<Button minimal={true} onClick={this.handleTodayClick} text="Today" />
<Button minimal={true} onClick={this.handleClearClick} text="Clear" />
<Button minimal={true} onClick={this.handleTodayClick} text={todayButtonText} />
<Button minimal={true} onClick={this.handleClearClick} text={clearButtonText} />
</div>,
];
}
Expand Down