diff --git a/README.md b/README.md index 0b8b902..266282f 100644 --- a/README.md +++ b/README.md @@ -47,5 +47,3 @@ const MyComponent = () => ( ``` For more examples [take a look at here](https://github.com/evandhq/react-persian-datepicker/blob/master/examples/src/components/App.js#L43). - -Note that you need `css-loader` for `/\.css$/` files enabled to have the styles working as we use css modules to put classnames in place. Otherwise, you'll have to pass an object of class names (like a css module) as `styles` prop. This way, you can develop your own stylesheet for the calendar according to the [basic one](https://github.com/evandhq/react-persian-datepicker/blob/master/src/styles/basic.css). The only thing that you will need to do is to require the css file that you made and pass it as `styles` prop to either `Calendar` or `DatePicker`. diff --git a/src/components/Calendar.js b/src/components/Calendar.js index 27dc23b..edece39 100644 --- a/src/components/Calendar.js +++ b/src/components/Calendar.js @@ -6,6 +6,7 @@ import Day from './Day'; import { getDaysOfMonth } from '../utils/moment-helper'; import moment from 'moment-jalali'; import onClickOutside from 'react-onclickoutside'; +import { defaultStyles } from './DefaultStyles'; // Load Persian localisation moment.loadPersian(); @@ -30,7 +31,7 @@ export class Calendar extends Component { }; static defaultProps = { - styles: require('../styles/basic.css'), + styles: { ...defaultStyles, ...require('../styles/basic.css') }, containerProps: {} }; diff --git a/src/components/DatePicker.js b/src/components/DatePicker.js index 682becb..848fe95 100644 --- a/src/components/DatePicker.js +++ b/src/components/DatePicker.js @@ -20,12 +20,14 @@ export default class DatePicker extends Component { inputFormat: PropTypes.string, removable: PropTypes.bool, timePickerComponent: PropTypes.func, + styles: PropTypes.object, calendarStyles: PropTypes.object, calendarContainerProps: PropTypes.object }; static defaultProps = { inputFormat: 'jYYYY/jM/jD', + styles: require('../styles/basic.css'), calendarStyles: require('../styles/basic.css'), calendarContainerProps: {} }; @@ -129,10 +131,10 @@ export default class DatePicker extends Component { className={className} type="text" ref="input" - onFocus={this.handleFocus.bind(this) } - onBlur={this.handleBlur.bind(this) } - onChange={this.handleInputChange.bind(this) } - onClick={this.handleInputClick.bind(this) } + onFocus={this.handleFocus.bind(this)} + onBlur={this.handleBlur.bind(this)} + onChange={this.handleInputChange.bind(this)} + onClick={this.handleInputClick.bind(this)} value={inputValue} /> @@ -142,6 +144,7 @@ export default class DatePicker extends Component { renderCalendar() { const { momentValue } = this.state; const { timePickerComponent: TimePicker, onChange, min, max, defaultMonth, calendarStyles, calendarContainerProps } = this.props; + const styles = this.props.styles || calendarStyles; return (