mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-04-20 08:16:38 +02:00
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
/*
|
|
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
|
*
|
|
* This is free software, licensed under the GNU General Public License v3.
|
|
* See /LICENSE for more information.
|
|
*/
|
|
|
|
import React from "react";
|
|
import PropTypes from "prop-types";
|
|
|
|
Button.propTypes = {
|
|
/** Additional class name. */
|
|
className: PropTypes.string,
|
|
/** Use foris form size and offset. */
|
|
forisFormSize: PropTypes.bool,
|
|
/** Show loading icon. */
|
|
loading: PropTypes.bool,
|
|
/** Button content. */
|
|
children: PropTypes.oneOfType([
|
|
PropTypes.string,
|
|
PropTypes.element,
|
|
PropTypes.node,
|
|
PropTypes.arrayOf(PropTypes.node),
|
|
]).isRequired,
|
|
};
|
|
|
|
export function Button({
|
|
className, loading, forisFormSize, children, ...props
|
|
}) {
|
|
let buttonClass = className ? `btn ${className}` : "btn btn-primary ";
|
|
if (forisFormSize) {
|
|
buttonClass = `${buttonClass} col-sm-12 col-lg-3`;
|
|
}
|
|
|
|
const span = loading
|
|
? <span className="spinner-border spinner-border-sm" role="status" aria-hidden="true" /> : null;
|
|
|
|
return (
|
|
<button type="button" className={buttonClass} {...props}>
|
|
{span}
|
|
{" "}
|
|
{span ? " " : null}
|
|
{" "}
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|