-
Notifications
You must be signed in to change notification settings - Fork 13
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 #606 from Cryptonomic/develop
Merging new changes in develop into master for v080b release
- Loading branch information
Showing
6 changed files
with
130 additions
and
73 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,92 +1,89 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import InputLabel from '@material-ui/core/InputLabel'; | ||
import Input from '@material-ui/core/Input'; | ||
import FormControl from '@material-ui/core/FormControl'; | ||
import FormHelperText from '@material-ui/core/FormHelperText'; | ||
import themes from '../../styles/theme'; | ||
|
||
const Container = styled(FormControl)` | ||
width: 100%; | ||
pointer-events: ${props => (props.disabled ? 'none' : 'auto')}; | ||
`; | ||
|
||
const TextAreaWrapper = styled(Input)` | ||
&&& { | ||
&[class*='focused'] { | ||
&:after { | ||
border-bottom-color: ${({ error, theme: { colors } }) => | ||
error ? colors.error1 : colors.accent}; | ||
} | ||
} | ||
background-color: ${({ theme: { colors } }) => colors.gray14}; | ||
border: 1px solid ${({ theme: { colors } }) => colors.gray14}; | ||
font-size: 14px; | ||
color: ${({ theme: { colors } }) => colors.blue5}; | ||
padding: 10px 22px 5px 22px; | ||
&:before { | ||
border-bottom: ${({ disabled }) => | ||
disabled | ||
? '1px dotted rgba(0, 0, 0, 0.32)' | ||
: '1px solid rgba(0, 0, 0, 0.12)'} ; | ||
} | ||
&:hover:before { | ||
border-bottom: solid 2px ${({ error, theme: { colors } }) => | ||
error ? colors.error1 : colors.accent} !important; | ||
} | ||
} | ||
}`; | ||
|
||
const LabelWrapper = styled(InputLabel)` | ||
&&& { | ||
&[class*='focused'] { | ||
color: ${({ theme: { colors } }) => colors.gray3}; | ||
} | ||
&[class*='shrink'] { | ||
transform: translate(0, 1.5px) scale(0.75); | ||
const styles = { | ||
cssContainer: { | ||
width: '100%' | ||
}, | ||
cssLabel: { | ||
color: themes.colors.gray15, | ||
zIndex: 10, | ||
fontSize: '16px', | ||
pointerEvents: 'none', | ||
'&$cssFocused': { | ||
color: themes.colors.gray3 | ||
} | ||
color: ${({ theme: { colors } }) => colors.gray15}; | ||
z-index: 10; | ||
font-size: 16px; | ||
pointer-events: none; | ||
transform: translate(22px, 34px) scale(1); | ||
}, | ||
cssFormControl: { | ||
transform: 'translate(22px, 34px) scale(1)' | ||
}, | ||
cssShrink: { | ||
transform: 'translate(0, 1.5px) scale(0.75)' | ||
}, | ||
cssFocused: {}, | ||
cssInput: { | ||
backgroundColor: themes.colors.gray14, | ||
border: `1px solid ${themes.colors.gray14}`, | ||
fontSize: '14px', | ||
color: themes.colors.blue5, | ||
padding: '10px 22px 5px 22px' | ||
}, | ||
cssText: { | ||
color: themes.colors.error1, | ||
fontSize: '12px', | ||
marginTop: '5px', | ||
lineHeight: '18px', | ||
height: '18px' | ||
} | ||
}`; | ||
|
||
const ErrorText = styled(FormHelperText)` | ||
&&& { | ||
color: ${({ theme: { colors } }) => colors.error1}; | ||
font-size: 12px; | ||
margin-top: 5px; | ||
line-height: 18px; | ||
height: 18px; | ||
} | ||
}`; | ||
}; | ||
|
||
type Props = { | ||
label: string, | ||
errorText?: string | React.Node, | ||
disabled?: boolean, | ||
onChange?: () => {} | ||
onChange?: () => {}, | ||
classes: object | ||
}; | ||
|
||
const CustomTextArea = (props: Props) => { | ||
const { label, onChange, errorText, disabled, ...other } = props; | ||
const { label, onChange, errorText, classes, ...other } = props; | ||
return ( | ||
<Container disabled={disabled}> | ||
<LabelWrapper>{label}</LabelWrapper> | ||
<TextAreaWrapper | ||
<FormControl className={classes.cssContainer}> | ||
<InputLabel | ||
classes={{ | ||
formControl: classes.cssFormControl, | ||
shrink: classes.cssShrink | ||
}} | ||
FormLabelClasses={{ | ||
root: classes.cssLabel, | ||
focused: classes.cssFocused | ||
}} | ||
htmlFor="micheline-input" | ||
> | ||
{label} | ||
</InputLabel> | ||
<Input | ||
classes={{ | ||
root: classes.cssInput | ||
}} | ||
id="micheline-input" | ||
key={label} | ||
onChange={event => onChange(event.target.value)} | ||
multiline | ||
{...other} | ||
/> | ||
<ErrorText component="div">{errorText}</ErrorText> | ||
</Container> | ||
<FormHelperText component="div" className={classes.cssText}> | ||
{errorText} | ||
</FormHelperText> | ||
</FormControl> | ||
); | ||
}; | ||
CustomTextArea.defaultProps = { | ||
errorText: '', | ||
disabled: false | ||
errorText: '' | ||
}; | ||
|
||
export default CustomTextArea; | ||
export default withStyles(styles)(CustomTextArea); |
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
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