Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextInput: Design QA #1278

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/src/field/field-message.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}

[data-sl-field-message-text] {
color: var(--sl-fg);
color: var(--sl-fg-soft);
font: var(--sl-text-caption-2-font);
letter-spacing: var(--sl-text-caption-2-letter-spacing);
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/select-field/select-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const SelectField = forwardRef<HTMLSelectElement, SelectFieldProps>(
data-disabled={disabled}
aria-invalid={error}
id={id}
aria-required={optional}
{...otherProps}
>
<option value="" disabled>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react'

import { TextInput } from '../index'
import { Stack } from '../../stack'
import { Tooltip } from '../../tooltip'
import { IconQuestion } from '@vtex/shoreline-icons'

export default {
title: 'shoreline-components/text-input',
Expand All @@ -28,6 +30,24 @@ export function All() {
error
/>
<TextInput label="Label" helpText="This is an input" />
<TextInput
label="Label"
disabled
helpText="This is an input"
value="Text input value"
/>
<TextInput
label={
<Stack direction="row" space="$space-1">
<span>Label</span>
<Tooltip text="Tooltip text">
<IconQuestion width={16} height={16} />
</Tooltip>
</Stack>
}
helpText="This is an input"
/>
<TextInput label="Label" optional helpText="This is an input" />
</Stack>
)
}
11 changes: 8 additions & 3 deletions packages/components/src/text-input/text-input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentPropsWithoutRef } from 'react'
import type { ComponentPropsWithoutRef, ReactNode } from 'react'
import React, { forwardRef } from 'react'
import { Field, FieldLabel, FieldMessage } from '../field'
import { useId } from '@vtex/shoreline-utils'
Expand All @@ -15,6 +15,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
label,
helpText,
errorText,
optional,
id: defaultId,
...inputProps
} = props
Expand All @@ -23,7 +24,9 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(

return (
<Field data-sl-text-input className={className}>
<FieldLabel htmlFor={id}>{label}</FieldLabel>
<FieldLabel htmlFor={id} optional={optional}>
{label}
</FieldLabel>
<div
data-sl-text-input-container
data-disabled={disabled}
Expand All @@ -39,6 +42,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
id={id}
ref={ref}
disabled={disabled}
aria-required={optional}
{...inputProps}
/>
{suffix && (
Expand Down Expand Up @@ -73,7 +77,8 @@ export interface TextInputProps
Node added before input space
*/
suffix?: React.ReactNode
label: string
label: ReactNode
errorText?: string
helpText?: string
optional?: boolean
}