Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/silly-parks-give.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need for a changeset here since the change hasn't been released yet if that's helpful!

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Do we still need it to kick off the Canary release that's necessary for integration tests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nope! You should be good. I think the workflow will force a "fake" changeset so that it always publishes something if I remember right

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Adds `sx` prop back to TextInput
36 changes: 36 additions & 0 deletions e2e/components/TextInput.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -219,6 +219,24 @@ test.describe('TextInput', () => {
}
})

test.describe('Dev: With Sx', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-textinput-dev--with-sx',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`TextInput.Dev.WithSx.${theme}.png`)
})
})
}
})

test.describe('Dev: With CSS', () => {
for (const theme of themes) {
test.describe(theme, () => {
Expand All@@ -236,4 +254,22 @@ test.describe('TextInput', () => {
})
}
})

test.describe('Dev: With Sx and CSS', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-textinput-dev--with-sx-and-css',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`TextInput.Dev.WithSxAndCSS.${theme}.png`)
})
})
}
})
})
9 changes: 4 additions & 5 deletions packages/react/src/SelectPanel/SelectPanel.module.css
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,11 +52,6 @@
color: var(--fgColor-muted);
}

.FilterInputWrapper {
margin: var(--base-size-8);
width: auto;
}

.Notice {
margin-top: var(--base-size-4);
margin-right: var(--base-size-8);
Expand DownExpand Up@@ -235,3 +230,7 @@
inset: 0;
background-color: var(--overlay-backdrop-bgColor);
}

