-
Notifications
You must be signed in to change notification settings - Fork 645
Fix: TextInput styling regression with icon and block prop usage #1592
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cb23223
fix: styling update textinput component with leading icon and block p…
rezrah a18c01e
add changeset
rezrah 5f44ebb
revert eslint rule change
rezrah a511b2d
reverting eslint rule again
rezrah 2c6b139
refactor with simpler solution
rezrah acb87de
Merge branch 'main' into bugfix/fix-textinput-icon-with-block-prop
rezrah 9ea076f
Merge branch 'main' into bugfix/fix-textinput-icon-with-block-prop
rezrah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@primer/components': patch | ||
| --- | ||
|
|
||
| Fixes a styling bug in TextInput components while using its `icon` and `block` props together |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import React, {useState, ReactNode} from 'react' | ||
| import {Meta} from '@storybook/react' | ||
|
|
||
| import {BaseStyles, Box, ThemeProvider, Text} from '..' | ||
| import TextInput, {TextInputProps} from '../TextInput' | ||
| import {CheckIcon} from '@primer/octicons-react' | ||
|
|
||
| export default { | ||
| title: 'Forms/Text Input', | ||
| component: TextInput, | ||
| decorators: [ | ||
| Story => { | ||
| return ( | ||
| <ThemeProvider> | ||
| <BaseStyles> | ||
| <Box paddingTop={5}>{Story()}</Box> | ||
| </BaseStyles> | ||
| </ThemeProvider> | ||
| ) | ||
| } | ||
| ], | ||
| argTypes: { | ||
| sx: { | ||
| table: { | ||
| disable: true | ||
| } | ||
| }, | ||
| block: { | ||
| name: 'Block', | ||
| defaultValue: false, | ||
| control: { | ||
| type: 'boolean' | ||
| } | ||
| }, | ||
| disabled: { | ||
| name: 'Disabled', | ||
| defaultValue: false, | ||
| control: { | ||
| type: 'boolean' | ||
| } | ||
| }, | ||
| variant: { | ||
| name: 'Variants', | ||
| options: ['small', 'medium', 'large'], | ||
| control: {type: 'radio'} | ||
| } | ||
| } | ||
| } as Meta | ||
|
|
||
| const Label = ({htmlFor, children}: {htmlFor: string; children: ReactNode}) => ( | ||
| <Text as="label" htmlFor={htmlFor} sx={{fontWeight: 600, fontSize: 14}}> | ||
| {children} | ||
| </Text> | ||
| ) | ||
|
|
||
| export const Default = (args: TextInputProps) => { | ||
| const [value, setValue] = useState('') | ||
|
|
||
| const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
| setValue(event.target.value) | ||
| } | ||
|
|
||
| const inputId = 'basic-text-input' | ||
|
|
||
| return ( | ||
| <form> | ||
| <div className="form-group"> | ||
| <div className="form-group-header"> | ||
| <Label htmlFor={inputId}>Example label</Label> | ||
| </div> | ||
| <div className="form-group-body"> | ||
| <TextInput id={inputId} value={value} onChange={handleChange} {...args} /> | ||
| </div> | ||
| </div> | ||
| </form> | ||
| ) | ||
| } | ||
|
|
||
| export const WithLeadingIcon = (args: TextInputProps) => { | ||
| const [value, setValue] = useState('') | ||
|
|
||
| const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
| setValue(event.target.value) | ||
| } | ||
|
|
||
| const inputId = 'basic-text-input-with-leading-icon' | ||
|
|
||
| return ( | ||
| <form> | ||
| <Label htmlFor={inputId}>Example label</Label> | ||
| <br /> | ||
| <TextInput icon={CheckIcon} id={inputId} value={value} onChange={handleChange} type="password" {...args} /> | ||
| </form> | ||
| ) | ||
| } | ||
|
|
||
| export const Password = (args: TextInputProps) => { | ||
| const [value, setValue] = useState('') | ||
|
|
||
| const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
| setValue(event.target.value) | ||
| } | ||
|
|
||
| const inputId = 'basic-text-input-as-password' | ||
|
|
||
| return ( | ||
| <form> | ||
| <Label htmlFor={inputId}>Password</Label> | ||
| <br /> | ||
| <TextInput type="password" id={inputId} value={value} onChange={handleChange} {...args} /> | ||
| </form> | ||
| ) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition!