Skip to content

Commit 27fe991

Browse files
feat(text-input): add design qa changes
1 parent b45f920 commit 27fe991

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

packages/components/src/field/field-message.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77

88
[data-sl-field-message-text] {
9-
color: var(--sl-fg);
9+
color: var(--sl-fg-soft);
1010
font: var(--sl-text-caption-2-font);
1111
letter-spacing: var(--sl-text-caption-2-letter-spacing);
1212
}

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

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

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

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

33
import { TextInput } from '../index'
44
import { Stack } from '../../stack'
5+
import { Tooltip } from '../../tooltip'
6+
import { IconQuestion } from '@vtex/shoreline-icons'
57

68
export default {
79
title: 'shoreline-components/text-input',
@@ -28,6 +30,24 @@ export function All() {
2830
error
2931
/>
3032
<TextInput label="Label" helpText="This is an input" />
33+
<TextInput
34+
label="Label"
35+
disabled
36+
helpText="This is an input"
37+
value="Text input value"
38+
/>
39+
<TextInput
40+
label={
41+
<Stack direction="row" space="$space-1">
42+
<span>Label</span>
43+
<Tooltip text="Tooltip text">
44+
<IconQuestion width={16} height={16} />
45+
</Tooltip>
46+
</Stack>
47+
}
48+
helpText="This is an input"
49+
/>
50+
<TextInput label="Label" optional helpText="This is an input" />
3151
</Stack>
3252
)
3353
}

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'
@@ -15,6 +15,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
1515
label,
1616
helpText,
1717
errorText,
18+
optional,
1819
id: defaultId,
1920
...inputProps
2021
} = props
@@ -23,7 +24,9 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
2324

2425
return (
2526
<Field data-sl-text-input className={className}>
26-
<FieldLabel htmlFor={id}>{label}</FieldLabel>
27+
<FieldLabel htmlFor={id} optional={optional}>
28+
{label}
29+
</FieldLabel>
2730
<div
2831
data-sl-text-input-container
2932
data-disabled={disabled}
@@ -39,6 +42,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
3942
id={id}
4043
ref={ref}
4144
disabled={disabled}
45+
aria-required={optional}
4246
{...inputProps}
4347
/>
4448
{suffix && (
@@ -73,7 +77,8 @@ export interface TextInputProps
7377
Node added before input space
7478
*/
7579
suffix?: React.ReactNode
76-
label: string
80+
label: ReactNode
7781
errorText?: string
7882
helpText?: string
83+
optional?: boolean
7984
}

0 commit comments

Comments
 (0)