Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/scripts/components/elements/Icon.tsx
7461 views
1
import React, { CSSProperties } from 'react';
2
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
3
import tw from 'twin.macro';
4
5
interface Props {
6
icon: IconDefinition;
7
className?: string;
8
style?: CSSProperties;
9
}
10
11
const Icon = ({ icon, className, style }: Props) => {
12
const [width, height, , , paths] = icon.icon;
13
14
return (
15
<svg
16
xmlns={'http://www.w3.org/2000/svg'}
17
viewBox={`0 0 ${width} ${height}`}
18
css={tw`fill-current inline-block`}
19
className={className}
20
style={style}
21
>
22
{(Array.isArray(paths) ? paths : [paths]).map((path, index) => (
23
<path key={`svg_path_${index}`} d={path} />
24
))}
25
</svg>
26
);
27
};
28
29
export default Icon;
30
31