Skip to content

Commit 561e35a

Browse files
committed
Adds examples to the resource page
1 parent 73f19e2 commit 561e35a

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
A date and time picker in the same React.js component. It can be used as a datepicker, timepicker or both at the same time. It is **highly customizable** and it even allows to edit date's milliseconds.
77

8-
> **Back to the roots!** Thanks to the people of [YouCanBook.me (best scheduling tool)](https://youcanbook.me) for sponsoring react-datetime for so long. Now the project returns to the community and we are **looking for collaborators** to continue improving react-datetime. [Would you like to give a hand?](contribute-home.md)
8+
> **Back to the roots!** Thanks to the people of [YouCanBook.me (best scheduling tool)](https://youcanbook.me) for sponsoring react-datetime for so long. Now the project returns to the community and we are **looking for contributors** to continue improving react-datetime. [Would you like to give a hand?](contribute-home.md)
99
1010
These are the docs for version 3 of the library. If you are still using the deprecated v2, [here it is its documentation](https://github.com/arqex/react-datetime/blob/2a83208452ac5e41c43fea31ef47c65efba0bb56/README.md), but we strongly recommend to migrate to version 3 in order to keep receiving updates. Please check [migrating react-datetime to version 3](migrateToV3.md) to safely update your app.
1111

@@ -25,20 +25,21 @@ yarn add react-datetime
2525

2626
[React.js](http://facebook.github.io/react/) and [Moment.js](http://momentjs.com/) are peer dependencies for react-datetime (as well as [Moment.js timezones](https://momentjs.com/timezone/) if you want to use the `displayTimeZone` prop). These dependencies are not installed along with react-datetime automatically, but your project needs to have them installed in order to make the datepicker work. You can then use the datepicker like in the example below.
2727

28-
2928
```js
29+
// Import the library
3030
import Datetime from 'react-datetime';
3131

32-
...
33-
34-
render: function() {
35-
return <Datetime />;
36-
}
32+
// return it from your components
33+
return <Datetime />;
3734
```
3835
[See this example working](https://codesandbox.io/s/boring-dew-uzln3).
3936

37+
Do you want more examples? [Have a look at our resources gallery](resources.md).
38+
4039
**Don't forget to add the [CSS stylesheet](https://github.com/arqex/react-datetime/blob/master/css/react-datetime.css) to make it work out of the box.**
4140

41+
42+
4243
## API
4344

4445
Below we have all the props that we can use with the `<DateTime>` component. There are also some methods that can be used imperatively.
@@ -225,15 +226,15 @@ class MyDTPicker extends React.Component {
225226
this.refs.datetime.navigate("days");
226227
}
227228
}
228-
[See it working](https://codesandbox.io/s/frosty-fog-nrwk2)
229229
```
230+
[See it working](https://codesandbox.io/s/frosty-fog-nrwk2)
230231

231232
#### Method Parameters
232233
* `props` is the object that the datepicker has calculated for this object. It is convenient to use this object as the `props` for your custom component, since it knows how to handle the click event and its `className` attribute is used by the default styles.
233234
* `selectedDate` and `currentDate` are [moment objects](http://momentjs.com) and can be used to change the output depending on the selected date, or the date for the current day.
234235
* `month` and `year` are the numeric representation of the current month and year to be displayed. Notice that the possible `month` values range from `0` to `11`.
235236

236-
## Specify Available Units
237+
## Make it work as a year picker or a time picker
237238
You can filter out what you want the user to be able to pick by using `dateFormat` and `timeFormat`, e.g. to create a timepicker, yearpicker etc.
238239

239240
In this example the component is being used as a *timepicker* and can *only be used for selecting a time*.
@@ -248,7 +249,7 @@ In this example you can *only select a year and month*.
248249
```
249250
[Working example of only selecting year and month here.](https://codesandbox.io/s/recursing-pascal-xl643)
250251

251-
## Selectable Dates
252+
## Blocking some dates to be selected
252253
It is possible to disable dates in the calendar if the user are not allowed to select them, e.g. dates in the past. This is done using the prop `isValidDate`, which admits a function in the form `function(currentDate, selectedDate)` where both arguments are [moment objects](http://momentjs.com). The function shall return `true` for selectable dates, and `false` for disabled ones.
253254

254255
In the example below are *all dates before today* disabled.

contribute-home.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
Hey!! So good you are interested in collaborate with react-datetime, I'm pretty sure you can make the difference here!
44

5-
react-datetime is a nice choice if you are looking for some open-source project to lay your hands on. It's a library used by thousands of developers, and the changes in the last version make easier for everyone to understand it. It's not simple, but it's small enough to be get you initiated in a couple of hours.
5+
react-datetime is a nice choice if you are looking for some open-source project to lay your hands on. It's a library **used by thousands of developers**, and the changes in the last version make easier for everyone to understand it. It's not simple, but it's small enough to be get you initiated in a couple of hours.
66

77
## Do you want to be part of the future of react-datetime?
88
We've just released the version 3 of the library and we are already planning the version 4, why don't you join the conversation and help defining the roadmap:
99

1010
* [Defining version 4 of react-datetime](https://github.com/arqex/react-datetime/issues/723)
1111

1212
## Do you want to play with the source code?
13-
Best way of understand anything is by doing it! This repository includes a playground to let you make changes to the library in minutes. Clone the repo and fire up the playground:
13+
Best way of understand anything is by experiencing it! This repository includes a playground to let you make changes to the library in minutes. Clone the repo and fire up the playground:
1414

1515
```sh
1616
git clone https://github.com/arqex/react-datetime.git

migrateToV3.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,6 @@ Version 3 is a big refactor of react-datetime. We have tried to not to change th
5555
* Updated most of the dependencies.
5656

5757
## Contribute
58+
react-datetime is made by the community for the community. People like you, interested in contribute, are the key of the project! 🙌🙌🙌
5859

59-
react-datetime is a nice choice if you are looking for some open-source project to lay your hands on. It's a library used by thousands of developers, and the changes in this version make easier for everyone to understand it. It's not simple, but it's small enough to be get you initiated in a couple of hours.
60-
61-
If you are interested and want to start playing with its code, clone it and fire up the playground included in the repo:
62-
63-
```
64-
git clone https://github.com/arqex/react-datetime.git
65-
cd react-datetime
66-
npm install
67-
npm run playground
68-
```
69-
70-
This will start a local development server building `src/index.js`. We can update react-datetime's sources then and our changes will be hot loaded by the development server.
71-
72-
Looking for something to work on? Have a look at [the list of known issues](https://github.com/arqex/react-datetime/issues), and maybe you can kill a bug making somebody happy! :)
73-
74-
Have some work done? That's great! But please, read the [react-datetime contributing guidelines](.github/CONTRIBUTING.md) before submitting it.
60+
Have a look at [our contribute page](contribute-home.md) to know how to get started.

resources.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,18 @@ Here a list of handy resouces that will help you getting started to use react-da
44

55
If you have written a nice article about react-datetime feel free to make a pull request to add it to the list!
66

7-
* [An editable code sandbox example to check how it works](https://codesandbox.io/s/boring-dew-uzln3).
7+
### Articles
8+
We don't have any articles yet. Yours can be the first! Create a PR to update this page.
9+
10+
### Examples
11+
* [An basic code sandbox example to check how it works](https://codesandbox.io/s/boring-dew-uzln3).
12+
* [i18n - datepicker in other languages](https://codesandbox.io/s/interesting-kare-0707b)
13+
* [Passing props to the input](https://codesandbox.io/s/interesting-kare-0707b)
14+
* [Using a custom input element](https://codesandbox.io/s/peaceful-water-3gb5m)
15+
* [Datepicker without an input](https://codesandbox.io/s/busy-vaughan-wh773)
16+
* [Using custom elements for the year/month/day views](https://codesandbox.io/s/busy-vaughan-wh773)
17+
* [Override the datepicker views completely](https://codesandbox.io/s/frosty-fog-nrwk2)
18+
* [Timepicker only](https://codesandbox.io/s/loving-nobel-sbok2)
19+
* [Year and month picker only](https://codesandbox.io/s/recursing-pascal-xl643)
20+
* [Blocking dates in the past](https://codesandbox.io/s/thirsty-shape-l4qg4)
21+
* [Blocking selection of weekends](https://codesandbox.io/s/laughing-keller-3wq1g)

0 commit comments

Comments
 (0)