Skip to content

Commit

Permalink
remove horizontal form variant
Browse files Browse the repository at this point in the history
  • Loading branch information
vassbence committed Nov 13, 2024
1 parent 8742f15 commit b315983
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 109 deletions.
2 changes: 1 addition & 1 deletion src/components/Form/Form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const Component = () => {
isDirty,
}) => (
<>
<Form.Fields horizontal />
<Form.Fields />
<div
style={{
display: 'flex',
Expand Down
29 changes: 2 additions & 27 deletions src/components/Form/FormField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export default {
component: FormField,
}

export const Vertical = () => {
export const Default = () => {
return (
<FormField label="Label" description="Description text" error="Error text">
<TextInput error onChange={() => {}} />
</FormField>
)
}

export const VerticalNote = () => {
export const WithNote = () => {
return (
<FormField
label="Label"
Expand All @@ -25,28 +25,3 @@ export const VerticalNote = () => {
</FormField>
)
}

export const Horizontal = () => {
return (
<FormField
horizontal
label="Label"
description="Description text"
error="Error text"
>
<TextInput error onChange={() => {}} />
</FormField>
)
}

export const HorizontalNote = () => {
return (
<FormField
horizontal
label="Label"
note={{ title: 'Title', description: 'Description' }}
>
<TextInput error onChange={() => {}} />
</FormField>
)
}
54 changes: 0 additions & 54 deletions src/components/Form/FormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,8 @@ function FormField({
label,
description,
error,
horizontal = false,
note,
}: FormFieldProps) {
if (horizontal) {
return (
<div
style={{
flex: 1,
width: '100%',
display: 'flex',
gap: 16,
minHeight: 36,
}}
>
<div style={{ width: 160, paddingTop: 9.5 }}>
<Text variant="display-regular" color="neutral60">
{label}
</Text>
</div>
<div
style={{
flex: 1,
display: 'flex',
flexDirection: 'column',
gap: 8,
alignItems: 'start',
justifyContent: 'center',
}}
>
{children}
{error && (
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 4,
color: colors.red100,
}}
>
<Icon variant="error-filled" />
<Text color="inherit" variant="display-medium">
{error}
</Text>
</div>
)}
{description && (
<Text variant="display-regular" color="neutral60">
{description}
</Text>
)}
{note && <Note {...note} />}
</div>
</div>
)
}

return (
<div
style={{
Expand Down
24 changes: 0 additions & 24 deletions src/components/Form/FormFieldGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,3 @@ export const Vertical = () => {
</FormFieldGroup>
)
}

export const Horizontal = () => {
return (
<FormFieldGroup label="Group title">
<FormField horizontal label="Label">
<TextInput onChange={() => {}} />
</FormField>
<FormField horizontal label="Label" description="Description text">
<TextInput onChange={() => {}} />
</FormField>
<FormField horizontal label="Label" error="Error text">
<TextInput error onChange={() => {}} />
</FormField>
<FormField
horizontal
label="Label"
description="Description text"
error="Error text"
>
<TextInput error onChange={() => {}} />
</FormField>
</FormFieldGroup>
)
}
4 changes: 1 addition & 3 deletions src/components/Form/FormFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import { RichTextEditor } from '../RichTextEditor/index.js'
import { getByPath, Path } from '@saulx/utils'

type FormFieldsProps = {
horizontal?: boolean
fullScreen?: boolean
}

function FormFields({ horizontal, fullScreen }: FormFieldsProps) {
function FormFields({ fullScreen }: FormFieldsProps) {
const ctx = useContext(FormContext)

if (!ctx) {
Expand All @@ -35,7 +34,6 @@ function FormFields({ horizontal, fullScreen }: FormFieldsProps) {
return (
<FormField
key={path.toString()}
horizontal={horizontal}
label={field.label}
description={field.description}
error={getByPath(form.errors, path)}
Expand Down

0 comments on commit b315983

Please sign in to comment.