Skip to content

Commit d786f3d

Browse files
feat(text-input): add design qa changes
1 parent 234010b commit d786f3d

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

packages/components/src/field/field.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
}
4141

4242
[data-sl-field-message-text] {
43-
color: var(--sl-fg);
43+
color: var(--sl-fg-soft);
4444
font: var(--sl-text-caption-2-font);
4545
letter-spacing: var(--sl-text-caption-2-letter-spacing);
4646
}

packages/components/src/select-field/select-field.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const SelectField = forwardRef<HTMLSelectElement, SelectFieldProps>(
5757
data-disabled={disabled}
5858
aria-invalid={error}
5959
id={id}
60+
aria-required={optional}
6061
{...otherProps}
6162
>
6263
<option value="" disabled>

packages/components/src/text-input/stories/text-input.stories.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import React from 'react'
44

55
import { TextInput } from '../index'
66
import { Stack } from '../../stack'
7+
import { Tooltip } from '../../tooltip'
8+
import { IconQuestion } from '@vtex/shoreline-icons'
79

810
export default {
911
title: 'shoreline-components/text-input',
@@ -30,6 +32,24 @@ export function All() {
3032
error
3133
/>
3234
<TextInput label="Label" helpText="This is an input" />
35+
<TextInput
36+
label="Label"
37+
disabled
38+
helpText="This is an input"
39+
value="Text input value"
40+
/>
41+
<TextInput
42+
label={
43+
<Stack direction="row" space="$space-1">
44+
<span>Label</span>
45+
<Tooltip text="Tooltip text">
46+
<IconQuestion width={16} height={16} />
47+
</Tooltip>
48+
</Stack>
49+
}
50+
helpText="This is an input"
51+
/>
52+
<TextInput label="Label" optional helpText="This is an input" />
3353
</Stack>
3454
)
3555
}

packages/components/src/text-input/text-input.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ComponentPropsWithoutRef } from 'react'
1+
import type { ComponentPropsWithoutRef, ReactNode } from 'react'
22
import React, { forwardRef } from 'react'
33
import { Field, FieldLabel, FieldMessage } from '../field'
44
import { useId } from '@vtex/shoreline-utils'
@@ -14,6 +14,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
1414
label,
1515
helpText,
1616
errorText,
17+
optional,
1718
id: defaultId,
1819
...inputProps
1920
} = props
@@ -22,7 +23,9 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
2223

2324
return (
2425
<Field data-sl-text-input className={className}>
25-
<FieldLabel htmlFor={id}>{label}</FieldLabel>
26+
<FieldLabel htmlFor={id} optional={optional}>
27+
{label}
28+
</FieldLabel>
2629
<div
2730
data-sl-text-input-container
2831
data-disabled={disabled}
@@ -38,6 +41,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
3841
id={id}
3942
ref={ref}
4043
disabled={disabled}
44+
aria-required={optional}
4145
{...inputProps}
4246
/>
4347
{suffix && (
@@ -72,7 +76,8 @@ export interface TextInputProps
7276
Node added before input space
7377
*/
7478
suffix?: React.ReactNode
75-
label: string
79+
label: ReactNode
7680
errorText?: string
7781
helpText?: string
82+
optional?: boolean
7883
}

0 commit comments

Comments
 (0)