Skip to content

Commit

Permalink
Merge pull request #1278 from vtex/feat/text-input-qa
Browse files Browse the repository at this point in the history
TextInput: Design QA
  • Loading branch information
lucasaarcoverde authored Nov 24, 2023
2 parents 28496cc + 27fe991 commit 187d902
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
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
20 changes: 20 additions & 0 deletions packages/components/src/text-input/stories/text-input.stories.tsx
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
}

1 comment on commit 187d902

@vercel
Copy link

@vercel vercel bot commented on 187d902 Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shoreline-docs – ./packages/next-docs

pvt-shoreline.vercel.app
shoreline-docs-admin-team.vercel.app
shoreline-docs-git-main-admin-team.vercel.app

Please sign in to comment.