-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35768d8
commit 589742f
Showing
5 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
class AddComment extends Component { | ||
static propTypes = { | ||
|
||
}; | ||
|
||
state = { | ||
username: '', | ||
testMess: '' | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<p>Add new comment</p> | ||
<form> | ||
<input type = 'text' placeholder="User Name" value = {this.state.username} onChange = {this.handleUserChange} /> | ||
<textarea type = 'text' placeholder="Comments" value = {this.state.testMess} onChange = {this.handleCommentChange}/> | ||
</form> | ||
</div> | ||
) | ||
} | ||
|
||
|
||
handleUserChange = (ev) => { | ||
if (ev.target.value.length < 5 || ev.target.value.length > 15){ | ||
ev.target.style.border = '2px solid red' | ||
} else{ | ||
ev.target.style.border = '' | ||
} | ||
this.setState({ | ||
username: ev.target.value | ||
}) | ||
} | ||
|
||
handleCommentChange = (ev) => { | ||
if (ev.target.value.length < 20 || ev.target.value.length > 50){ | ||
ev.target.style.border = '2px solid red' | ||
} else{ | ||
ev.target.style.border = '' | ||
} | ||
|
||
this.setState({ | ||
testMess: ev.target.value | ||
}) | ||
} | ||
|
||
} | ||
|
||
export default AddComment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import DayPicker, { DateUtils } from 'react-day-picker'; | ||
|
||
import 'react-day-picker/lib/style.css'; | ||
|
||
export default class Calendar extends React.Component { | ||
state = { | ||
from: null, | ||
to: null, | ||
}; | ||
handleDayClick = day => { | ||
const range = DateUtils.addDayToRange(day, this.state); | ||
this.setState(range); | ||
}; | ||
handleResetClick = e => { | ||
e.preventDefault(); | ||
this.setState({ | ||
from: null, | ||
to: null, | ||
}); | ||
}; | ||
render() { | ||
const { from, to } = this.state; | ||
return ( | ||
<div className="RangeExample"> | ||
{!from && !to && <p>Please select the <strong>first day</strong>.</p>} | ||
{from && !to && <p>Please select the <strong>last day</strong>.</p>} | ||
{from && | ||
to && | ||
<p> | ||
You chose from | ||
{' '} | ||
{moment(from).format('L')} | ||
{' '} | ||
to | ||
{' '} | ||
{moment(to).format('L')} | ||
. | ||
{' '}<a href="." onClick={this.handleResetClick}>Reset</a> | ||
</p>} | ||
<DayPicker | ||
numberOfMonths={2} | ||
selectedDays={[from, { from, to }]} | ||
onDayClick={this.handleDayClick} | ||
fixedWeeks | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters