gab-social/app/javascript/gabsocial/components/textarea.js
mgabdev 176ddc22f2 Updated the default class name
• Updated:
- the default class name
2020-08-18 15:49:11 -05:00

81 lines
1.7 KiB
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames/bind'
import Text from './text'
const cx = classNames.bind(_s)
class Textarea extends React.PureComponent {
handleOnChange = (e) => {
this.props.onChange(e.target.value)
}
render() {
const {
placeholder,
prependIcon,
value,
onKeyUp,
onFocus,
onBlur,
title,
} = this.props
const inputClasses = cx({
d: 1,
text: 1,
outlineNone: 1,
lineHeight125: 1,
displayBlock: 1,
py10: 1,
bgTransparent: 1,
fs15PX: 1,
flexGrow1: 1,
maxH100VH: 1,
resizeVertical: 1,
cPrimary: 1,
px5: !!prependIcon,
pl15: !prependIcon,
})
return (
<div>
{
!!title &&
<div className={[_s.d, _s.mb10, _s.pl15].join(' ')}>
<Text size='small' weight='medium' color='secondary'>
{title}
</Text>
</div>
}
<div className={[_s.d, _s.bgPrimary, _s.border1PX, _s.borderColorSecondary, _s.flexRow, _s.radiusSmall, _s.aiCenter].join(' ')}>
<textarea
className={inputClasses}
type='text'
placeholder={placeholder}
value={value}
onChange={this.handleOnChange}
onKeyUp={onKeyUp}
onFocus={onFocus}
onBlur={onBlur}
/>
</div>
</div>
)
}
}
Textarea.propTypes = {
placeholder: PropTypes.string,
prependIcon: PropTypes.string,
value: PropTypes.string,
onChange: PropTypes.func,
onKeyUp: PropTypes.func,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
title: PropTypes.string,
}
export default Textarea