Skip to content

Commit 7ba2345

Browse files
feat: Add tooltip with text area (#535)
1 parent 6c3a2b9 commit 7ba2345

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/components/TextAreaField/TextAreaField.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
font-family: var(--font-family);
1010
color: var(--secondary-text);
1111
display: flex;
12+
align-items: center;
13+
}
14+
15+
.dcl.text-area > .title > .dui-info-tooltip__trigger {
16+
margin-left: 7px;
1217
}
1318

1419
.dcl.text-area > .title > .maxLength {

src/components/TextAreaField/TextAreaField.stories.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ storiesOf('TextArea', module)
2828
cols="50"
2929
/>
3030
))
31+
.add('With tooltip', () => (
32+
<TextAreaField
33+
value={textAreaValue}
34+
label="Description"
35+
rows="10"
36+
cols="50"
37+
maxLength={300}
38+
tooltip={{
39+
content: 'This is a tooltip',
40+
position: 'top center'
41+
}}
42+
/>
43+
))
3144
.add('Without label and max length', () => (
3245
<TextAreaField maxLength={300} value={textAreaValue} rows="10" cols="50" />
3346
))

src/components/TextAreaField/TextAreaField.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import TextArea, {
55
} from 'semantic-ui-react/dist/commonjs/addons/TextArea/TextArea'
66
import Icon from 'semantic-ui-react/dist/commonjs/elements/Icon/Icon'
77
import { getInputValueLength } from '../../lib/input'
8+
import { InfoTooltip, InfoTooltipProps } from '../InfoTooltip'
89
import './TextAreaField.css'
910

1011
export type TextAreaFieldProps = TextAreaProps & {
@@ -13,6 +14,7 @@ export type TextAreaFieldProps = TextAreaProps & {
1314
error?: string
1415
warning?: string
1516
info?: string
17+
tooltip?: InfoTooltipProps
1618
}
1719

1820
function renderMessage(props: TextAreaFieldProps) {
@@ -58,6 +60,9 @@ export const TextAreaField = (props: TextAreaFieldProps): JSX.Element => {
5860
{props.label || props.maxLength !== undefined ? (
5961
<div className="title">
6062
{props.label ? <label>{props.label}</label> : null}
63+
{props.label && props.tooltip ? (
64+
<InfoTooltip {...props.tooltip} />
65+
) : null}
6166
{props.maxLength ? (
6267
<span className="maxLength">
6368
{getInputValueLength(props.value)}/{props.maxLength}

0 commit comments

Comments
 (0)