Skip to content

Commit

Permalink
fix: Moving FormField as a organism-level component
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasOmar committed Jan 19, 2024
1 parent 5b122f1 commit cc70d6f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 26 deletions.
1 change: 0 additions & 1 deletion src/components/molecules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export { default as Pagination } from './Pagination'
export { default as Modal } from './Modal'
export { default as Tabs } from './Tabs'
export { default as InputControl } from './InputControl'
export { default as FormField } from './FormField'
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { InputControlProps } from '../../../interfaces/moleculeProps'
import { createObjArray } from '../../../functions/parsers'
// MOCKS
import { storybook, testing } from './index.mocks.json'
import inputControlMocks from '../InputControl/index.mocks.json'
import inputControlMocks from '../../molecules/InputControl/index.mocks.json'

const { baseConfig } = inputControlMocks.testing

export default {
title: 'Molecules/FormField',
title: 'Organisms/FormField',
component: FormField,
...storybook,
args: { inputControlConfig: baseConfig }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { createObjArray } from '../../../functions/parsers'
// MOCKS
import { testing } from './index.mocks.json'
import inputControlMocks from '../InputControl/index.mocks.json'
import inputControlMocks from '../../molecules/InputControl/index.mocks.json'

describe('FormField', () => {
const { baseConfig } = inputControlMocks.testing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
// COMPONENTS
import InputControl from '../InputControl'
import InputControl from '../../molecules/InputControl'
// TYPES & INTERFACES
import { InputControlProps } from '../../../interfaces/moleculeProps'
import {
FormFieldHelperProps,
FormFieldProps,
InputControlProps
} from '../../../interfaces/moleculeProps'
FormFieldProps
} from '../../../interfaces/organismsProps'
// PARSERS
import { parseClasses, parseKey, parseTestId } from '../../../functions/parsers'

Expand Down
1 change: 1 addition & 0 deletions src/components/organisms/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as FormField } from './FormField'
18 changes: 0 additions & 18 deletions src/interfaces/moleculeProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,3 @@ export interface InputControlProps extends ElementProps {
/** `Styling` Used for `FormField` styling purpose only. Will strech the input and its container in full-width */
isExpanded?: boolean
}

export interface FormFieldHelperProps {
text?: string
color?: basicColorType
}

export interface FormFieldProps extends ElementProps {
/** `Attribute` Sets a custom text before the wrapped input to indicate its usage */
labelText?: string
/** `Attribute` `Required` Single or multiple `InputControlProps` config objects which will be wrapped around the `FormField` */
inputControlConfig: InputControlProps | InputControlProps[]
/** `Attribute` Adds a helper text below the wrapped paragraph to provide context information */
helperConfig?: FormFieldHelperProps
/** `Styling` Will adjust field's sections (label, input/s and helper) in horizontal position */
isHorizontal?: boolean
/** `Styling` Will group the list of inputs in a same wrapper (useful for several inputs with same usage, as a complex address) */
isGrouped?: boolean
}
24 changes: 24 additions & 0 deletions src/interfaces/organismsProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// COMMON PROPS
import { ElementProps } from './commonProps'
// COMPONENT PROPS
import { InputControlProps } from './moleculeProps'
// TYPES & INTERFACES
import { basicColorType } from '../types/styleTypes'

export interface FormFieldHelperProps {
text?: string
color?: basicColorType
}

export interface FormFieldProps extends ElementProps {
/** `Attribute` Sets a custom text before the wrapped input to indicate its usage */
labelText?: string
/** `Attribute` `Required` Single or multiple `InputControlProps` config objects which will be wrapped around the `FormField` */
inputControlConfig: InputControlProps | InputControlProps[]
/** `Attribute` Adds a helper text below the wrapped paragraph to provide context information */
helperConfig?: FormFieldHelperProps
/** `Styling` Will adjust field's sections (label, input/s and helper) in horizontal position */
isHorizontal?: boolean
/** `Styling` Will group the list of inputs in a same wrapper (useful for several inputs with same usage, as a complex address) */
isGrouped?: boolean
}

0 comments on commit cc70d6f

Please sign in to comment.