-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add arrow and allow picto placement on DateTimePicker (#270)
* DateTimePicker now has an arrow * DateTimePicker now has timeIconPlacement and dateIconPlacement props with "left" "right" possible values Signed-off-by: Paul-Xavier Ceccaldi <[email protected]>
- Loading branch information
Showing
4 changed files
with
91 additions
and
7 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 |
---|---|---|
@@ -1,28 +1,54 @@ | ||
import React, { PureComponent } from 'react' | ||
import { func } from 'prop-types' | ||
import { func, oneOf } from 'prop-types' | ||
|
||
import { COMPONENT_TYPE, SIZES_TYPE } from '../../utils' | ||
import { IconWrapper } from '../Field/styles' | ||
import { Icon } from '../Icon' | ||
|
||
import * as S from './styles' | ||
|
||
// eslint-disable-next-line react/prefer-stateless-function | ||
export class CustomInput extends PureComponent { | ||
render() { | ||
const { handleBlur, handleFocus, icon, inputRef, size, ...rest } = this.props | ||
const { | ||
focused, | ||
handleBlur, | ||
handleFocus, | ||
icon, | ||
iconPlacement, | ||
inputRef, | ||
size, | ||
...rest | ||
} = this.props | ||
return ( | ||
<S.CustomInput icon={icon} onBlur={handleBlur} onFocus={handleFocus} size={size}> | ||
{icon && <IconWrapper size={size}>{icon}</IconWrapper>} | ||
<S.CustomInput | ||
focused={focused} | ||
icon={icon} | ||
iconPlacement={iconPlacement} | ||
onBlur={handleBlur} | ||
onFocus={handleFocus} | ||
size={size} | ||
> | ||
{icon && ( | ||
<IconWrapper iconPlacement={iconPlacement} size={size}> | ||
{icon} | ||
</IconWrapper> | ||
)} | ||
<input ref={inputRef} {...rest} /> | ||
<IconWrapper iconPlacement="right" size={size}> | ||
<Icon name="down" size="xs" /> | ||
</IconWrapper> | ||
</S.CustomInput> | ||
) | ||
} | ||
} | ||
|
||
CustomInput.propTypes = { | ||
focused: oneOf('date', 'time', null), | ||
handleBlur: func, | ||
handleFocus: func, | ||
icon: COMPONENT_TYPE, | ||
iconPlacement: oneOf('right', 'left'), | ||
inputRef: func, | ||
size: SIZES_TYPE | ||
} |
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
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
1c87dc7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://welcome-ui-79r4okumn.now.sh to the following aliases: