Skip to content

Commit ca34b29

Browse files
committed
feat(inputs): Adding support to custom todayButtonText
1 parent cad4151 commit ca34b29

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

src/components/button/today.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ const TodayButton = ({ selectable, selected, today, ...rest }) => {
1717
today={today.toString()}
1818
style={{ marginTop: 10 }}
1919
{...otherProps}
20-
>
21-
Today
22-
</Button>
20+
/>
2321
);
2422
};
2523

src/components/calendar/calendar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const Calendar = ({
1818
selected,
1919
selectedClassName,
2020
showToday,
21+
todayButtonText,
2122
weekdayNames,
2223
}) => (
2324
<Segment className="clndr-calendars-segment">
@@ -115,7 +116,7 @@ const Calendar = ({
115116
dateObj: getToday(selected, minDate, maxDate),
116117
})}
117118
>
118-
Today
119+
{todayButtonText}
119120
</TodayButton>
120121
)}
121122
</Segment>
@@ -133,6 +134,7 @@ Calendar.propTypes = {
133134
selected: PropTypes.instanceOf(Date),
134135
selectedClassName: PropTypes.string,
135136
showToday: PropTypes.bool,
137+
todayButtonText: PropTypes.string.isRequired,
136138
weekdayNames: PropTypes.array.isRequired,
137139
};
138140

src/inputs/range.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class RangeInput extends BaseInput {
2020
monthNames: PropTypes.array,
2121
onDateChange: PropTypes.func.isRequired,
2222
placeholder: PropTypes.string,
23+
todayButtonText: PropTypes.string,
2324
weekdayNames: PropTypes.array,
2425
};
2526

@@ -28,6 +29,7 @@ class RangeInput extends BaseInput {
2829
format: 'YYYY-MM-DD',
2930
monthNames: monthNamesEng,
3031
placeholder: null,
32+
todayButtonText: 'Today',
3133
weekdayNames: weekdayNamesEng,
3234
};
3335

@@ -81,7 +83,7 @@ class RangeInput extends BaseInput {
8183

8284
render() {
8385
const { isVisible, selectedDate, selectedDateFormatted } = this.state;
84-
const { date, monthNames } = this.props;
86+
const { date, monthNames, todayButtonText } = this.props;
8587

8688
return (
8789
<div
@@ -109,6 +111,7 @@ class RangeInput extends BaseInput {
109111
<Calendar
110112
{...props}
111113
monthNames={monthNames}
114+
todayButtonText={todayButtonText}
112115
weekdayNames={this.weekdayNames}
113116
/>
114117
)}

src/inputs/simple.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class SimpleInput extends BaseInput {
2020
monthNames: PropTypes.array,
2121
onDateChange: PropTypes.func.isRequired,
2222
placeholder: PropTypes.string,
23+
todayButtonText: PropTypes.string,
2324
weekdayNames: PropTypes.array,
2425
};
2526

@@ -28,6 +29,7 @@ class SimpleInput extends BaseInput {
2829
format: 'YYYY-MM-DD',
2930
monthNames: monthNamesEng,
3031
placeholder: null,
32+
todayButtonText: 'Today',
3133
weekdayNames: weekdayNamesEng,
3234
};
3335

@@ -76,7 +78,7 @@ class SimpleInput extends BaseInput {
7678

7779
render() {
7880
const { isVisible, selectedDate, selectedDateFormatted } = this.state;
79-
const { date, monthNames } = this.props;
81+
const { date, monthNames, todayButtonText } = this.props;
8082

8183
return (
8284
<div
@@ -103,6 +105,7 @@ class SimpleInput extends BaseInput {
103105
<Calendar
104106
{...props}
105107
monthNames={monthNames}
108+
todayButtonText={todayButtonText}
106109
weekdayNames={this.weekdayNames}
107110
/>
108111
)}

stories/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ storiesOf('Examples', module)
5252
.add('Simple with brazilian labels', () => (
5353
<Simple
5454
onDateChange={console.log}
55+
format="DD/MM/YYYY"
5556
monthNames={brazilianMonths}
57+
todayButtonText="Hoje"
5658
weekdayNames={brazilianWeek}
5759
/>
5860
));

0 commit comments

Comments
 (0)