Skip to content

Commit

Permalink
Rename weekdayStyles prop to dayOfWeekStyles.
Browse files Browse the repository at this point in the history
Bump version.
  • Loading branch information
peacechen committed Jan 4, 2020
1 parent 0cf6b95 commit 55d13b8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions CalendarPicker/Weekdays.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function Weekdays(props) {
weekdays,
textStyle,
dayLabelsWrapper,
weekdayStyles,
dayOfWeekStyles,
} = props;
let wd = weekdays;
if (!wd) {
Expand All @@ -25,8 +25,8 @@ export default function Weekdays(props) {
{ wd.map((day, key) => {
let updatedStyle = textStyle;
try {
if (weekdayStyles[+key]) {
let currentDayStyle = weekdayStyles[+key];
if (dayOfWeekStyles[+key]) {
let currentDayStyle = dayOfWeekStyles[+key];
if (currentDayStyle) {
updatedStyle = [updatedStyle, currentDayStyle];
}
Expand Down
16 changes: 8 additions & 8 deletions CalendarPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ export default class CalendarPicker extends Component {
enableDateChange: true,
headingLevel: 1,
sundayColor: '#FFFFFF',
weekdayStyles: {},
dayOfWeekStyles: {},
};

componentDidMount() {
this.updateDayOfWeekStyles(moment());
}

updateDayOfWeekStyles = currentDate => {
const {startFromMonday, weekdayStyles} = this.props;
const {startFromMonday, dayOfWeekStyles} = this.props;
let day = currentDate.clone().startOf('month');

let customDatesStyles = [];
Expand All @@ -69,7 +69,7 @@ export default class CalendarPicker extends Component {
dayIndex = 6; // This is Sunday.
}
}
let currentDayStyle = weekdayStyles[dayIndex];
let currentDayStyle = dayOfWeekStyles[dayIndex];
if (currentDayStyle) {
customDatesStyles.push({
date: day.clone(),
Expand Down Expand Up @@ -214,7 +214,7 @@ export default class CalendarPicker extends Component {
});
}
try {
if (Object.entries(this.props.weekdayStyles).length) {
if (Object.entries(this.props.dayOfWeekStyles).length) {
this.updateDayOfWeekStyles(
moment({year: currentYear, month: previousMonth}),
);
Expand Down Expand Up @@ -245,7 +245,7 @@ export default class CalendarPicker extends Component {
});
}
try {
if (Object.entries(this.props.weekdayStyles).length > 0) {
if (Object.entries(this.props.dayOfWeekStyles).length > 0) {
this.updateDayOfWeekStyles(moment({year: currentYear, month: nextMonth}));
}
} catch (error) {}
Expand Down Expand Up @@ -311,14 +311,14 @@ export default class CalendarPicker extends Component {
restrictMonthNavigation,
headingLevel,
dayLabelsWrapper,
weekdayStyles,
dayOfWeekStyles,
previousTitleStyle,
nextTitleStyle,
} = this.props;

let _disabledDates = [];
let tempCustomDatesStyles = customDatesStyles;
if (Object.entries(weekdayStyles).length > 0) {
if (Object.entries(dayOfWeekStyles).length > 0) {
tempCustomDatesStyles = customDatesStyles
? customDatesStyles
: defaultCustomDatesStyles;
Expand Down Expand Up @@ -401,7 +401,7 @@ export default class CalendarPicker extends Component {
weekdays={weekdays}
textStyle={textStyle}
dayLabelsWrapper={dayLabelsWrapper}
weekdayStyles={weekdayStyles}
dayOfWeekStyles={dayOfWeekStyles}
/>
<DaysGridView
enableDateChange={enableDateChange}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const styles = StyleSheet.create({
| **`previousTitleStyle`** | `TextStyle` | Optional. Text styling for Previous text.|
| **`nextTitleStyle`** | `TextStyle` | Optional. Text styling for Next text.|
| **`dayLabelsWrapper`** | `ViewStyle` | Optional. Style for weekdays wrapper. E.g If you want to remove top and bottom divider line.|
| **`weekdayStyles`** | `ViewStyle` | Optional. Style for changing color and style for any day of the week. E.g If you want all Sundays in RED color, and Mondays in BLUE color, etc. You need to pass JSON object of styles. 0 for Sunday and 6 for Saturday, but if `startFromMonday=true`, then 0 for Monday and 6 for Sunday. See example below.|
| **`dayOfWeekStyles`** | `ViewStyle` | Optional. Style for changing color and style for any day of the week. E.g If you want all Sundays in RED color, and Mondays in BLUE color, etc. You need to pass JSON object of styles. 0 for Sunday and 6 for Saturday, but if `startFromMonday=true`, then 0 for Monday and 6 for Sunday. See example below.|

# Styles
Some styles will overwrite some won't. For instance:
Expand Down Expand Up @@ -334,7 +334,7 @@ render() {
borderBottomWidth: 0,
borderTopWidth: 0,
}}
weekdayStyles={{
dayOfWeekStyles={{
0: {
color: '#00f',
fontSize: 22,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-calendar-picker",
"version": "6.0.3",
"version": "6.0.4",
"description": "Calendar Picker Component for React Native",
"engines": {
"node": ">=4.0.0"
Expand Down

0 comments on commit 55d13b8

Please sign in to comment.