@atlaskit/button
Version:
A button triggers an event or action. They let users know what will happen next.
88 lines • 3.19 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["href", "children"],
_excluded2 = ["icon", "label"],
_excluded3 = ["href", "icon", "label"];
import React, { forwardRef } from 'react';
import StarStarredIcon from '@atlaskit/icon/core/star-starred';
import Button from '../new-button/variants/default/button';
import LinkButton from '../new-button/variants/default/link';
import IconButton from '../new-button/variants/icon/button';
import LinkIconButton from '../new-button/variants/icon/link';
import { buttonAppearances } from './button-appearances';
import { buttonSpacing } from './button-spacing';
import { iconButtonAppearances } from './icon-button-appearances';
import { iconButtonShapes } from './icon-button-shapes';
import { iconButtonSpacing } from './icon-button-spacing';
import { linkButtonAppearances } from './link-button-appearances';
// Add required default props to variants
var LinkButtonRender = /*#__PURE__*/forwardRef(function (_ref, ref) {
var _ref$href = _ref.href,
href = _ref$href === void 0 ? 'home' : _ref$href,
children = _ref.children,
rest = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/React.createElement(LinkButton, _extends({
ref: ref,
href: href
}, rest), children);
});
var IconButtonRender = /*#__PURE__*/forwardRef(function (_ref2, ref) {
var _ref2$icon = _ref2.icon,
icon = _ref2$icon === void 0 ? StarStarredIcon : _ref2$icon,
_ref2$label = _ref2.label,
label = _ref2$label === void 0 ? 'Label' : _ref2$label,
rest = _objectWithoutProperties(_ref2, _excluded2);
return /*#__PURE__*/React.createElement(IconButton, _extends({
ref: ref,
icon: icon,
label: label
}, rest));
});
var LinkIconButtonRender = /*#__PURE__*/forwardRef(function (_ref3, ref) {
var _ref3$href = _ref3.href,
href = _ref3$href === void 0 ? 'home' : _ref3$href,
_ref3$icon = _ref3.icon,
icon = _ref3$icon === void 0 ? StarStarredIcon : _ref3$icon,
_ref3$label = _ref3.label,
label = _ref3$label === void 0 ? 'Label' : _ref3$label,
rest = _objectWithoutProperties(_ref3, _excluded3);
return /*#__PURE__*/React.createElement(LinkIconButton, _extends({
ref: ref,
href: href,
icon: icon,
label: label
}, rest));
});
var variants = {
Button: {
name: 'Button',
Component: Button,
elementType: HTMLButtonElement,
appearances: buttonAppearances,
spacing: buttonSpacing
},
LinkButton: {
name: 'LinkButton',
Component: LinkButtonRender,
elementType: HTMLAnchorElement,
appearances: linkButtonAppearances,
spacing: buttonSpacing
},
IconButton: {
name: 'IconButton',
Component: IconButtonRender,
elementType: HTMLButtonElement,
appearances: iconButtonAppearances,
spacing: iconButtonSpacing,
shape: iconButtonShapes
},
LinkIconButton: {
name: 'LinkIconButton',
Component: LinkIconButtonRender,
elementType: HTMLAnchorElement,
appearances: iconButtonAppearances,
spacing: iconButtonSpacing,
shape: iconButtonShapes
}
};
export default variants;