Skip to content

Commit aca0733

Browse files
committed
fix: textarea character counter
1 parent 94037dc commit aca0733

File tree

6 files changed

+44
-16
lines changed

6 files changed

+44
-16
lines changed

src/shared/components/Settings/FormField/index.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import cn from 'classnames';
99
import './styles.scss';
1010

1111
const FormField = ({
12-
children, label = '', disabled, style,
12+
children, label = '', disabled, style, isTextarea,
1313
}) => (
1414
<div styleName="form-field-wrapper" style={style}>
1515
<div styleName="form-field">
16-
<div styleName={cn('label', disabled ? 'disabled' : null)} role="presentation">
16+
<div styleName={cn('label', { disabled, isTextarea })} role="presentation">
1717
{label}
1818
</div>
1919
{children}
@@ -26,13 +26,15 @@ FormField.defaultProps = {
2626
children: null,
2727
disabled: false,
2828
style: {},
29+
isTextarea: false,
2930
};
3031

3132
FormField.propTypes = {
3233
label: PT.string,
3334
children: PT.node,
3435
disabled: PT.bool,
3536
style: PT.object,
37+
isTextarea: PT.bool,
3638
};
3739

3840
export default FormField;

src/shared/components/Settings/FormField/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
&.disabled {
3030
color: $color-black-60;
3131
}
32+
33+
&.isTextarea {
34+
top: 10px;
35+
}
3236
}
3337
}
3438
}

src/shared/components/Settings/FormInputTextArea/index.jsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,34 @@ import PT from 'prop-types';
88
import cn from 'classnames';
99
import './styles.scss';
1010

11-
const FormInputTextArea = ({ styleName, ...props }) => (
12-
<textarea
13-
type="text"
14-
styleName={cn('form-input-text-area', styleName || '')}
15-
{...props}
16-
/>
17-
);
11+
const FormInputTextArea = ({ styleName, ...props }) => {
12+
const { value } = props;
13+
14+
return (
15+
<div>
16+
<span styleName="char-count">
17+
{(value && value.length) || 0}
18+
<span styleName="grey">
19+
&nbsp;/ 240
20+
</span>
21+
</span>
22+
<textarea
23+
type="text"
24+
styleName={cn('form-input-text-area', styleName || '')}
25+
{...props}
26+
/>
27+
</div>
28+
);
29+
};
1830

1931
FormInputTextArea.defaultProps = {
2032
styleName: {},
33+
value: null,
2134
};
2235

2336
FormInputTextArea.propTypes = {
2437
styleName: PT.shape(),
38+
value: PT.string,
2539
};
2640

2741
export default FormInputTextArea;

src/shared/components/Settings/FormInputTextArea/styles.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,17 @@
3131
box-shadow: none !important;
3232
}
3333
}
34+
35+
.char-count {
36+
@include roboto-regular;
37+
38+
position: absolute;
39+
right: 0;
40+
top: 10px;
41+
font-size: 11px;
42+
padding-right: 5px;
43+
}
44+
45+
.grey {
46+
color: $tc-gray-40;
47+
}

src/shared/components/Settings/ProfileSettings/AboutYou/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const AboutYou = (props) => {
3838
</FormField>
3939

4040
{/* Primary interests */}
41-
<FormField label="Short bio">
41+
<FormField label="Short bio" isTextarea>
4242
<FormInputTextArea
4343
disabled={!canModifyTrait}
4444
id="description"

src/shared/components/Settings/style.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,6 @@ $checkbox-bg-selected: $tc-dark-blue;
300300
text-transform: none;
301301
}
302302

303-
.char-count {
304-
float: right;
305-
font-size: 11px;
306-
padding-right: 5px;
307-
}
308-
309303
.grey {
310304
color: $tc-gray-40;
311305
}

0 commit comments

Comments
 (0)