Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
5bb9999
feat(TextInput): Convert TextInput to CSS module behind feature flag
hussam-i-am Nov 4, 2024
2faab3f
lint fixes
hussam-i-am Nov 4, 2024
7e146e5
update snapshots and fix spinner
hussam-i-am Nov 4, 2024
83ed14e
stylelint fix
hussam-i-am Nov 4, 2024
76852c8
changeset
hussam-i-am Nov 4, 2024
87d76af
Update wrappers to use css modules
hussam-i-am Nov 5, 2024
4c63933
lint fixes
hussam-i-am Nov 6, 2024
669d8f9
chore(TextInput): Update TextInput to use data attributes for styling
hussam-i-am Nov 6, 2024
19d0b08
remove variant functions
hussam-i-am Nov 6, 2024
51aed91
add data attrs
hussam-i-am Nov 6, 2024
b475780
Merge branch 'main' of https://github.com/primer/react into hussam-i-…
hussam-i-am Nov 6, 2024
e3617ee
update jest snapshots
hussam-i-am Nov 6, 2024
6a241ce
changeset
hussam-i-am Nov 6, 2024
6db3a71
add width to block
hussam-i-am Nov 6, 2024
189a565
add higher specificity to passing in sx
hussam-i-am Nov 6, 2024
e902102
update snapshots
hussam-i-am Nov 6, 2024
d99cd58
revert success border color
hussam-i-am Nov 7, 2024
e9bb09c
Merge branch 'hussam-i-am/text-input-data-attrs' of https://github.co…
hussam-i-am Nov 7, 2024
16767c2
Merge https://github.com/primer/react into css-moduled-text-input
hussam-i-am Nov 7, 2024
d24b82a
rework width props
hussam-i-am Nov 7, 2024
7d8cadb
revert Spinner changes
hussam-i-am Nov 7, 2024
0a463f2
Merge branch 'main' into hussam-i-am/text-input-data-attrs
hussam-i-am Nov 7, 2024
6724911
css fix
hussam-i-am Nov 7, 2024
9c4126e
Merge branch 'hussam-i-am/text-input-data-attrs' of https://github.co…
hussam-i-am Nov 7, 2024
f823dd4
type fix and ass missing styles
hussam-i-am Nov 7, 2024
4764e21
update TextInputWithTokens
hussam-i-am Nov 7, 2024
fef5246
Merge branch 'main' into hussam-i-am/text-input-data-attrs
hussam-i-am Nov 7, 2024
6d4a049
Merge branch 'hussam-i-am/text-input-data-attrs' of https://github.co…
hussam-i-am Nov 7, 2024
05973c0
Merge branch 'main' into hussam-i-am/text-input-data-attrs
hussam-i-am Nov 7, 2024
93addc2
fix padding for small
hussam-i-am Nov 8, 2024
d5fe194
use useMemo
hussam-i-am Nov 8, 2024
779c1f3
Merge branch 'main' into hussam-i-am/text-input-data-attrs
hussam-i-am Nov 8, 2024
fee7dc3
fix test
hussam-i-am Nov 8, 2024
b8158dd
Merge branch 'hussam-i-am/text-input-data-attrs' of https://github.co…
hussam-i-am Nov 8, 2024
d4fdc87
Fix unstyled story
hussam-i-am Nov 8, 2024
275eed8
readd fallback css variable
hussam-i-am Nov 8, 2024
e7d5efa
Fix placeholder
hussam-i-am Nov 8, 2024
7e74223
feat(TextInput): Remove width props from TextInput
hussam-i-am Nov 8, 2024
1958184
type fixes
hussam-i-am Nov 8, 2024
8a1443e
Merge branch 'main' of https://github.com/primer/react into css-modul…
hussam-i-am Nov 8, 2024
de2b18f
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 8, 2024
bbac544
Revert "Revert "feat(TextInput): Update TextInput to use data attribu…
hussam-i-am Nov 8, 2024
95c0827
Merge branch 'main' of https://github.com/primer/react into hussam-i-…
hussam-i-am Nov 8, 2024
a2fd736
lint fix
hussam-i-am Nov 8, 2024
5d36dd7
Merge branch 'hussam-i-am/remove-textinput-width-props' of https://gi…
hussam-i-am Nov 8, 2024
f64022b
remove unused imports
hussam-i-am Nov 8, 2024
66aa372
Merge branch 'hussam-i-am/remove-textinput-width-props' of https://gi…
hussam-i-am Nov 9, 2024
40ab2b3
fix type error and add test
hussam-i-am Nov 9, 2024
75a2a67
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 12, 2024
50e4f49
Merge branch 'hussam-i-am/remove-textinput-width-props' into revert-5…
hussam-i-am Nov 12, 2024
4c64a6c
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 12, 2024
c20c57a
Merge branch 'hussam-i-am/remove-textinput-width-props' into revert-5…
hussam-i-am Nov 12, 2024
21c4f47
Merge branch 'main' of https://github.com/primer/react into css-modul…
hussam-i-am Nov 13, 2024
4ab0f54
updated snapshots
hussam-i-am Nov 13, 2024
c1a8696
Merge branch 'revert-5256-revert-5242-hussam-i-am/text-input-data-att…
hussam-i-am Nov 13, 2024
5083cc8
merge conflicts
hussam-i-am Nov 13, 2024
617ace9
fix tests
hussam-i-am Nov 13, 2024
ca14ee3
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 13, 2024
8086ba0
Merge branch 'hussam-i-am/remove-textinput-width-props' into revert-5…
hussam-i-am Nov 13, 2024
e2f88db
Merge branch 'revert-5256-revert-5242-hussam-i-am/text-input-data-att…
hussam-i-am Nov 13, 2024
311ddce
fix type
hussam-i-am Nov 13, 2024
589ebb2
Update type to include children
hussam-i-am Nov 13, 2024
a97371d
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 13, 2024
abd6c29
Merge branch 'hussam-i-am/remove-textinput-width-props' into revert-5…
hussam-i-am Nov 13, 2024
1eb3018
Merge branch 'revert-5256-revert-5242-hussam-i-am/text-input-data-att…
hussam-i-am Nov 13, 2024
7a9493b
Update to deprecate props
hussam-i-am Nov 13, 2024
9e4a9e5
Merge branch 'hussam-i-am/remove-textinput-width-props' of https://gi…
hussam-i-am Nov 13, 2024
a1c0433
Fix media styling
hussam-i-am Nov 13, 2024
8915312
revert back to get
hussam-i-am Nov 13, 2024
29464fd
revert more gets
hussam-i-am Nov 13, 2024
d7deba0
Properly mark props as deprecated
hussam-i-am Nov 13, 2024
ae9748b
Merge branch 'hussam-i-am/remove-textinput-width-props' of https://gi…
hussam-i-am Nov 13, 2024
4e51a6b
Merge branch 'main' of https://github.com/primer/react into revert-52…
hussam-i-am Nov 13, 2024
5c114a6
Merge branch 'revert-5256-revert-5242-hussam-i-am/text-input-data-att…
hussam-i-am Nov 13, 2024
ca150ee
Update width prop
hussam-i-am Nov 13, 2024
4a2338a
revert action and slot conversion
hussam-i-am Nov 13, 2024
102d7ba
Merge branch 'main' of https://github.com/primer/react into css-modul…
hussam-i-am Nov 14, 2024
96c2dc4
snapshot
hussam-i-am Nov 14, 2024
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/dry-seals-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Convert TextInput to CSS module behind feature flag
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
.TextInputWrapper {
padding-top: var(--base-size-6);
padding-bottom: var(--base-size-6);
padding-left: var(--base-size-12);

&:where([data-block]) {
display: flex;
width: 100%;
}

&:where([data-token-wrapping]) {
overflow: auto;
}
}

