-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: define unified form labels for all new formik fields
- Loading branch information
1 parent
9b60880
commit fab4d83
Showing
10 changed files
with
88 additions
and
105 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { twMerge } from 'tailwind-merge' | ||
import { Label } from './forms/Label' | ||
|
||
export interface FormLabelProps { | ||
id?: string | ||
required: boolean | ||
label: string | ||
labelType: 'small' | 'large' | ||
className?: { | ||
label?: string | ||
tooltip?: string | ||
} | ||
tooltip?: string | React.ReactNode | ||
} | ||
|
||
export function FormLabel({ | ||
id, | ||
required, | ||
label, | ||
labelType = 'small', | ||
className, | ||
tooltip, | ||
}: FormLabelProps) { | ||
return ( | ||
<Label | ||
forId={id} | ||
required={required} | ||
label={label} | ||
className={{ | ||
root: twMerge( | ||
'my-auto mr-2 min-w-max font-bold', | ||
labelType === 'small' && '-mb-0.5 mt-1 leading-6 text-gray-600', | ||
className?.label | ||
), | ||
tooltip: twMerge('text-sm font-normal', className?.tooltip), | ||
tooltipSymbol: twMerge(labelType === 'small' && 'h-2 w-2'), | ||
}} | ||
tooltip={tooltip} | ||
showTooltipSymbol={typeof tooltip !== 'undefined'} | ||
/> | ||
) | ||
} | ||
|
||
export default FormLabel |
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
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