Skip to content

Commit 1cc0cbc

Browse files
hoestwehriam
authored andcommitted
Added some extra options (#52)
* Code cleanup * Implemented a button for 'Today' * Implemented `CustomControl` * Added documentation in `README.md` * Build `DatePicker` * Removed `console.log` * Added some padding for today-button * Remove `.bind(this)` * Added a `npm run lint` command * Added className for today-button * Added test for new functions
1 parent 796c387 commit 1cc0cbc

File tree

8 files changed

+5111
-145
lines changed

8 files changed

+5111
-145
lines changed

.eslintrc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"root": true,
3+
"ecmaFeatures": {
4+
"jsx": true,
5+
"modules": true
6+
},
7+
"parserOptions": {
8+
"ecmaVersion": 6,
9+
"sourceType": "module",
10+
"ecmaFeatures": {
11+
"jsx": true,
12+
"modules": true,
13+
}
14+
},
15+
"env": {
16+
"es6": true,
17+
"browser": true,
18+
"node": true,
19+
"jest": true,
20+
},
21+
"parser": "babel-eslint",
22+
"extends": [
23+
"eslint:recommended",
24+
"plugin:react/recommended"
25+
],
26+
"plugins": ["react"],
27+
"rules": {
28+
"indent": ["error", 2, { "SwitchCase": 1 }],
29+
"jsx-quotes": ["error", "prefer-double"],
30+
"keyword-spacing": ["error", { "after": true }],
31+
"no-console": "warn",
32+
"no-const-assign": "error",
33+
"no-duplicate-imports": "error",
34+
"no-trailing-spaces": "error",
35+
"no-unused-vars": "warn",
36+
"no-use-before-define": "error",
37+
"no-useless-concat": "error",
38+
"no-var": "error",
39+
"prefer-const": "error",
40+
"prefer-template": "error",
41+
"quotes": ["error", "single"],
42+
"radix": ["error", "always"],
43+
"semi": ["error", "always"],
44+
"template-curly-spacing": ["error", "never"],
45+
"react/no-find-dom-node": ["off"]
46+
}
47+
}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ DatePicker component. Renders as a [React-Bootstrap InputGroup](https://react-bo
165165
* **Optional**
166166
* **Type:** `boolean`
167167
* **Example:** `true`
168+
* `showTodayButton` - Toggles the visibility of the today-button.
169+
* **Optional**
170+
* **Type:** `boolean`
171+
* **Example:** `false`
172+
* `todayButtonLabel` - Label for the today-button
173+
* **Optional**
174+
* **Type:** `string`
175+
* **Example:** `"Today"`
176+
* `customControl` - Overwrite the default `FormControl` component with your own component.
177+
* **Optional**
178+
* **Type:** `React.Component`
179+
* **Example:** `<CustomControl />`
168180

169181
* **Methods:**
170182

example/app.jsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
33
import Grid from "react-bootstrap/lib/Grid";
44
import Row from "react-bootstrap/lib/Row";
55
import Col from "react-bootstrap/lib/Col";
6-
import { Navbar } from "react-bootstrap";
6+
import { Navbar, Button } from "react-bootstrap";
77
import Nav from "react-bootstrap/lib/Nav";
88
import NavItem from "react-bootstrap/lib/NavItem";
99
import DatePicker from "../src/index.jsx";
@@ -310,10 +310,36 @@ const App = React.createClass({
310310
</FormGroup>
311311
</Col>
312312
</Row>
313+
<Row>
314+
<Col sm={6}>
315+
<FormGroup bsSize="large">
316+
<ControlLabel>Show today button</ControlLabel>
317+
<DatePicker showTodayButton />
318+
</FormGroup>
319+
</Col>
320+
<Col sm={6}>
321+
<FormGroup bsSize="large">
322+
<ControlLabel>Use custom control</ControlLabel>
323+
<DatePicker customControl={<CustomControl />} />
324+
</FormGroup>
325+
</Col>
326+
</Row>
313327
</Grid>;
314328
}
315329
});
316330

317-
ReactDOM.render(<App />, document.getElementById('react'));
331+
const CustomControl = React.createClass({
332+
displayName: 'CustomControl',
333+
334+
render() {
335+
const {
336+
value,
337+
placeholder,
338+
...rest,
339+
} = this.props;
318340

341+
return <Button {...rest}>{value || placeholder}</Button>;
342+
},
343+
});
319344

345+
ReactDOM.render(<App />, document.getElementById('react'));

0 commit comments

Comments
 (0)