Skip to content

Commit

Permalink
feat(components): add withoutIcon prop to Message component
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed Nov 28, 2024
1 parent 96e9141 commit 4e52cd9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/components/Message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ export type MessageProps = HTMLAttributes<HTMLDivElement> & {
children: ReactNode | string
iconColor?: Level | undefined
level?: Level | undefined
withoutIcon?: boolean
}
export function Message({ children, className, Icon, iconColor, level = Level.INFO, ...nativeProps }: MessageProps) {
export function Message({
children,
className,
Icon,
iconColor,
level = Level.INFO,
withoutIcon,
...nativeProps
}: MessageProps) {
const controlledClassName = classnames('Component-Message', className)
const ControlledIcon = Icon ?? DEFAUT_ICON[level]
const controlledIconColor = iconColor ?? DEFAULT_ICON_COLOR[level]

return (
<Box $level={level} className={controlledClassName} {...nativeProps}>
<ControlledIcon color={controlledIconColor} />
{!withoutIcon && <ControlledIcon color={controlledIconColor} />}
<ChildrenContainer>{children}</ChildrenContainer>
</Box>
)
Expand All @@ -41,7 +50,6 @@ const Box = styled.div<{
}>`
${getStyledCssFromLevel()}
border-radius: 2px;
display: flex;
font-size: 13px;
padding: 16px;
Expand Down
3 changes: 1 addition & 2 deletions src/components/Message/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ export function getStyledCssFromLevel() {
color: ${props.theme.color.gunMetal};
`

// TODO Check `border-color` with Adeline.
case props.$level === Level.INFO:
default:
return `
background-color: ${props.theme.color.blueGray25};
border: solid 1px ${props.theme.color.blueGrayBorder};
border: solid 1px #AECEEA;
color: ${props.theme.color.gunMetal};
`
}
Expand Down

0 comments on commit 4e52cd9

Please sign in to comment.