Skip to content

Commit

Permalink
feat(TextInput): Update TextInput to use data attributes for styling (#…
Browse files Browse the repository at this point in the history
…5242)

* chore(TextInput): Update TextInput to use data attributes for styling

* remove variant functions

* add data attrs

* update jest snapshots

* changeset

* add width to block

* add higher specificity to passing in sx

* update snapshots

* revert success border color
  • Loading branch information
hussam-i-am authored Nov 8, 2024
1 parent dce754b commit 706d272
Show file tree
Hide file tree
Showing 8 changed files with 9,221 additions and 2,732 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-fans-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Convert TextInput to use data attributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Token from '../Token/Token'
import type {TokenSizeKeys} from '../Token/TokenBase'

import type {TextInputSizes} from '../internal/components/TextInputWrapper'
import TextInputWrapper, {textInputHorizPadding} from '../internal/components/TextInputWrapper'
import TextInputWrapper from '../internal/components/TextInputWrapper'
import UnstyledTextInput from '../internal/components/UnstyledTextInput'
import TextInputInnerVisualSlot from '../internal/components/TextInputInnerVisualSlot'

Expand Down Expand Up @@ -266,8 +266,8 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
variant={variantProp} // deprecated. use `size` prop instead
onClick={focusInput}
sx={{
paddingLeft: textInputHorizPadding,
py: `calc(${textInputHorizPadding} / 2)`,
paddingLeft: '12px',
py: `calc(12px / 2)`,
...(block
? {
display: 'flex',
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/__tests__/Textarea.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ describe('Textarea', () => {
width: '100%',
display: 'flex',
}
const defaultStyles = renderStyles(<Textarea block />)
const blockStyles = renderStyles(<Textarea />)
const defaultStyles = renderStyles(<Textarea />)
const blockStyles = renderStyles(<Textarea block />)

expect(defaultStyles).toEqual(expect.objectContaining(expectedStyles))
expect(blockStyles).not.toEqual(expect.objectContaining(expectedStyles))
expect(defaultStyles).not.toEqual(expect.objectContaining(expectedStyles))
expect(blockStyles).toEqual(expect.objectContaining(expectedStyles))
})

it('renders default resize values correctly', () => {
Expand Down
Loading

0 comments on commit 706d272

Please sign in to comment.