@activecollab/components
Version:
ActiveCollab Components
75 lines (74 loc) • 4.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Button = void 0;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _Styles = require("./Styles");
var _excluded = ["children", "active", "variant", "size", "className"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @component Button
* @description
* Button component is used to trigger an action or event, such as submitting a form,
* opening a Dialog, canceling an action, or performing a delete operation.
*
* @prop {variant} - adds unique look and feel to button.
* @prop {size} - controls the size of a button.
* @prop {active} - adds active/pressed state to a button.
*
* @example
* return (
* <Button className="mr-2" variant="primary" size="big">
* Save
* </Button>
* )
* @see
* https://system.activecollab.com/?path=/story/components-button-indicators-button--button
* https://design.activecollab.com/docs/components/button
*/
var Button = exports.Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
var children = _ref.children,
_ref$active = _ref.active,
active = _ref$active === void 0 ? false : _ref$active,
_ref$variant = _ref.variant,
variant = _ref$variant === void 0 ? "contained" : _ref$variant,
_ref$size = _ref.size,
size = _ref$size === void 0 ? "medium" : _ref$size,
className = _ref.className,
args = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/_react.default.createElement(_Styles.StyledButton, _extends({
className: (0, _classnames.default)("c-btn", className, {
"c-btn--contained": variant === "primary" || variant === "contained",
"c-btn--outlined": variant === "secondary" || variant === "outlined",
"c-btn--text_colored": variant === "tertiary" || variant === "text colored",
"c-btn--text_gray": variant === "option" || variant === "text gray",
"c-btn--dark_transparent": variant === "dark transparent",
"c-btn--circle-raised": variant === "circle raised",
"c-btn--big": size === "big",
"c-btn--small": size === "small",
"c-btn--icon-only": children instanceof Object && !(children instanceof Array)
}),
iconOnly: children instanceof Object && !(children instanceof Array),
variant: variant,
active: active,
size: size,
ref: ref,
"aria-pressed": active,
role: "button"
}, args), children instanceof Array ? /*#__PURE__*/_react.default.createElement(_Styles.StyledButtonElements, {
className: "c-btn__elements"
}, children.map(function (value, index) {
return value ? /*#__PURE__*/_react.default.createElement(_Styles.StyledButtonElement, {
className: "c-btn__elements__element",
key: index
}, value) : null;
})) : children);
});
Button.displayName = "Button";
//# sourceMappingURL=Button.js.map