web-base/react/shared/elements/icon.jsx

24 lines
576 B
React
Raw Normal View History

import React from 'react';
2020-06-14 12:38:35 +02:00
export default function Icon(props) {
2020-06-17 14:30:37 +02:00
let classes = props.className || [];
2020-06-14 12:38:35 +02:00
classes = Array.isArray(classes) ? classes : classes.toString().split(" ");
let type = props.type || "fas";
let icon = props.icon;
2020-06-14 22:35:01 +02:00
classes.push(type);
classes.push("fa-" + icon);
2020-06-14 12:38:35 +02:00
2020-06-18 15:20:50 +02:00
if (icon === "spinner" || icon === "circle-notch") {
2020-06-14 12:38:35 +02:00
classes.push("fa-spin");
}
2020-06-15 23:10:14 +02:00
let newProps = {...props, className: classes.join(" ") };
delete newProps["type"];
delete newProps["icon"];
2020-06-14 12:38:35 +02:00
return (
2020-06-15 23:10:14 +02:00
<i {...newProps} />
2020-06-14 12:38:35 +02:00
);
}