Skip to content

Commit fbad6fa

Browse files
authored
Merge pull request #8 from jquense/master
merging parent changes
2 parents f94992c + ad8defa commit fbad6fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+61155
-31906
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"plugins": [
1212
["babel-plugin-transform-rename-import", {
13-
replacements: [{ original: "lodash", replacement: "lodash-es" }]
13+
"replacements": [{ "original": "lodash", "replacement": "lodash-es" }]
1414
}]
1515
]
1616
}

.size-snapshot.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"./dist/react-big-calendar.js": {
3-
"bundled": 497580,
4-
"minified": 153472,
5-
"gzipped": 47831
3+
"bundled": 535365,
4+
"minified": 165479,
5+
"gzipped": 51024
66
},
77
"./dist/react-big-calendar.min.js": {
8-
"bundled": 428485,
9-
"minified": 132196,
10-
"gzipped": 42237
8+
"bundled": 463339,
9+
"minified": 143714,
10+
"gzipped": 45341
1111
},
1212
"dist/react-big-calendar.esm.js": {
13-
"bundled": 185554,
14-
"minified": 87500,
15-
"gzipped": 21669,
13+
"bundled": 219605,
14+
"minified": 99669,
15+
"gzipped": 24759,
1616
"treeshaked": {
1717
"rollup": {
18-
"code": 62542,
19-
"import_statements": 1590
18+
"code": 63242,
19+
"import_statements": 1412
2020
},
2121
"webpack": {
22-
"code": 67195
22+
"code": 66708
2323
}
2424
}
2525
}

.storybook/rbc.theme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ export default create({
2626
inputBorderRadius: 4,
2727

2828
brandTitle: 'Big Calendar',
29-
brandUrl: 'http://intljusticemission.github.io/react-big-calendar/examples',
29+
brandUrl: 'http://jquense.github.io/react-big-calendar/examples',
3030
})

CHANGELOG.md

Lines changed: 62 additions & 68 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ element has a height, or the calendar won't be visible. To provide your own cust
2121
## Run examples locally
2222

2323
```sh
24-
$ git clone [email protected]:intljusticemission/react-big-calendar.git
24+
$ git clone [email protected]:jquense/react-big-calendar.git
2525
$ cd react-big-calendar
2626
$ yarn
2727
$ yarn examples
@@ -89,7 +89,7 @@ import getDay from 'date-fns/getDay'
8989
import enUS from 'date-fns/locale/en-US'
9090

9191
const locales = {
92-
'en-US': enUS
92+
'en-US': enUS,
9393
}
9494

9595
const localizer = dateFnsLocalizer({
@@ -118,7 +118,6 @@ const MyCalendar = props => (
118118
Out of the box, you can include the compiled CSS files and be up and running. But, sometimes, you may want to style
119119
Big Calendar to match your application styling. For this reason, SASS files are included with Big Calendar.
120120

121-
122121
```
123122
@import 'react-big-calendar/lib/sass/styles';
124123
@import 'react-big-calendar/lib/addons/dragAndDrop/styles'; // if using DnD

examples/App.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import Api from './Api'
33
import Intro from './Intro.md'
4+
import TimezoneIntro from './Timezones.md'
45
import { render } from 'react-dom'
56
import Layout from 'react-tackle-box/Layout'
67

@@ -20,6 +21,8 @@ import BackgroundEvents from './demos/backgroundEvents'
2021
import Selectable from './demos/selectable'
2122
import CreateEventWithNoOverlap from './demos/createEventWithNoOverlap'
2223
import Cultures from './demos/cultures'
24+
import Timezones from './demos/timezones'
25+
import Luxon from './demos/luxon'
2326
import Popup from './demos/popup'
2427
import Rendering from './demos/rendering'
2528
import CustomView from './demos/customView'
@@ -34,13 +37,15 @@ import MenuItem from 'react-bootstrap/lib/MenuItem'
3437
const globalizeLocalizer = localizer(globalize)
3538

3639
let demoRoot =
37-
'https://github.com/intljusticemission/react-big-calendar/tree/master/examples/demos'
40+
'https://github.com/jquense/react-big-calendar/tree/master/examples/demos'
3841

