-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
80 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
import { forwardRef } from 'react'; | ||
import type { ReactNode } from 'react'; | ||
import type { HTMLAttributes, ReactNode } from 'react'; | ||
import { FieldBoxLabel } from './Label'; | ||
|
||
export interface FieldBoxProps { | ||
export interface FieldBoxProps extends HTMLAttributes<HTMLDivElement> { | ||
topAddon?: ReactNode; | ||
bottomAddon?: ReactNode; | ||
children: ReactNode; | ||
} | ||
|
||
const FieldBox = forwardRef<HTMLDivElement, FieldBoxProps>((props, forwardedRef) => { | ||
const FieldBoxImpl = forwardRef<HTMLDivElement, FieldBoxProps>((props, forwardedRef) => { | ||
const { topAddon, bottomAddon, children, ...restProps } = props; | ||
|
||
return ( | ||
<div ref={forwardedRef} {...restProps}> | ||
<div>{topAddon}</div> | ||
{topAddon} | ||
<div>{children}</div> | ||
<div>{bottomAddon}</div> | ||
</div> | ||
); | ||
}); | ||
|
||
FieldBox.displayName = 'FieldBox'; | ||
FieldBoxImpl.displayName = 'FieldBoxImpl'; | ||
|
||
export default FieldBox; | ||
export const FieldBox = Object.assign(FieldBoxImpl, { | ||
Label: FieldBoxLabel, | ||
}); |
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,27 @@ | ||
import type { HTMLAttributes } from 'react'; | ||
import { forwardRef } from 'react'; | ||
import * as S from './style.css'; | ||
|
||
export interface FieldBoxLabelProps extends HTMLAttributes<HTMLDivElement> { | ||
label: string; | ||
description: string; | ||
required: boolean; | ||
} | ||
|
||
export const FieldBoxLabel = forwardRef<HTMLDivElement, FieldBoxLabelProps>((props, forwardedRef) => { | ||
const { required, label, description } = props; | ||
|
||
return ( | ||
<div ref={forwardedRef}> | ||
<label className={S.label}> | ||
<span> | ||
{label} | ||
{required ? <span className={S.required}>*</span> : null} | ||
</span> | ||
<p className={S.description}>{description}</p> | ||
</label> | ||
</div> | ||
); | ||
}); | ||
|
||
FieldBoxLabel.displayName = 'FieldBoxLabel'; |
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,2 @@ | ||
export * from './FieldBox'; | ||
export * from './Label'; |
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,21 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
import theme from '../theme.css'; | ||
|
||
export const label = style({ | ||
...theme.fontsObject.LABEL_3_14_SB, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
textAlign: 'left', | ||
color: theme.colors.white, | ||
}); | ||
|
||
export const description = style({ | ||
...theme.fontsObject.LABEL_4_12_SB, | ||
color: theme.colors.gray300, | ||
marginBottom: '8px', | ||
}); | ||
|
||
export const required = style({ | ||
color: theme.colors.secondary, | ||
marginLeft: '4px', | ||
}); |
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