UNPKG

@geezee/react-ui

Version:

Modern and minimalist React UI library.

45 lines (41 loc) 2.17 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; import _JSXStyle from "styled-jsx/style"; import React, { useMemo } from 'react'; import withDefaults from '../utils/with-defaults'; import useTheme from '../styles/use-theme'; var defaultProps = { type: 'default', className: '' }; var getColor = function getColor(type, theme) { var colors = { "default": theme.palette.accents_2, success: theme.palette.success, warning: theme.palette.warning, error: theme.palette.error }; return colors[type] || colors["default"]; }; var Dot = function Dot(_ref) { var type = _ref.type, children = _ref.children, className = _ref.className, props = _objectWithoutProperties(_ref, ["type", "children", "className"]); var theme = useTheme(); var color = useMemo(function () { return getColor(type, theme); }, [type, theme]); return /*#__PURE__*/React.createElement("span", _extends({}, props, { className: _JSXStyle.dynamic([["1187438594", [color]]]) + " " + (props && props.className != null && props.className || "dot ".concat(className)) }), /*#__PURE__*/React.createElement("span", { className: _JSXStyle.dynamic([["1187438594", [color]]]) + " " + "icon" }), /*#__PURE__*/React.createElement("span", { className: _JSXStyle.dynamic([["1187438594", [color]]]) + " " + "label" }, children), /*#__PURE__*/React.createElement(_JSXStyle, { id: "1187438594", dynamic: [color] }, ".dot.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.icon.__jsx-style-dynamic-selector{width:0.625rem;height:0.625rem;border-radius:50%;background-color:".concat(color, ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}.label.__jsx-style-dynamic-selector{margin-left:8px;font-size:1rem;text-transform:capitalize;}"))); }; var MemoDot = React.memo(Dot); export default withDefaults(MemoDot, defaultProps);