diff --git a/.changeset/hip-ravens-sell.md b/.changeset/hip-ravens-sell.md new file mode 100644 index 00000000000..b5ff9010577 --- /dev/null +++ b/.changeset/hip-ravens-sell.md @@ -0,0 +1,5 @@ +--- +'@primer/components': patch +--- + +Fixes a styling bug in TextInput components while using its `icon` and `block` props together diff --git a/src/_TextInputWrapper.tsx b/src/_TextInputWrapper.tsx index 83822045cb5..fbc4da61e13 100644 --- a/src/_TextInputWrapper.tsx +++ b/src/_TextInputWrapper.tsx @@ -91,6 +91,13 @@ const TextInputWrapper = styled.span` display: block; width: 100%; `} + + ${props => + props.block && + props.hasIcon && + css` + display: flex; + `} // Ensures inputs don't zoom on mobile but are body-font size on desktop @media (min-width: ${get('breakpoints.1')}) { diff --git a/src/stories/TextInput.stories.tsx b/src/stories/TextInput.stories.tsx new file mode 100644 index 00000000000..0d8c9fb8fdc --- /dev/null +++ b/src/stories/TextInput.stories.tsx @@ -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 ( + + + {Story()} + + + ) + } + ], + 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}) => ( + + {children} + +) + +export const Default = (args: TextInputProps) => { + const [value, setValue] = useState('') + + const handleChange = (event: React.ChangeEvent) => { + setValue(event.target.value) + } + + const inputId = 'basic-text-input' + + return ( +
+
+
+ +
+
+ +
+
+
+ ) +} + +export const WithLeadingIcon = (args: TextInputProps) => { + const [value, setValue] = useState('') + + const handleChange = (event: React.ChangeEvent) => { + setValue(event.target.value) + } + + const inputId = 'basic-text-input-with-leading-icon' + + return ( +
+ +
+ + + ) +} + +export const Password = (args: TextInputProps) => { + const [value, setValue] = useState('') + + const handleChange = (event: React.ChangeEvent) => { + setValue(event.target.value) + } + + const inputId = 'basic-text-input-as-password' + + return ( +
+ +
+ + + ) +}