UNPKG

es6-react-admin-lte

Version:

An AdminLTE Template made to use as React components.

126 lines (94 loc) 12 kB
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var Theme = /*#__PURE__*/function (_React$Component) { _inherits(Theme, _React$Component); var _super = _createSuper(Theme); function Theme() { _classCallCheck(this, Theme); return _super.apply(this, arguments); } _createClass(Theme, [{ key: "darkenColor", value: function darkenColor(color) { var newColor = color.indexOf('rgb') < 0 ? color.replace('#', '') : color.replace('rgba(', '').replace('rgb(', '').replace(')', '').replace(' ', '').split(','); if (typeof newColor === 'string') { newColor = "#".concat(newColor.split('').map(function (clr, c, clrList) { var numcol = Number(clr); switch (clr.toLowerCase()) { case 'a': return '9'; case 'b': return 'a'; case 'c': return 'b'; case 'd': return 'c'; case 'e': return 'd'; case 'f': return 'e'; default: return numcol > 0 ? numcol - 1 : numcol; } }).join('')); } else { newColor = newColor.length < 4 ? "rgb(".concat(newColor.map(function (clr) { return Number(clr) >= 10 ? Number(clr) - 10 : 0; }).join(', '), ")") : "rgba(".concat(newColor.map(function (clr, c) { if (c >= 3) { return clr; } return Number(clr) >= 5 ? Number(clr) - 5 : 0; }).join(', '), ")"); } return newColor; } }, { key: "componentDidMount", value: function componentDidMount() { var styleRef = document.createElement('STYLE'); styleRef.innerHTML = "\n .skin-".concat(this.props.name, " .main-header .navbar {\n background-color: ").concat(this.props.primary, ";\n }\n .skin-").concat(this.props.name, " .main-header .navbar .nav > li > a {\n color: ").concat(this.props.hasDarkText ? '#333' : '#fff', ";\n }\n .skin-").concat(this.props.name, " .main-header .navbar .nav > li > a:hover,\n .skin-").concat(this.props.name, " .main-header .navbar .nav > li > a:active,\n .skin-").concat(this.props.name, " .main-header .navbar .nav > li > a:focus,\n .skin-").concat(this.props.name, " .main-header .navbar .nav .open > a,\n .skin-").concat(this.props.name, " .main-header .navbar .nav .open > a:hover,\n .skin-").concat(this.props.name, " .main-header .navbar .nav .open > a:focus,\n .skin-").concat(this.props.name, " .main-header .navbar .nav > .active > a {\n background: rgba(0, 0, 0, 0.1);\n color: ").concat(this.props.hasDarkText ? '#999' : '#f6f6f6', ";\n }\n .skin-").concat(this.props.name, " .main-header .navbar .sidebar-toggle {\n color: ").concat(this.props.hasDarkText ? '#333' : '#fff', ";\n }\n .skin-").concat(this.props.name, " .main-header .navbar .sidebar-toggle:hover {\n color: ").concat(this.props.hasDarkText ? '#999' : '#f6f6f6', ";\n background: rgba(0, 0, 0, 0.1);\n }\n .skin-").concat(this.props.name, " .main-header .navbar .sidebar-toggle {\n color: ").concat(this.props.hasDarkText ? '#333' : '#fff', ";\n }\n .skin-").concat(this.props.name, " .main-header .navbar .sidebar-toggle:hover {\n background-color: ").concat(this.props.secondary, ";\n }\n @media (max-width: 767px) {\n .skin-").concat(this.props.name, " .main-header .navbar .dropdown-menu li.divider {\n background-color: rgba(0, 0, 0, 0.1);\n }\n .skin-").concat(this.props.name, " .main-header .navbar .dropdown-menu li a {\n color: #333;\n }\n }\n .skin-").concat(this.props.name, " .main-header .logo {\n background-color: ").concat(this.props.secondary, ";\n color: ").concat(this.props.hasDarkText ? '#333' : '#fff', ";\n border-bottom: 0 solid transparent;\n }\n .skin-").concat(this.props.name, " .main-header .logo:hover {\n background-color: ").concat(this.darkenColor(this.props.secondary), ";\n }\n .skin-").concat(this.props.name, " .main-header li.user-header {\n background-color: ").concat(this.props.primary, ";\n }\n .skin-").concat(this.props.name, " .content-header {\n background: transparent;\n }\n .skin-").concat(this.props.name, " .wrapper,\n .skin-").concat(this.props.name, " .main-sidebar,\n .skin-").concat(this.props.name, " .left-side {\n background-color: #222d32;\n }\n .skin-").concat(this.props.name, " .user-panel > .info,\n .skin-").concat(this.props.name, " .user-panel > .info > a {\n color: ").concat(this.props.hasDarkText ? '#333' : '#fff', ";\n }\n .skin-").concat(this.props.name, " .sidebar-menu > li.header {\n color: #4b646f;\n background: #1a2226;\n }\n .skin-").concat(this.props.name, " .sidebar-menu > li > a {\n border-left: 3px solid transparent;\n }\n .skin-").concat(this.props.name, " .sidebar-menu > li:hover > a,\n .skin-").concat(this.props.name, " .sidebar-menu > li.active > a {\n color: #fff;\n background: #1e282c;\n border-left-color: ").concat(this.props.primary, ";\n }\n .skin-").concat(this.props.name, " .main-sidebar-light { background-color: #f9f9f9; }\n .skin-").concat(this.props.name, " .main-sidebar-light > .sidebar .sidebar-menu > li a:hover,\n .skin-").concat(this.props.name, " .main-sidebar-light > .sidebar .sidebar-menu > li.treeview.active a {\n border-left-color: ").concat(this.props.primary, ";\n }\n .skin-").concat(this.props.name, " .sidebar-menu > li > .treeview-menu {\n margin: 0 1px;\n background: #2c3b41;\n }\n .skin-").concat(this.props.name, " .sidebar a {\n color: #b8c7ce;\n }\n .skin-").concat(this.props.name, " .sidebar a:hover {\n text-decoration: none;\n }\n .skin-").concat(this.props.name, " .treeview-menu > li > a {\n color: #8aa4af;\n }\n .skin-").concat(this.props.name, " .treeview-menu > li.active > a,\n .skin-").concat(this.props.name, " .treeview-menu > li > a:hover {\n color: #fff;\n }\n .skin-").concat(this.props.name, " .sidebar-form {\n border-radius: 3px;\n border: 1px solid #374850;\n margin: 10px 10px;\n }\n .skin-").concat(this.props.name, " .sidebar-form input[type=\"text\"],\n .skin-").concat(this.props.name, " .sidebar-form .btn {\n box-shadow: none;\n background-color: #374850;\n border: 1px solid transparent;\n height: 35px;\n }\n .skin-").concat(this.props.name, " .sidebar-form input[type=\"text\"] {\n color: #666;\n border-top-left-radius: 2px;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 2px;\n }\n .skin-").concat(this.props.name, " .sidebar-form input[type=\"text\"]:focus,\n .skin-").concat(this.props.name, " .sidebar-form input[type=\"text\"]:focus + .input-group-btn .btn {\n background-color: #fff;\n color: #666;\n }\n .skin-").concat(this.props.name, " .sidebar-form input[type=\"text\"]:focus + .input-group-btn .btn {\n border-left-color: #fff;\n }\n .skin-").concat(this.props.name, " .sidebar-form .btn {\n color: #999;\n border-top-left-radius: 0;\n border-top-right-radius: 2px;\n border-bottom-right-radius: 2px;\n border-bottom-left-radius: 0;\n }\n ").concat(this.props.specialStyles, "\n "); document.head.appendChild(styleRef); } }, { key: "render", value: function render() { return null; } }]); return Theme; }(_react["default"].Component); Theme.propTypes = { name: _propTypes["default"].string.isRequired, primary: _propTypes["default"].string, secondary: _propTypes["default"].string, hasDarkText: _propTypes["default"].bool, specialStyles: _propTypes["default"].string }; Theme.defaultProps = { hasDarkText: false, primary: '#3c8dbc', secondary: '#357ca5', specialStyles: '' }; var _default = Theme; exports["default"] = _default; module.exports = exports.default; //# sourceMappingURL=theme.js.map