Skip to content

Commit df5faec

Browse files
committed
external styles
1 parent 664ffc6 commit df5faec

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Calendar.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import PropTypes from 'prop-types'
33
import dateFns from 'date-fns';
44
import { View, Text, Animated, TouchableOpacity, TouchableHighlight, ScrollView, Dimensions, PanResponder, Platform } from 'react-native'
55

6-
import styles from './calendarStyles'
7-
6+
import defaultStyles from './calendarStyles'
87
import { defaultEmptyListRenderer, defaultItemRenderer } from './helpers'
8+
let styles = defaultStyles
99

1010
class Calendar extends React.Component {
1111
constructor(props) {
@@ -76,7 +76,10 @@ class Calendar extends React.Component {
7676
}
7777

7878
static getDerivedStateFromProps(props, state) {
79-
const ignoreProps = ['scrollable', 'weekMode']
79+
const ignoreProps = ['scrollable', 'weekMode', 'styles']
80+
if (props.styles) {
81+
styles = props.styles
82+
}
8083
const newState = {...state}
8184
Object.keys(props).forEach(key => {
8285
if(!ignoreProps.includes(key))
@@ -373,7 +376,8 @@ Calendar.propTypes = {
373376
emptyListRenderer: PropTypes.func,
374377
itemRenderer: PropTypes.func,
375378
itemClickHandler: PropTypes.func,
376-
onDateSelect: PropTypes.func
379+
onDateSelect: PropTypes.func,
380+
styles: PropTypes.object,
377381
}
378382

379383
export default Calendar;

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ You can see usage example in this [Expo demo](https://snack.expo.io/@ger_exciter
4747
| itemRenderer | function | defaultItemRenderer | agenda item renderer |
4848
| itemClickHandler | function | void | agenda item click handler |
4949
| onDateSelect | function | void | date select handler, doesn't prevent rendering date's agenda, runs after selected date state is updated |
50+
| styles | object | defaultStyles | custom styles that can be applied to the component. Import defaultStyles for the reference |
5051

5152
Agenda items data format:
5253
```javascript

main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import Calendar from './Calendar'
22
import { defaultEmptyListRenderer, defaultItemRenderer } from './helpers'
3+
import defaultStyles from './calendarStyles'
34

45
export {
56
Calendar,
67
defaultEmptyListRenderer,
7-
defaultItemRenderer
8+
defaultItemRenderer,
9+
defaultStyles
810
}

0 commit comments

Comments
 (0)