-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathFooter.tsx
More file actions
46 lines (39 loc) · 1.65 KB
/
Footer.tsx
File metadata and controls
46 lines (39 loc) · 1.65 KB
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
42
43
44
45
46
import React from 'react';
import TImage from '../image';
import { TdFooterProps } from './type';
import { StyledProps } from '../common';
import { footerDefaultProps } from './defaultProps';
import { usePrefixClass } from '../hooks/useClass';
import useDefaultProps from '../hooks/useDefaultProps';
export interface FooterProps extends TdFooterProps, StyledProps {}
const Footer: React.FC<FooterProps> = (originProps) => {
const props = useDefaultProps(originProps, footerDefaultProps);
const { links, text, logo, className, style } = props;
const footerClass = usePrefixClass('footer');
const footerLinkClass = usePrefixClass('footer__link');
return (
<div className={`${footerClass} ${className || ''}`} style={style}>
{logo && (
<a className={`${footerClass}__logo`} href={logo.url} target={logo.target}>
{logo.icon && <TImage className={`${footerClass}__${logo.title ? 'icon' : 'title-url'}`} src={logo.icon} />}
{logo.title && <span className={`${footerClass}__title`}>{logo.title}</span>}
</a>
)}
{links.length ? (
<div className={`${footerLinkClass}-list`}>
{links.map((link, index) => (
<React.Fragment key={link.url}>
<a href={link.url} target={link.target} className={`${footerLinkClass}-item`}>
{link.name}
</a>
{index !== links.length - 1 && <div className={`${footerLinkClass}-line`}>|</div>}
</React.Fragment>
))}
</div>
) : null}
{text && <div className={`${footerClass}__text`}>{text}</div>}
</div>
);
};
Footer.displayName = 'Footer';
export default Footer;