UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

67 lines (64 loc) 3.38 kB
import _defineProperty from '@babel/runtime/helpers/defineProperty'; import styled from 'styled-components'; import '../Box/BaseBox/index.js'; import '../../utils/index.js'; import { buttonBorderRadius } from '../Button/BaseButton/buttonTokens.js'; import { BaseBox } from '../Box/BaseBox/BaseBox.web.js'; import { makeBorderSize } from '../../utils/makeBorderSize/makeBorderSize.js'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var StyledButtonGroup = /*#__PURE__*/styled(BaseBox).withConfig({ displayName: "StyledButtonGroup", componentId: "gr4xbj-0" })(function (_ref) { var theme = _ref.theme, _ref$variant = _ref.variant, variant = _ref$variant === void 0 ? 'primary' : _ref$variant, isFullWidth = _ref.isFullWidth, _ref$size = _ref.size, size = _ref$size === void 0 ? 'medium' : _ref$size; var borderRadiusToken = buttonBorderRadius[size]; var borderRadius = makeBorderSize(theme.border.radius[borderRadiusToken]); var isSecondaryOrTertiary = variant === 'secondary' || variant === 'tertiary'; return _objectSpread({ display: 'flex', width: isFullWidth ? '100%' : 'fit-content', borderWidth: makeBorderSize(theme.border.width.thin), borderRadius: borderRadius, borderStyle: 'solid', borderColor: 'transparent', overflow: 'hidden', 'button[role="button"]': { flex: isFullWidth ? 1 : 'auto', borderRadius: 0 }, // Handles both direct buttons and buttons wrapped in components like Dropdown '> button[role="button"]:first-child, > *:first-child button[role="button"]': { borderRight: 'none', borderTopLeftRadius: borderRadius, borderBottomLeftRadius: borderRadius }, // Targets middle buttons, whether direct children or wrapped in container elements '> button[role="button"]:not(:first-child):not(:last-child), > *:not(:first-child):not(:last-child) button[role="button"]': { borderLeft: 'none', borderRight: 'none' }, // Handles last button in group, accounting for wrapper components like Dropdown '> button[role="button"]:last-child, > *:last-child button[role="button"]': { borderLeft: 'none', borderTopRightRadius: borderRadius, borderBottomRightRadius: borderRadius }, // Remove radial gradient from all buttons except the first one '> button[role="button"]:not(:first-child), > *:not(:first-child) button[role="button"]': { backgroundImage: 'none' } }, isSecondaryOrTertiary && { '> button[role="button"]:not(:first-child), > *:not(:first-child) button[role="button"]': { marginLeft: '-1px', backgroundImage: 'none' } }); }); export { StyledButtonGroup }; //# sourceMappingURL=StyledButtonGroup.js.map