Skip to content

Commit 253a377

Browse files
committed
refactor(CHeader): improve and clean-up syntax
1 parent a895e6f commit 253a377

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

packages/coreui-react/src/components/header/CHeader.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,19 @@ export interface CHeaderProps extends HTMLAttributes<HTMLDivElement> {
1919

2020
export const CHeader = forwardRef<HTMLDivElement, CHeaderProps>(
2121
({ children, className, container, position, ...rest }, ref) => {
22-
let content
23-
if (container) {
24-
content = (
25-
<div className={`container${container !== true ? '-' + container : ''}`}>{children}</div>
26-
)
27-
} else {
28-
content = children
29-
}
30-
3122
return (
3223
<div
3324
className={classNames('header', { [`header-${position}`]: position }, className)}
3425
{...rest}
3526
ref={ref}
3627
>
37-
{content}
28+
{container ? (
29+
<div className={typeof container === 'string' ? `container-${container}` : 'container'}>
30+
{children}
31+
</div>
32+
) : (
33+
<>{children}</>
34+
)}
3835
</div>
3936
)
4037
},

packages/coreui-react/src/components/header/CHeaderToggler.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const CHeaderToggler = forwardRef<HTMLButtonElement, CHeaderTogglerProps>
1313
({ children, className, ...rest }, ref) => {
1414
return (
1515
<button type="button" className={classNames('header-toggler', className)} {...rest} ref={ref}>
16-
{children ? children : <span className="header-toggler-icon"></span>}
16+
{children ?? <span className="header-toggler-icon"></span>}
1717
</button>
1818
)
1919
},

0 commit comments

Comments
 (0)