@activecollab/components
Version:
ActiveCollab Components
69 lines (67 loc) • 3.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StyledBadge = void 0;
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _FontStyle = require("../FontStyle");
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); }
var DEFAULT_DIMENSION = 8;
var LARGE_FONT_FROM_DIMENSION = 18;
var CIRCLE_PADDING_INLINE = 5;
var PILL_PADDING_INLINE = 10;
var DIGIT_INLINE_SIZE = 7;
var SMALL_CIRCLE_BELOW_DIMENSION = 16;
var dimensionOf = function dimensionOf(props) {
var _props$dimension;
return (_props$dimension = props.dimension) !== null && _props$dimension !== void 0 ? _props$dimension : DEFAULT_DIMENSION;
};
var paddingInlineOf = function paddingInlineOf(props) {
if (!props.hasLabel) {
return 0;
}
if (props.shape === "pill") {
return PILL_PADDING_INLINE;
}
var dimension = dimensionOf(props);
if (dimension >= SMALL_CIRCLE_BELOW_DIMENSION) {
return CIRCLE_PADDING_INLINE;
}
// A small circle keeps a single digit inside its box only with less padding.
return Math.max(0, Math.floor((dimension - DIGIT_INLINE_SIZE) / 2));
};
var StyledBadge = exports.StyledBadge = _styledComponents.default.div.withConfig({
displayName: "Styles__StyledBadge",
componentId: "sc-6o8do5-0"
})(["", " align-items:center;background-color:", ";block-size:", ";border-radius:999px;box-sizing:border-box;color:", ";display:flex;font-size:", ";font-variant-numeric:tabular-nums;font-weight:700;inline-size:auto;justify-content:center;min-inline-size:", ";padding-inline:", ";pointer-events:none;position:absolute;z-index:1;", " ", " ", " ", " ", " ", ""], _FontStyle.FontStyle, function (props) {
return !props.backgroundColor ? "var(--color-primary)" : props.backgroundColor;
}, function (props) {
return dimensionOf(props) + "px";
}, function (props) {
return !props.textColor ? "var(--color-theme-100)" : props.textColor;
}, function (props) {
return dimensionOf(props) >= LARGE_FONT_FROM_DIMENSION ? "12px" : "10px";
}, function (props) {
return dimensionOf(props) + "px";
}, function (props) {
return paddingInlineOf(props) + "px";
}, function (_ref) {
var shadows = _ref.shadows;
return shadows && (0, _styledComponents.css)(["box-shadow:var(--shadow-tertiary);text-shadow:0 1px 2px rgba(0,0,0,0.25);"]);
}, function (_ref2) {
var isStandalone = _ref2.isStandalone;
return isStandalone && (0, _styledComponents.css)(["position:static;z-index:0;"]);
}, function (_ref3) {
var position = _ref3.position;
return position === "top-left" && (0, _styledComponents.css)(["inset-block-start:0;inset-inline-start:0;"]);
}, function (_ref4) {
var position = _ref4.position;
return position === "top-right" && (0, _styledComponents.css)(["inset-block-start:0;inset-inline-end:0;"]);
}, function (_ref5) {
var position = _ref5.position;
return position === "bottom-right" && (0, _styledComponents.css)(["inset-block-end:0;inset-inline-end:0;"]);
}, function (_ref6) {
var position = _ref6.position;
return position === "bottom-left" && (0, _styledComponents.css)(["inset-block-end:0;inset-inline-start:0;"]);
});
//# sourceMappingURL=Styles.js.map