-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1195 from kadena-community/refactor/rename-input-…
…wrapper Refactor/rename input wrapper
- Loading branch information
Showing
31 changed files
with
157 additions
and
130 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
--- | ||
'@kadena/react-ui': minor | ||
--- | ||
|
||
Refactor InputFieldWrapper for the new FormFieldWrapper component with stacked | ||
items |
This file contains 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 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 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 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 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
File renamed without changes.
This file contains 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
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
.../InputWrapper/InputHelper/InputHelper.tsx → ...apper/FormFieldHelper/FormFieldHelper.tsx
This file contains 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 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 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 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
61 changes: 61 additions & 0 deletions
61
packages/libs/react-ui/src/components/Form/FormFieldWrapper/FormFieldWrapper.tsx
This file contains 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,61 @@ | ||
import type { | ||
IInputProps, | ||
ISelectProps, | ||
ITextareaProps, | ||
} from '@components/Form'; | ||
import type { FC, FunctionComponentElement } from 'react'; | ||
import React from 'react'; | ||
import type { vars } from 'src/styles'; | ||
import type { FormFieldStatus } from '../Form.css'; | ||
|
||
import { Stack } from '@components/Layout'; | ||
import type { IFormFieldHeaderProps } from './FormFieldHeader/FormFieldHeader'; | ||
import { FormFieldHeader } from './FormFieldHeader/FormFieldHeader'; | ||
import { FormFieldHelper } from './FormFieldHelper/FormFieldHelper'; | ||
import { FormFieldWrapperContext } from './FormFieldWrapper.context'; | ||
import { statusVariant } from './FormFieldWrapper.css'; | ||
|
||
export interface IFormFieldWrapperProps | ||
extends Omit<IFormFieldHeaderProps, 'label'> { | ||
children: | ||
| FunctionComponentElement<IInputProps | ISelectProps | ITextareaProps> | ||
| FunctionComponentElement<IInputProps | ISelectProps | ITextareaProps>[]; | ||
status?: FormFieldStatus; | ||
disabled?: boolean; | ||
helperText?: string; | ||
label?: string; | ||
leadingTextWidth?: keyof typeof vars.sizes; | ||
} | ||
|
||
export const FormFieldWrapper: FC<IFormFieldWrapperProps> = ({ | ||
status, | ||
disabled, | ||
children, | ||
label, | ||
leadingTextWidth = undefined, | ||
htmlFor, | ||
tag, | ||
info, | ||
helperText, | ||
}) => { | ||
const statusVal = disabled === true ? 'disabled' : status; | ||
|
||
return ( | ||
<FormFieldWrapperContext.Provider value={{ status, leadingTextWidth }}> | ||
<div className={statusVal ? statusVariant[statusVal] : undefined}> | ||
{label !== undefined && ( | ||
<FormFieldHeader | ||
htmlFor={htmlFor} | ||
label={label} | ||
tag={tag} | ||
info={info} | ||
/> | ||
)} | ||
<Stack gap="$2" direction="column"> | ||
{children} | ||
</Stack> | ||
{Boolean(helperText) && <FormFieldHelper>{helperText}</FormFieldHelper>} | ||
</div> | ||
</FormFieldWrapperContext.Provider> | ||
); | ||
}; |
4 changes: 4 additions & 0 deletions
4
packages/libs/react-ui/src/components/Form/FormFieldWrapper/index.ts
This file contains 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,4 @@ | ||
export { | ||
FormFieldWrapper, | ||
type IFormFieldWrapperProps, | ||
} from './FormFieldWrapper'; |
This file contains 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
Oops, something went wrong.
cbdc36b
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.
Successfully deployed to the following URLs:
tools – ./packages/apps/tools
tools-kadena-js.vercel.app
kadena-js-transfer.vercel.app
tools.kadena.io
tools-git-main-kadena-js.vercel.app
cbdc36b
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.
Successfully deployed to the following URLs:
react-ui – ./packages/libs/react-ui
react-ui-delta.vercel.app
react-ui-kadena-js.vercel.app
react-ui-git-main-kadena-js.vercel.app
react-ui.kadena.io