This repository was archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathIllo.jsx
More file actions
96 lines (89 loc) · 2.63 KB
/
Copy pathIllo.jsx
File metadata and controls
96 lines (89 loc) · 2.63 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import React from 'react'
import PropTypes from 'prop-types'
import getValidProps from '@helpscout/react-utils/dist/getValidProps'
import VisuallyHidden from '../VisuallyHidden'
import classNames from 'classnames'
import { IlloUI, IconUI, CenteredContentUI } from './Illo.css'
import { svgSet } from './Illo.utils'
const Illo = props => {
const {
className,
color,
colorSecondary,
colorUi,
colorUiDark,
colorUiLight,
colorUiTransparent,
colorUiWhite,
name,
size,
style,
title,
...rest
} = props
const componentClassName = classNames(
'c-Illo',
color && 'has-color',
colorSecondary && 'has-colorSecondary',
size && `is-${size}`,
className
)
const IlloComponent = svgSet[name]
const iconTitle = title || name
const componentStyle = { ...style, color }
return (
<IlloUI
{...getValidProps(rest)}
className={componentClassName}
data-illo-name={name}
style={componentStyle}
>
<CenteredContentUI>
<IconUI className="c-Illo__icon" title={iconTitle}>
{IlloComponent && <IlloComponent />}
</IconUI>
</CenteredContentUI>
<VisuallyHidden>{iconTitle}</VisuallyHidden>
</IlloUI>
)
}
Illo.defaultProps = {
color: '',
colorSecondary: '',
colorUi: '',
colorUiDark: '',
colorUiLight: '',
colorUiTransparent: 'transparent',
colorUiWhite: 'white',
'data-cy': 'Illo',
size: '60',
}
Illo.propTypes = {
/** Custom class names to be added to the component. */
className: PropTypes.string,
/** Custom color for SVG image on primary paths. */
color: PropTypes.string,
/** Custom color for SVG image on secondary paths. */
colorSecondary: PropTypes.string,
/** Custom color for SVG image on UI themed paths. */
colorUi: PropTypes.string,
/** Custom color for SVG image on UI dark themed paths. */
colorUiDark: PropTypes.string,
/** Custom color for SVG image on UI light themed paths. */
colorUiLight: PropTypes.string,
/** Custom color for SVG image on UI transparent themed paths. Default `transparent`. */
colorUiTransparent: PropTypes.string,
/** Custom color for SVG image on UI white themed paths. Default `white`. */
colorUiWhite: PropTypes.string,
/** Determines the SVG image. Required. */
name: PropTypes.string,
/** Callback function when component is clicked. */
onClick: PropTypes.func,
/** Adjusts the size of the component. */
size: PropTypes.oneOf(['40', '60', '72', '80', '90', 40, 60, 72, 80, 90]),
/** Provides a name for the component. */
title: PropTypes.string,
/** Data attr for Cypress tests. */
'data-cy': PropTypes.string,
}
export default Illo