.UnstyledTextInput {
height: 100%;
}
72 changes: 45 additions & 27 deletions packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import TextInputWrapper from '../internal/components/TextInputWrapper'
import UnstyledTextInput, {TEXT_INPUT_CSS_MODULES_FEATURE_FLAG} from '../internal/components/UnstyledTextInput'
import TextInputInnerVisualSlot from '../internal/components/TextInputInnerVisualSlot'
import {useFeatureFlag} from '../FeatureFlags'

import styles from './TextInputWithTokens.module.css'
import {clsx} from 'clsx'
import type {BetterSystemStyleObject} from '../sx'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type AnyReactComponent = React.ComponentType<React.PropsWithChildren<any>>
Expand Down Expand Up @@ -96,6 +97,7 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
validationStatus,
variant: variantProp, // deprecated. use `size` instead
visibleTokenCount,
style,
...rest
}: TextInputWithTokensProps<TokenComponentType | typeof Token>,
forwardedRef: React.ForwardedRef<HTMLInputElement>,
Expand Down Expand Up @@ -255,10 +257,49 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo

const enabled = useFeatureFlag(TEXT_INPUT_CSS_MODULES_FEATURE_FLAG)

const stylingProps = React.useMemo(
() =>
enabled
? {
className: clsx(className, styles.TextInputWrapper),
style: maxHeight ? {maxHeight, ...style} : style,
sx: sxProp,
}
: {
className,
style,
sx: {
paddingLeft: '12px',
py: '6px',
...(block
? {
display: 'flex',
width: '100%',
}
: {}),

...(maxHeight
? {
maxHeight,
overflow: 'auto',
}
: {}),

...(preventTokenWrapping
? {
overflow: 'auto',
}
: {}),

...sxProp,
} as BetterSystemStyleObject,
},
[block, className, enabled, maxHeight, preventTokenWrapping, style, sxProp],
)

return (
<TextInputWrapper
block={block}
className={className}
contrast={contrast}
disabled={disabled}
hasLeadingVisual={Boolean(LeadingVisual || showLeadingLoadingIndicator)}
Expand All @@ -270,31 +311,8 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
validationStatus={validationStatus}
variant={variantProp} // deprecated. use `size` prop instead
onClick={focusInput}
sx={{
paddingLeft: '12px',
py: `calc(12px / 2)`,
...(block
? {
display: 'flex',
width: '100%',
}
: {}),

...(maxHeight
? {
maxHeight,
overflow: 'auto',
}
: {}),

...(preventTokenWrapping
? {
overflow: 'auto',
}
: {}),

...sxProp,
}}
data-token-wrapping={Boolean(preventTokenWrapping || maxHeight) || undefined}
{...stylingProps}
>
{IconComponent && !LeadingVisual && <IconComponent className="TextInput-icon" />}
<TextInputInnerVisualSlot
Expand Down
Loading
Loading