Skip to content

Commit

Permalink
feat: Add tooltip with text area (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed May 3, 2024
1 parent 6c3a2b9 commit 7ba2345
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/TextAreaField/TextAreaField.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
font-family: var(--font-family);
color: var(--secondary-text);
display: flex;
align-items: center;
}

.dcl.text-area > .title > .dui-info-tooltip__trigger {
margin-left: 7px;
}

.dcl.text-area > .title > .maxLength {
Expand Down
13 changes: 13 additions & 0 deletions src/components/TextAreaField/TextAreaField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ storiesOf('TextArea', module)
cols="50"
/>
))
.add('With tooltip', () => (
<TextAreaField
value={textAreaValue}
label="Description"
rows="10"
cols="50"
maxLength={300}
tooltip={{
content: 'This is a tooltip',
position: 'top center'
}}
/>
))
.add('Without label and max length', () => (
<TextAreaField maxLength={300} value={textAreaValue} rows="10" cols="50" />
))
Expand Down
5 changes: 5 additions & 0 deletions src/components/TextAreaField/TextAreaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TextArea, {
} from 'semantic-ui-react/dist/commonjs/addons/TextArea/TextArea'
import Icon from 'semantic-ui-react/dist/commonjs/elements/Icon/Icon'
import { getInputValueLength } from '../../lib/input'
import { InfoTooltip, InfoTooltipProps } from '../InfoTooltip'
import './TextAreaField.css'

export type TextAreaFieldProps = TextAreaProps & {
Expand All @@ -13,6 +14,7 @@ export type TextAreaFieldProps = TextAreaProps & {
error?: string
warning?: string
info?: string
tooltip?: InfoTooltipProps
}

function renderMessage(props: TextAreaFieldProps) {
Expand Down Expand Up @@ -58,6 +60,9 @@ export const TextAreaField = (props: TextAreaFieldProps): JSX.Element => {
{props.label || props.maxLength !== undefined ? (
<div className="title">
{props.label ? <label>{props.label}</label> : null}
{props.label && props.tooltip ? (
<InfoTooltip {...props.tooltip} />
) : null}
{props.maxLength ? (
<span className="maxLength">
{getInputValueLength(props.value)}/{props.maxLength}
Expand Down

0 comments on commit 7ba2345

Please sign in to comment.