.TextInput {
margin: var(--base-size-8);
}
2 changes: 1 addition & 1 deletion packages/react/src/SelectPanel/SelectPanel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -648,7 +648,7 @@ function Panel({

const extendedTextInputProps: Partial<TextInputProps> = useMemo(() => {
return {
className: classes.FilterInputWrapper,
className: classes.TextInput,
contrast: true,
leadingVisual: SearchIcon,
'aria-label': inputLabel,
Expand Down
18 changes: 18 additions & 0 deletions packages/react/src/TextInput/TextInput.dev.stories.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,3 +18,21 @@ export const WithCSS = () => (
</FormControl>
</form>
)

export const WithSx = () => (
<form>
<FormControl>
<FormControl.Label>Default label</FormControl.Label>
<TextInput sx={{borderColor: 'red'}} />
</FormControl>
</form>
)

export const WithSxAndCSS = () => (
<form>
<FormControl>
<FormControl.Label>Default label</FormControl.Label>
<TextInput sx={{borderColor: 'red'}} className="testCustomClassnameBorderColor" />
</FormControl>
</form>
)
21 changes: 21 additions & 0 deletions packages/react/src/TextInput/TextInput.docs.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,6 +140,27 @@
"deprecated": true,
"description": "(Use size) Creates a smaller or larger input than the default."
},
{
"name": "width",
"type": "string | number | Array<string | number>",
"defaultValue": "",
"deprecated": true,
"description": "(Use sx prop) Set the width of the input"
},
{
"name": "maxWidth",
"type": "string | number | Array<string | number>",
"defaultValue": "",
"deprecated": true,
"description": "(Use sx prop) Set the maximum width of the input"
},
{
"name": "minWidth",
"type": "string | number | Array<string | number>",
"defaultValue": "",
"deprecated": true,
"description": "(Use sx prop) Set the minimum width of the input"
},
{
"name": "icon",
"type": "React.ComponentType",
Expand Down
23 changes: 22 additions & 1 deletion packages/react/src/TextInput/TextInput.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,7 +40,20 @@ export type TextInputNonPassthroughProps = {
*/
trailingAction?: React.ReactElement<React.HTMLProps<HTMLButtonElement>>
} & Partial<
Pick<StyledWrapperProps, 'block' | 'contrast' | 'disabled' | 'monospace' | 'variant' | 'size' | 'validationStatus'>
Pick<
StyledWrapperProps,
| 'block'
| 'contrast'
| 'disabled'
| 'monospace'
| 'sx'
| 'width'
| 'maxWidth'
| 'minWidth'
| 'variant'
| 'size'
| 'validationStatus'
>
>

export type TextInputProps = Merge<React.ComponentPropsWithoutRef<'input'>, TextInputNonPassthroughProps>
Expand All@@ -62,10 +75,14 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
loaderText = 'Loading',
monospace,
validationStatus,
sx: sxProp,
size: sizeProp,
onFocus,
onBlur,
// start deprecated props
width: widthProp,
minWidth: minWidthProp,
maxWidth: maxWidthProp,
variant: variantProp,
// end deprecated props
type = 'text',
Expand DownExpand Up@@ -120,7 +137,11 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
contrast={contrast}
disabled={disabled}
monospace={monospace}
sx={sxProp}
size={sizeProp}
width={widthProp}
minWidth={minWidthProp}
maxWidth={maxWidthProp}
variant={variantProp}
hasLeadingVisual={Boolean(LeadingVisual || showLeadingLoadingIndicator)}
hasTrailingVisual={Boolean(TrailingVisual || showTrailingLoadingIndicator)}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,13 +83,17 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
className,
block,
disabled,
sx: sxProp,
tokens,
onTokenRemove,
tokenComponent: TokenComponent = Token,
preventTokenWrapping = false,
size = 'xlarge',
hideTokenRemoveButtons = false,
maxHeight,
width: widthProp,
minWidth: minWidthProp,
maxWidth: maxWidthProp,
validationStatus,
variant: variantProp, // deprecated. use `size` instead
visibleTokenCount,
Expand DownExpand Up@@ -258,13 +262,17 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
disabled={disabled}
hasLeadingVisual={Boolean(LeadingVisual || showLeadingLoadingIndicator)}
hasTrailingVisual={Boolean(TrailingVisual || showTrailingLoadingIndicator)}
width={widthProp}
minWidth={minWidthProp}
maxWidth={maxWidthProp}
size={inputSizeMap[size]}
validationStatus={validationStatus}
variant={variantProp} // deprecated. use `size` prop instead
onClick={focusInput}
data-token-wrapping={Boolean(preventTokenWrapping || maxHeight) || undefined}
className={clsx(className, styles.TextInputWrapper)}
style={maxHeight ? {maxHeight, ...style} : style}
sx={sxProp}
>
{IconComponent && !LeadingVisual && <IconComponent className="TextInput-icon" />}
<TextInputInnerVisualSlot
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/Textarea/Textarea.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type {TextareaHTMLAttributes, ReactElement} from 'react'
import React from 'react'
import {TextInputBaseWrapper} from '../internal/components/TextInputWrapper'
import type {FormValidationStatus} from '../utils/types/FormValidationStatus'
import type {SxProp} from '../sx'
import classes from './TextArea.module.css'

export const DEFAULT_TEXTAREA_ROWS = 7
Expand DownExpand Up@@ -45,7 +46,8 @@ export type TextareaProps = {
* CSS styles to apply to the Textarea
*/
style?: React.CSSProperties
} & TextareaHTMLAttributes<HTMLTextAreaElement>
} & TextareaHTMLAttributes<HTMLTextAreaElement> &
SxProp

/**
* An accessible, native textarea component that supports validation states.
Expand All@@ -56,6 +58,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
{
value,
disabled,
sx: sxProp,
required,
validationStatus,
rows = DEFAULT_TEXTAREA_ROWS,
Expand All@@ -73,6 +76,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
): ReactElement => {
return (
<TextInputBaseWrapper
sx={sxProp}
validationStatus={validationStatus}
disabled={disabled}
block={block}
Expand Down
19 changes: 18 additions & 1 deletion packages/react/src/internal/components/TextInputWrapper.tsx
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
import React, {type ComponentProps} from 'react'
import {type ResponsiveValue} from 'styled-system'
import type {SxProp} from '../../sx'
import type {FormValidationStatus} from '../../utils/types/FormValidationStatus'
import {clsx} from 'clsx'

Expand All@@ -22,7 +24,13 @@ type StyledTextInputBaseWrapperProps = {
style?: React.CSSProperties
onClick?: React.MouseEventHandler
children?: React.ReactNode
}
/** @deprecated Update `width` using CSS modules or style. */
width?: string | number | ResponsiveValue<string | number>
/** @deprecated Update `min-width` using CSS modules or style. */
minWidth?: string | number | ResponsiveValue<string | number>
/** @deprecated Update `max-width` using CSS modules or style. */
maxWidth?: string | number | ResponsiveValue<string | number>
} & SxProp

type StyledTextInputWrapperProps = {
hasLeadingVisual?: boolean
Expand All@@ -33,6 +41,7 @@ export const TextInputBaseWrapper = React.forwardRef<HTMLElement, StyledTextInpu
function TextInputBaseWrapper(
{
className,
style,
variant,
size,
isInputFocused,
Expand All@@ -42,6 +51,9 @@ export const TextInputBaseWrapper = React.forwardRef<HTMLElement, StyledTextInpu
contrast,
monospace,
block,
width,
minWidth,
maxWidth,
...restProps
},
forwardRef,
Expand All@@ -60,6 +72,11 @@ export const TextInputBaseWrapper = React.forwardRef<HTMLElement, StyledTextInpu
data-trailing-action={hasTrailingAction || undefined}
data-validation={validationStatus || undefined}
data-variant={variant || undefined}
style={
typeof width === 'string' || typeof minWidth === 'string' || typeof maxWidth === 'string'
? {width, maxWidth, minWidth, ...style}
: style
}
{...restProps}
/>
)
Expand Down
33 changes: 0 additions & 33 deletions packages/styled-react/src/components/Autocomplete.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions packages/styled-react/src/components/Select.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions packages/styled-react/src/components/TextInput.tsx

This file was deleted.

Loading
Loading