-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathsection-title.tsx
41 lines (37 loc) · 1.27 KB
/
section-title.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { FC, HTMLProps, ReactNode } from 'react'
import classNames from 'classnames'
import { findComponent } from '../common/component-utils'
import {
EbaySectionTitleSubtitle,
EbaySectionTitleTitle,
EbaySectionTitleInfo,
EbaySectionTitleOverflow
} from './index'
import Cta from './cta'
export type EbaySectionTitleProps = Omit<HTMLProps<HTMLDivElement>, 'title'> & {
href?: string;
ctaText?: ReactNode;
}
const EbaySectionTitle: FC<EbaySectionTitleProps> = ({
href,
ctaText,
className,
children,
...rest
}) => {
const sectionTitleClass = classNames(className, 'section-title')
const title = findComponent(children, EbaySectionTitleTitle)
const subtitle = findComponent(children, EbaySectionTitleSubtitle)
const info = findComponent(children, EbaySectionTitleInfo)
const overflow = findComponent(children, EbaySectionTitleOverflow)
return (
<div {...rest} className={sectionTitleClass}>
<div className="section-title__title-container">
{title || <EbaySectionTitleTitle>{children}</EbaySectionTitleTitle>}
{subtitle}
</div>
{href && <Cta href={href} ctaText={ctaText} /> || info || overflow}
</div>
)
}
export default EbaySectionTitle