Skip to content

Commit

Permalink
fix: ensure that input field components are full width by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sjschlapbach committed Jul 19, 2024
1 parent 8c9d0c7 commit e960012
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/forms/NewFormikNumberField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const Default = () => (
name="name"
label="Label"
tooltip="Tooltip for this input"
className={{ root: 'mb-1' }}
className={{ root: 'mb-1 w-80' }}
placeholder="Placeholder"
/>
<Button type="submit">Submit</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/forms/NewFormikNumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function FormikNumberField({

if (name) {
return (
<div className={twMerge('w-80', className?.root)}>
<div className={twMerge('w-full', className?.root)}>
<NumberField
id={id}
value={field.value}
Expand Down Expand Up @@ -117,7 +117,7 @@ export function FormikNumberField({
}

return (
<div className={twMerge('w-80', className?.root)}>
<div className={twMerge('w-full', className?.root)}>
<NumberField
id={id}
value={value!}
Expand Down
2 changes: 1 addition & 1 deletion src/forms/NewFormikTextField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Default = () => (
name="name"
label="Label"
tooltip="Tooltip for this input"
className={{ root: 'mb-1' }}
className={{ root: 'mb-1 w-80' }}
placeholder="Placeholder"
/>
<Button type="submit">Submit</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/forms/NewFormikTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function FormikTextField({

if (name) {
return (
<div className={twMerge('w-80', className?.root)}>
<div className={twMerge('w-full', className?.root)}>
<TextField
id={id}
data={data}
Expand All @@ -115,7 +115,7 @@ export function FormikTextField({
)
} else {
return (
<div className={twMerge('w-80', className?.root)}>
<div className={twMerge('w-full', className?.root)}>
<TextField
id={id}
data={data}
Expand Down
2 changes: 1 addition & 1 deletion src/forms/NewFormikTextareaField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const Default = () => (
name="name"
label="Label"
tooltip="Tooltip for this input"
className={{ root: 'mb-1' }}
className={{ root: 'mb-1 w-96' }}
placeholder="Placeholder"
/>
<Button type="submit">Submit</Button>
Expand Down
6 changes: 5 additions & 1 deletion src/forms/NumberField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export function Default() {
precision (negative and positive) and its value is maintained as a
string.
</div>
<NumberField value={value} onChange={(newValue) => setValue(newValue)} />
<NumberField
value={value}
onChange={(newValue) => setValue(newValue)}
className={{ field: 'w-80' }}
/>
<div>Value: {value}</div>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/forms/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function NumberField({
/>
)}

<div className="flex flex-row items-center gap-2">
<div className="flex w-full flex-row items-center gap-2">
<input
id={id}
data-cy={data?.cy}
Expand Down
4 changes: 3 additions & 1 deletion src/forms/TextField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export const Default = () => {
<TextField
label="Label"
tooltip="Tooltip for this input"
className={{ field: 'mb-1' }}
className={{
field: 'mb-1 w-80',
}}
placeholder="Placeholder"
value={value}
onChange={setValue}
Expand Down
4 changes: 2 additions & 2 deletions src/forms/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export function TextField({
/>
)}

<div className="flex flex-row items-center gap-2">
<div className="relative">
<div className="flex w-full flex-row items-center gap-2">
<div className="relative w-full">
{name && field ? (
<input
{...field}
Expand Down
1 change: 1 addition & 0 deletions src/forms/TextareaField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const Default = () => {
placeholder="Placeholder"
value={value}
onChange={setValue}
className={{ root: 'w-[30rem]' }}
/>
</div>
)
Expand Down
3 changes: 1 addition & 2 deletions src/forms/TextareaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export interface TextareaFieldOnChangeProps extends TextareaFieldProps {
* @param className - The optional className object allows you to override the default styling.
* @returns Text field component with optional label, tooltip, error message and icon.
*/

export function TextareaField({
id,
data,
Expand All @@ -98,7 +97,7 @@ export function TextareaField({
...props
}: TextareaFieldNameProps | TextareaFieldOnChangeProps) {
return (
<div className={twMerge('flex flex-col', className?.root)}>
<div className={twMerge('flex w-full flex-col', className?.root)}>
<div
className={twMerge(
'flex w-full flex-row',
Expand Down

0 comments on commit e960012

Please sign in to comment.