@coveord/plasma-mantine
Version:
A Plasma flavoured Mantine theme
159 lines (158 loc) • 5.36 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "InfoToken", {
enumerable: true,
get: function() {
return InfoToken;
}
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _jsxruntime = require("react/jsx-runtime");
var _plasmareacticons = require("@coveord/plasma-react-icons");
var _core = require("@mantine/core");
var _react = require("react");
var _InfoTokenmodulecss = /*#__PURE__*/ _interop_require_default._(require("./InfoToken.module.css"));
var defaultProps = {
variant: 'outline',
type: 'information',
size: 'xs'
};
var colorResolver = function colorResolver(type) {
switch(type){
case 'error':
return 'var(--mantine-color-error)';
case 'advice':
case 'question':
return 'var(--coveo-color-text-primary)';
case 'warning':
return 'var(--mantine-color-yellow-text)';
case 'success':
return 'var(--mantine-color-green-text)';
case 'information':
default:
return 'var(--mantine-color-gray-text)';
}
};
var bgColorResolver = function bgColorResolver(type) {
switch(type){
case 'error':
return 'var(--mantine-color-red-light)';
case 'advice':
case 'question':
return 'var(--mantine-primary-color-light)';
case 'warning':
return 'var(--mantine-color-yellow-light)';
case 'success':
return 'var(--mantine-color-green-light)';
case 'information':
default:
return 'var(--mantine-color-gray-light)';
}
};
var sizeResolver = function sizeResolver(size) {
switch(size){
case 'sm':
return 20;
case 'md':
return 24;
case 'lg':
return 32;
case 'xs':
default:
return 16;
}
};
var iconResolver = function iconResolver(type) {
switch(type){
case 'error':
return _plasmareacticons.IconAlertSquare;
case 'question':
return _plasmareacticons.IconHelpCircle;
case 'warning':
return _plasmareacticons.IconAlertTriangle;
case 'advice':
return _plasmareacticons.IconBulb;
case 'success':
return _plasmareacticons.IconCheck;
default:
return _plasmareacticons.IconInfoCircle;
}
};
var varsResolver = (0, _core.createVarsResolver)(function(_theme, param) {
var type = param.type;
var color = colorResolver(type);
var bgColor = bgColorResolver(type);
return {
root: {
'--it-color': color,
'--it-bg': bgColor
}
};
});
var _InfoToken = (0, _core.polymorphicFactory)(function(_props, ref) {
var props = (0, _core.useProps)('InfoToken', defaultProps, _props);
var variant = props.variant, type = props.type, vars = props.vars, className = props.className, style = props.style, unstyled = props.unstyled, styles = props.styles, classNames = props.classNames, size = props.size, others = _object_without_properties._(props, [
"variant",
"type",
"vars",
"className",
"style",
"unstyled",
"styles",
"classNames",
"size"
]);
var getStyles = (0, _core.useStyles)({
name: 'InfoToken',
classes: _InfoTokenmodulecss.default,
className: className,
props: props,
style: style,
styles: styles,
unstyled: unstyled,
vars: vars,
varsResolver: varsResolver
});
var IconComponent = iconResolver(type);
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.Box, _object_spread_props._(_object_spread._({
ref: ref,
variant: variant,
role: "img",
"aria-label": type,
size: size
}, getStyles('root', {
className: className,
style: style,
styles: styles,
classNames: classNames
}), others), {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(IconComponent, {
size: sizeResolver(size)
})
}));
});
var createInfoTokenCompound = function createInfoTokenCompound(type, displayName) {
var Component = (0, _core.createPolymorphicComponent)(/*#__PURE__*/ (0, _react.forwardRef)(function(props, ref) {
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_InfoToken, _object_spread_props._(_object_spread._({
ref: ref
}, props), {
type: type
}));
}));
Component.displayName = displayName;
return Component;
};
var InfoToken = {
Information: createInfoTokenCompound('information', 'InfoToken.Information'),
Advice: createInfoTokenCompound('advice', 'InfoToken.Advice'),
Warning: createInfoTokenCompound('warning', 'InfoToken.Warning'),
Error: createInfoTokenCompound('error', 'InfoToken.Error'),
Question: createInfoTokenCompound('question', 'InfoToken.Question'),
Success: createInfoTokenCompound('success', 'InfoToken.Success')
};
//# sourceMappingURL=InfoToken.js.map