-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from performant-software/feature/datetime-input
Archnet #1276 - Add DatetimeLocalInput
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.datetime-local-input.ui.icon.input > i.icon.right { | ||
cursor: pointer; | ||
pointer-events: all !important; | ||
left: auto; | ||
right: 1px; | ||
} | ||
.datetime-local-input.ui.icon.input > input { | ||
padding-right: calc(22px + 1.1em) !important; | ||
} |
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,44 @@ | ||
// @flow | ||
|
||
import React from 'react'; | ||
import { Icon, Input } from 'semantic-ui-react'; | ||
import './DatetimeLocalInput.css'; | ||
|
||
type Props = { | ||
/** | ||
* Callback fired when the datetime string in the input field is changed. | ||
*/ | ||
onChange: (dateString: ?String) => void, | ||
/** | ||
* Current value of the datetime-local input form field, as a string, or null. | ||
*/ | ||
value?: ?String | ||
} | ||
|
||
/** | ||
* This input component is used to input and display a date and time, using the browser's | ||
* native date picker. | ||
*/ | ||
const DatetimeLocalInput = (props: Props) => ( | ||
<Input | ||
aria-label='Datetime Local Input' | ||
className='datetime-local-input icon' | ||
> | ||
<input | ||
onChange={(e) => props.onChange(e.target.value)} | ||
type='datetime-local' | ||
value={props.value} | ||
/> | ||
<Icon | ||
className='right icon' | ||
name='times' | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
props.onChange(''); | ||
}} | ||
/> | ||
</Input> | ||
); | ||
|
||
export default DatetimeLocalInput; |
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