Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c0b468c

Browse filesBrowse files
committed
feat(CSidebarBrand): allows to rendering the component as a link
1 parent ad08245 commit c0b468c
Copy full SHA for c0b468c

File tree

1 file changed

+21
-11
lines changed
Filter options

1 file changed

+21
-11
lines changed

‎packages/coreui-react/src/components/sidebar/CSidebarBrand.tsx

Copy file name to clipboardExpand all lines: packages/coreui-react/src/components/sidebar/CSidebarBrand.tsx
+21-11Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
import React, { forwardRef, HTMLAttributes } from 'react'
1+
import React, { ElementType, forwardRef, HTMLAttributes } from 'react'
22
import PropTypes from 'prop-types'
33
import classNames from 'classnames'
44

5-
export interface CSidebarBrandProps extends HTMLAttributes<HTMLDivElement> {
5+
import { PolymorphicRefForwardingComponent } from '../../helpers'
6+
7+
export interface CSidebarBrandProps extends HTMLAttributes<HTMLAnchorElement | HTMLDivElement> {
8+
/**
9+
* Component used for the root node. Either a string to use a HTML element or a component.
10+
*
11+
* @since 5.0.0-rc.0
12+
*/
13+
as?: ElementType
614
/**
715
* A string of all className you want applied to the component.
816
*/
917
className?: string
1018
}
1119

12-
export const CSidebarBrand = forwardRef<HTMLDivElement, CSidebarBrandProps>(
13-
({ children, className, ...rest }, ref) => {
14-
return (
15-
<div className={classNames('sidebar-brand', className)} ref={ref} {...rest}>
16-
{children}
17-
</div>
18-
)
19-
},
20-
)
20+
export const CSidebarBrand: PolymorphicRefForwardingComponent<'a', CSidebarBrandProps> = forwardRef<
21+
HTMLAnchorElement | HTMLDivElement,
22+
CSidebarBrandProps
23+
>(({ children, as: Component = 'a', className, ...rest }, ref) => {
24+
return (
25+
<Component className={classNames('sidebar-brand', className)} ref={ref} {...rest}>
26+
{children}
27+
</Component>
28+
)
29+
})
2130

2231
CSidebarBrand.propTypes = {
32+
as: PropTypes.elementType,
2333
children: PropTypes.node,
2434
className: PropTypes.string,
2535
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.