UNPKG

pouncejs

Version:

A collection of UI components from Panther labs

135 lines (115 loc) 3.29 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.default = void 0; var _helpers = require("../../../utils/helpers"); var _useTheme = _interopRequireDefault(require("../../../utils/useTheme")); var getSolidAlertThemes = function getSolidAlertThemes(alertVariant) { switch (alertVariant) { case 'success': return { color: 'green-500', backgroundColor: 'green-50', icon: 'check-circle' }; case 'warning': return { color: 'yellow-600', backgroundColor: 'yellow-50', icon: 'alert-circle-filled' }; case 'error': return { color: 'red-400', backgroundColor: 'red-50', icon: 'alert-circle-filled' }; case 'info': return { color: 'blue-400', backgroundColor: 'blue-50', icon: 'info' }; case 'default': default: return { color: undefined, backgroundColor: 'gray-100', icon: undefined }; } }; var getTransparentAlertThemes = function getTransparentAlertThemes(alertVariant) { var theme = (0, _useTheme.default)(); switch (alertVariant) { case 'success': return { color: 'green-300', backgroundColor: (0, _helpers.addOpacity)(theme.colors['green-300'], 0.3), icon: 'check-circle' }; case 'warning': return { color: 'yellow-300', backgroundColor: (0, _helpers.addOpacity)(theme.colors['yellow-300'], 0.3), icon: 'alert-circle' }; case 'error': return { color: 'red-300', backgroundColor: (0, _helpers.addOpacity)(theme.colors['red-300'], 0.3), icon: 'alert-circle' }; case 'info': return { color: 'blue-300', backgroundColor: (0, _helpers.addOpacity)(theme.colors['blue-300'], 0.3), icon: 'info' }; case 'default': default: return { color: 'white', backgroundColor: (0, _helpers.addOpacity)(theme.colors['white'], 0.3), icon: 'info' }; } }; var useAlertStyles = function useAlertStyles(_ref) { var variant = _ref.variant, variantBackgroundStyle = _ref.variantBackgroundStyle; var _ref2 = variantBackgroundStyle === 'solid' ? getSolidAlertThemes(variant) : getTransparentAlertThemes(variant), color = _ref2.color, backgroundColor = _ref2.backgroundColor, icon = _ref2.icon; switch (variantBackgroundStyle) { case 'transparent': return { p: 2, align: 'center', icon: icon, iconColor: color, border: '1px solid', borderColor: color, borderRadius: 'large', backgroundColor: backgroundColor, discardButtonColor: undefined }; case 'solid': default: return { p: 2, align: 'center', icon: icon, iconColor: color, borderRadius: 'large', borderLeft: variant === 'default' ? 'none' : '4px solid', borderLeftColor: color, backgroundColor: backgroundColor, titleColor: 'black', discardButtonColor: 'black' }; } }; var _default = useAlertStyles; exports.default = _default;