-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: label 컴포넌트 추가 및 적용 (#ATR-603)
- Loading branch information
Showing
5 changed files
with
66 additions
and
49 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
packages/design-system/packages/core/src/components/label/Label.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,21 @@ | ||
import React from 'react' | ||
import { cn } from '@attraction/utils' | ||
|
||
interface LabelProps | ||
extends React.DetailedHTMLProps< | ||
React.LabelHTMLAttributes<HTMLLabelElement>, | ||
HTMLLabelElement | ||
> { | ||
required?: boolean | ||
} | ||
|
||
const Label = React.forwardRef<HTMLLabelElement, LabelProps>( | ||
({ required, className, children, ...props }, ref) => ( | ||
<label ref={ref} className={cn('ds-label', className)} {...props}> | ||
{children} | ||
{required && <span className="ds-asterisk">*</span>} | ||
</label> | ||
), | ||
) | ||
|
||
export default Label |
38 changes: 38 additions & 0 deletions
38
packages/design-system/packages/core/src/components/label/_index.scss
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,38 @@ | ||
@use '../../token/variable'; | ||
|
||
.ds-label { | ||
position: relative; | ||
display: inline-flex; | ||
justify-content: flex-start; | ||
align-items: center; | ||
box-sizing: border-box; | ||
margin: 0px; | ||
margin-bottom: 0.25rem; | ||
padding: 0px 0.25rem; | ||
font-size: variable.$ds-font-size-200; | ||
font-weight: variable.$ds-font-weight-medium; | ||
color: variable.$ds-gray-500; | ||
line-height: variable.$ds-leading-normal; | ||
white-space: nowrap; | ||
.dark & { | ||
color: variable.$ds-gray-400; | ||
} | ||
& > .ds-asterisk { | ||
position: absolute; | ||
top: 0.125rem; | ||
bottom: 0rem; | ||
right: -0.25rem; | ||
font-size: variable.$ds-font-size-300; | ||
font-weight: variable.$ds-font-weight-medium; | ||
color: variable.$ds-red-400; | ||
line-height: variable.$ds-leading-tight; | ||
white-space: inherit; | ||
.dark & { | ||
color: variable.$ds-red-300; | ||
} | ||
} | ||
|
||
*[class$='--size-lg'] & { | ||
margin-bottom: 0.5rem; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/design-system/packages/core/src/components/label/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 @@ | ||
export { default as Label } 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
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