1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-23 05:24:18 +00:00
pds-2021-g2-nest/code/frontend/src/components/Button.js

29 lines
786 B
JavaScript
Raw Normal View History

import React, { isValidElement } from "react"
import Style from "./Button.module.css"
import classNames from "classnames"
import isString from "is-string"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
export default function Button({ children, className, color, icon, ...props }) {
let iconElement;
if(isValidElement(icon)) {
iconElement = <span className={Style.Icon}>icon</span>;
}
else if(icon) {
iconElement = (
<span className={Style.Icon}><FontAwesomeIcon icon={icon}/></span>
)
}
else {
iconElement = null;
}
return (
<button className={classNames(Style.Button, Style[`Button${color}`], className)} {...props}>
{children} {iconElement}
</button>
)
}