forked from flexport/__latitude
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphicIcon.jsx
54 lines (48 loc) · 1.42 KB
/
GraphicIcon.jsx
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
/**
* TEAM: frontend_infra
* WATCHERS: notandrewkaye
* @flow strict
*/
/* eslint-disable react/prefer-stateless-function */
import * as React from "react";
import {type GraphicIcons, graphicIcons} from "./tools/graphicIcons";
import ThemeNameContext, {type Theme} from "./context/ThemeNameContext";
type Props = {|
/** Illustrations available are designed on a case-by-case basis and generally have specific intentions. */
+icon: GraphicIcons,
/** Width can be any pixel value. If "auto" is passed, then a width of 100% will be assigned so the SVG fills it's container. */
+width: number | "auto",
|};
/**
* @short Detailed SVG illustrations made for empty states, loading states, and ownable moments.
* @brandStatus V2
* @status Stable
* @category General
* @extends React.Component */
class GraphicIcon extends React.PureComponent<Props> {
static defaultProps = {
width: 320,
};
static contextType = ThemeNameContext;
context: Theme;
render() {
const {icon, width} = this.props;
const svgWidth = width === "auto" ? "100%" : width;
const graphic = graphicIcons(this.context)[icon];
const viewBox = "0 0 360 360";
return (
<div>
<svg
viewBox={viewBox}
role="img"
aria-hidden="true"
aria-labelledby="title desc"
width={svgWidth}
>
{graphic.svgData}
</svg>
</div>
);
}
}
export default GraphicIcon;