3942
const EXAMPLES = {
4043
basic: 'Basic Calendar',
4144
selectable: 'Create events',
4245
createEventWithNoOverlap: 'Create events with no-overlap algorithm',
46+
timezones: 'Timezones',
4347
cultures: 'Localization',
48+
luxon: 'Luxon Localizer',
4449
popup: 'Show more via a popup',
4550
timeslots: 'Custom Time Grids',
4651
rendering: 'Customized Component Rendering',
@@ -78,7 +83,9 @@ class Example extends React.Component {
7883
basic: Basic,
7984
backgroundEvents: BackgroundEvents,
8085
selectable: Selectable,
86+
timezones: Timezones,
8187
cultures: Cultures,
88+
luxon: Luxon,
8289
popup: Popup,
8390
rendering: Rendering,
8491
customView: CustomView,
@@ -109,7 +116,7 @@ class Example extends React.Component {
109116
{' | '}
110117
<a
111118
target="_blank"
112-
href="https://github.com/intljusticemission/react-big-calendar"
119+
href="https://github.com/jquense/react-big-calendar"
113120
>
114121
<i className="fa fa-github" /> github
115122
</a>
@@ -163,6 +170,9 @@ class Example extends React.Component {
163170
<div className="contain section">
164171
<Intro />
165172
</div>
173+
<div className="contain section">
174+
<TimezoneIntro />
175+
</div>
166176
<Api className="contain section" />
167177
</div>
168178
</div>

examples/Intro.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ _yarn:_ `yarn add react-big-calendar`
66

77
_npm:_ `npm install --save react-big-calendar`
88

9+
`react-big-calendar` is a full featured Calendar component for managing events and dates. It uses modern `flexbox` for layout, making it super responsive and performant. Leaving most of the layout heavy lifting to the browser.
10+
911
Styles can be found at: `react-big-calendar/lib/css/react-big-calendar.css`, and should be included on the page
10-
with the calendar component. Alternatively, you can include the styles directly in your SASS build. See the [Custom Styling](https://github.com/intljusticemission/react-big-calendar/blob/master/README.md#custom-styling) section of the README file for more details.
12+
with the calendar component. Alternatively, you can include the styles directly in your SASS build. See the [Custom Styling](https://github.com/jquense/react-big-calendar/blob/master/README.md#custom-styling) section of the README file for more details.
1113

12-
Also make sure that your calendar's container
13-
element has a height, or the calendar won't be visible (see why below).
14+
Also make sure that your calendar's container element has a height, or the calendar won't be visible (see why below).
1415

1516
Date internationalization and localization is **hard** and `react-big-calendar` doesn't even attempt to
1617
solve that problem. Instead you can use one of the many excellent solutions already
17-
out there, via adapters called "localizers". Big Calendar comes with two localizers for use
18-
with [Globalize.js](https://github.com/jquery/globalize) or [Moment.js](http://momentjs.com/).
18+
out there, via adapters called "localizers". Big Calendar comes with three localizers for use
19+
with [Globalize.js](https://github.com/jquery/globalize), [Moment.js](http://momentjs.com/) or [Luxon](https://moment.github.io/luxon).
1920

2021
Choose the localizer that best suits your needs, or write your own. Whatever you do, you'll need to set it up
2122
before you can use the calendar (you only need to set it up once).
@@ -24,7 +25,7 @@ before you can use the calendar (you only need to set it up once).
2425
import { Calendar, momentLocalizer } from 'react-big-calendar'
2526
import moment from 'moment'
2627

27-
// Setup the localizer by providing the moment (or globalize) Object
28+
// Setup the localizer by providing the moment (or globalize, or Luxon) Object
2829
// to the correct localizer.
2930
const localizer = momentLocalizer(moment) // or globalizeLocalizer
3031

@@ -44,3 +45,6 @@ Once you've configured a localizer, the Calendar is ready to accept `dateFormat`
4445
how dates will be displayed throughout the component and are specific to the localizer of your choice. For
4546
instance if you are using the Moment localizer,
4647
then any [Moment format pattern](http://momentjs.com/docs/#/displaying/format/) is valid!
48+
49+
One thing to note is that, `react-big-calendar` treats event start/end dates as an _exclusive_ range which means that the event spans up to, but not including, the end date. In the case of displaying events on whole days, end dates are rounded _up_ to the next day. So an event ending on `Apr 8th 12:00:00 am` will not appear on the 8th, whereas one ending
50+
on `Apr 8th 12:01:00 am` will. If you want _inclusive_ ranges consider providing a function `endAccessor` that returns the end date + 1 day for those events that end at midnight.

examples/TimezoneSelect.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import Layout from 'react-tackle-box/Layout'
4+
import moment from 'moment'
5+
import 'moment-timezone'
6+
7+
import ExampleControlSlot from './ExampleControlSlot'
8+
9+
const allZones = moment.tz.names()
10+
allZones.unshift('clear')
11+
12+
export default function TimezoneSelect({
13+
title,
14+
defaultTZ = moment.tz.guess(),
15+
timezone,
16+
setTimezone,
17+
}) {
18+
const onChange = ({ target: { value } }) =>
19+
setTimezone(value ? value : defaultTZ)
20+
21+
return (
22+
<ExampleControlSlot.Entry waitForOutlet>
23+
<Layout direction="column" align="center">
24+
{title ? <h4>{title}</h4> : null}
25+
<label>Select a Timezone</label>{' '}
26+
<select
27+
className="form-control"
28+
style={{ width: 200, display: 'inline-block' }}
29+
value={timezone}
30+
onChange={onChange}
31+
>
32+
{allZones.map((c, idx) => (
33+
<option key={idx} value={c !== 'clear' ? c : ''}>
34+
{c}
35+
</option>
36+
))}
37+
</select>
38+
</Layout>
39+
</ExampleControlSlot.Entry>
40+
)
41+
}
42+
43+
TimezoneSelect.propTypes = {
44+
title: PropTypes.string,
45+
defaultTZ: PropTypes.string,
46+
timezone: PropTypes.string,
47+
setTimezone: PropTypes.func,
48+
}

examples/Timezones.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# <a id='timezonesIntro' href='#timezoneIntro'>Dealing With Time Zones</a>
2+
3+
Time Zones are... **hard**, and while changing the `culture` will help with internationalization and localization, it does not adjust the dates for a specific time zone. Javascript Date objects don't really support time zone switching natively, and date math gets **very** complicated. Thankfully `react-big-calender` does support `moment` as a localizer, so if you use [moment-timezone](https://momentjs.com/timezone/) you can get your events to display relevant to a time zone other than the browser native.
4+
5+
To change your events to display as a specific time zone, you must [change moment's default timezone](https://momentjs.com/timezone/docs/#/using-timezones/default-timezone/) for all dates, **using an IANA time zone**.
6+
7+
```jsx
8+
import { Calendar, momentLocalizer } from 'react-big-calendar'
9+
import moment from 'moment'
10+
import 'moment-timezone' // or 'moment-timezone/builds/moment-timezone-with-data[-datarange].js'. See their docs
11+
12+
// Set the IANA time zone you want to use
13+
moment.tz.setDefault('Europe/Paris')
14+
15+
// Setup the localizer by providing the moment Object
16+
// to the correct localizer.
17+
const localizer = momentLocalizer(moment) // or globalizeLocalizer
18+
19+
const MyCalendar = props => (
20+
<div>
21+
<Calendar
22+
localizer={localizer}
23+
events={myEventsList}
24+
startAccessor="start"
25+
endAccessor="end"
26+
/>
27+
</div>
28+
)
29+
```
30+
31+
The `momentLocalizer` will now handle all dates and date math as if the date is in the timezone you specified. It is important to note that [changing moment's default timezone](https://momentjs.com/timezone/docs/#/using-timezones/default-timezone/) affects all dates, created by moment, from that point forward, so you may want to reset the default when your component unmounts. And, if switching timezones 'on-the-fly', you want to update your 'localizer' and any Date based props (min, max, getNow, etc) at the same time.
32+
33+
**Note:** The new `luxonLocalizer` operates in a similar fashion. View the 'Luxon Localizer' demo and view it's source for an example of it's usage.

0 commit comments

Comments
 (0)