"use strict";

const React = require("react");

const defaultStyle = require("./style.css");
const useTheme = require("../../util/themeable");
const Icon = require("../icon");

module.exports = function Button({ type, onClick, label, icon }) {
	// TODO: Validate type?
	// TODO: Content override instead of label/icon?
	let { withTheme } = useTheme({ control: "button", defaultStyle });

	return (
		<button className={withTheme("button", `style-${type}`)} onClick={onClick}>
			<span className="buttonContents">
				{(icon != null)
					? <Icon icon={icon} />
					: null
				}

				{label}
			</span>
		</button>
	);
};
