1 | import * as React from 'react';
|
2 |
|
3 | import Hiperlink from './Link.styled';
|
4 | import { Forward, Backward, ArrowPlus, Download, Plus } from './LinksIcon';
|
5 |
|
6 | export interface IProps {
|
7 | href?: string;
|
8 | children?: React.ReactNode;
|
9 | target?: string;
|
10 | isType?: string;
|
11 | className?: string;
|
12 | css?: string|Object;
|
13 | title?: string;
|
14 | alt?: string;
|
15 | onClick?: (any?: any) => any;
|
16 | isActiveRoute?: boolean;
|
17 | route?: string;
|
18 | params?: any;
|
19 | }
|
20 |
|
21 | const renderChildAndTypeIcon = (type?: string, children?: any) => {
|
22 | const mapIconLinks = new Map();
|
23 | mapIconLinks
|
24 | .set('forward', Forward(children))
|
25 | .set('backward', Backward(children))
|
26 | .set('download', Download(children))
|
27 | .set('arrow-plus', ArrowPlus(children))
|
28 | .set('plus', Plus(children));
|
29 |
|
30 | return mapIconLinks.get(type) || children;
|
31 | };
|
32 |
|
33 | export default ({ children, isType, ...props }: IProps) => {
|
34 | const restProps = { isType, ...props};
|
35 |
|
36 | return (
|
37 | <Hiperlink {...restProps}>
|
38 | {renderChildAndTypeIcon(isType, children)}
|
39 | </Hiperlink>
|
40 | );
|
41 | };
|