UNPKG

design-system-starter

Version:
887 lines (716 loc) • 30.3 kB
/* design-system-starter v0.0.10 © 2019 Ryan Fitzer */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var React = require('react'); var React__default = _interopDefault(React); var propTypes = require('prop-types'); 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); return Constructor; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } var tokens = {colorLink:'blue',colorBorder:'#666',fontBase:'"Helvetica Neue", Helvetica, Arial, sans-serif'}; var ThemeContext=React.createContext(tokens);var useTheme=function useTheme(overrides){var theme=React.useContext(ThemeContext);var result=React.useMemo(function(){if(theme&&overrides){return Object.assign({},theme,overrides);}return theme||overrides;},[theme,overrides]);return result;};var ThemeProvider=/*#__PURE__*/function(_Component){_inherits(ThemeProvider,_Component);function ThemeProvider(){_classCallCheck(this,ThemeProvider);return _possibleConstructorReturn(this,_getPrototypeOf(ThemeProvider).apply(this,arguments));}_createClass(ThemeProvider,[{key:"render",value:function render(){return React__default.createElement(ThemeContext.Provider,{value:this.props.theme},this.props.children);}}]);return ThemeProvider;}(React.Component);_defineProperty(ThemeProvider,"defaultProps",{theme:tokens});_defineProperty(ThemeProvider,"propTypes",{children:propTypes.object,theme:propTypes.object.isRequired}); function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } function hash(str) { var hash = 5381, i = str.length; while(i) { hash = (hash * 33) ^ str.charCodeAt(--i); } /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed * integers. Since we want the results to be always positive, convert the * signed int to an unsigned by doing an unsigned bitshift. */ return hash >>> 0; } var stringHash = hash; var stylesheet = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; 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); return Constructor; } /* Based on Glamor's sheet https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js */ var isProd = process.env && process.env.NODE_ENV === 'production'; var isString = function isString(o) { return Object.prototype.toString.call(o) === '[object String]'; }; var StyleSheet = /*#__PURE__*/ function () { function StyleSheet() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref$name = _ref.name, name = _ref$name === void 0 ? 'stylesheet' : _ref$name, _ref$optimizeForSpeed = _ref.optimizeForSpeed, optimizeForSpeed = _ref$optimizeForSpeed === void 0 ? isProd : _ref$optimizeForSpeed, _ref$isBrowser = _ref.isBrowser, isBrowser = _ref$isBrowser === void 0 ? typeof window !== 'undefined' : _ref$isBrowser; _classCallCheck(this, StyleSheet); invariant(isString(name), '`name` must be a string'); this._name = name; this._deletedRulePlaceholder = "#".concat(name, "-deleted-rule____{}"); invariant(typeof optimizeForSpeed === 'boolean', '`optimizeForSpeed` must be a boolean'); this._optimizeForSpeed = optimizeForSpeed; this._isBrowser = isBrowser; this._serverSheet = undefined; this._tags = []; this._injected = false; this._rulesCount = 0; var node = this._isBrowser && document.querySelector('meta[property="csp-nonce"]'); this._nonce = node ? node.getAttribute('content') : null; } _createClass(StyleSheet, [{ key: "setOptimizeForSpeed", value: function setOptimizeForSpeed(bool) { invariant(typeof bool === 'boolean', '`setOptimizeForSpeed` accepts a boolean'); invariant(this._rulesCount === 0, 'optimizeForSpeed cannot be when rules have already been inserted'); this.flush(); this._optimizeForSpeed = bool; this.inject(); } }, { key: "isOptimizeForSpeed", value: function isOptimizeForSpeed() { return this._optimizeForSpeed; } }, { key: "inject", value: function inject() { var _this = this; invariant(!this._injected, 'sheet already injected'); this._injected = true; if (this._isBrowser && this._optimizeForSpeed) { this._tags[0] = this.makeStyleTag(this._name); this._optimizeForSpeed = 'insertRule' in this.getSheet(); if (!this._optimizeForSpeed) { if (!isProd) { console.warn('StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.'); } this.flush(); this._injected = true; } return; } this._serverSheet = { cssRules: [], insertRule: function insertRule(rule, index) { if (typeof index === 'number') { _this._serverSheet.cssRules[index] = { cssText: rule }; } else { _this._serverSheet.cssRules.push({ cssText: rule }); } return index; }, deleteRule: function deleteRule(index) { _this._serverSheet.cssRules[index] = null; } }; } }, { key: "getSheetForTag", value: function getSheetForTag(tag) { if (tag.sheet) { return tag.sheet; } // this weirdness brought to you by firefox for (var i = 0; i < document.styleSheets.length; i++) { if (document.styleSheets[i].ownerNode === tag) { return document.styleSheets[i]; } } } }, { key: "getSheet", value: function getSheet() { return this.getSheetForTag(this._tags[this._tags.length - 1]); } }, { key: "insertRule", value: function insertRule(rule, index) { invariant(isString(rule), '`insertRule` accepts only strings'); if (!this._isBrowser) { if (typeof index !== 'number') { index = this._serverSheet.cssRules.length; } this._serverSheet.insertRule(rule, index); return this._rulesCount++; } if (this._optimizeForSpeed) { var sheet = this.getSheet(); if (typeof index !== 'number') { index = sheet.cssRules.length; } // this weirdness for perf, and chrome's weird bug // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule try { sheet.insertRule(rule, index); } catch (error) { if (!isProd) { console.warn("StyleSheet: illegal rule: \n\n".concat(rule, "\n\nSee https://stackoverflow.com/q/20007992 for more info")); } return -1; } } else { var insertionPoint = this._tags[index]; this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint)); } return this._rulesCount++; } }, { key: "replaceRule", value: function replaceRule(index, rule) { if (this._optimizeForSpeed || !this._isBrowser) { var sheet = this._isBrowser ? this.getSheet() : this._serverSheet; if (!rule.trim()) { rule = this._deletedRulePlaceholder; } if (!sheet.cssRules[index]) { // @TBD Should we throw an error? return index; } sheet.deleteRule(index); try { sheet.insertRule(rule, index); } catch (error) { if (!isProd) { console.warn("StyleSheet: illegal rule: \n\n".concat(rule, "\n\nSee https://stackoverflow.com/q/20007992 for more info")); } // In order to preserve the indices we insert a deleteRulePlaceholder sheet.insertRule(this._deletedRulePlaceholder, index); } } else { var tag = this._tags[index]; invariant(tag, "old rule at index `".concat(index, "` not found")); tag.textContent = rule; } return index; } }, { key: "deleteRule", value: function deleteRule(index) { if (!this._isBrowser) { this._serverSheet.deleteRule(index); return; } if (this._optimizeForSpeed) { this.replaceRule(index, ''); } else { var tag = this._tags[index]; invariant(tag, "rule at index `".concat(index, "` not found")); tag.parentNode.removeChild(tag); this._tags[index] = null; } } }, { key: "flush", value: function flush() { this._injected = false; this._rulesCount = 0; if (this._isBrowser) { this._tags.forEach(function (tag) { return tag && tag.parentNode.removeChild(tag); }); this._tags = []; } else { // simpler on server this._serverSheet.cssRules = []; } } }, { key: "cssRules", value: function cssRules() { var _this2 = this; if (!this._isBrowser) { return this._serverSheet.cssRules; } return this._tags.reduce(function (rules, tag) { if (tag) { rules = rules.concat(_this2.getSheetForTag(tag).cssRules.map(function (rule) { return rule.cssText === _this2._deletedRulePlaceholder ? null : rule; })); } else { rules.push(null); } return rules; }, []); } }, { key: "makeStyleTag", value: function makeStyleTag(name, cssString, relativeToTag) { if (cssString) { invariant(isString(cssString), 'makeStyleTag acceps only strings as second parameter'); } var tag = document.createElement('style'); if (this._nonce) tag.setAttribute('nonce', this._nonce); tag.type = 'text/css'; tag.setAttribute("data-".concat(name), ''); if (cssString) { tag.appendChild(document.createTextNode(cssString)); } var head = document.head || document.getElementsByTagName('head')[0]; if (relativeToTag) { head.insertBefore(tag, relativeToTag); } else { head.appendChild(tag); } return tag; } }, { key: "length", get: function get() { return this._rulesCount; } }]); return StyleSheet; }(); exports.default = StyleSheet; function invariant(condition, message) { if (!condition) { throw new Error("StyleSheet: ".concat(message, ".")); } } }); unwrapExports(stylesheet); var stylesheetRegistry = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _stringHash = _interopRequireDefault(stringHash); var _stylesheet = _interopRequireDefault(stylesheet); 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); return Constructor; } var sanitize = function sanitize(rule) { return rule.replace(/\/style/gi, '\\/style'); }; var StyleSheetRegistry = /*#__PURE__*/ function () { function StyleSheetRegistry() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref$styleSheet = _ref.styleSheet, styleSheet = _ref$styleSheet === void 0 ? null : _ref$styleSheet, _ref$optimizeForSpeed = _ref.optimizeForSpeed, optimizeForSpeed = _ref$optimizeForSpeed === void 0 ? false : _ref$optimizeForSpeed, _ref$isBrowser = _ref.isBrowser, isBrowser = _ref$isBrowser === void 0 ? typeof window !== 'undefined' : _ref$isBrowser; _classCallCheck(this, StyleSheetRegistry); this._sheet = styleSheet || new _stylesheet.default({ name: 'styled-jsx', optimizeForSpeed: optimizeForSpeed }); this._sheet.inject(); if (styleSheet && typeof optimizeForSpeed === 'boolean') { this._sheet.setOptimizeForSpeed(optimizeForSpeed); this._optimizeForSpeed = this._sheet.isOptimizeForSpeed(); } this._isBrowser = isBrowser; this._fromServer = undefined; this._indices = {}; this._instancesCounts = {}; this.computeId = this.createComputeId(); this.computeSelector = this.createComputeSelector(); } _createClass(StyleSheetRegistry, [{ key: "add", value: function add(props) { var _this = this; if (undefined === this._optimizeForSpeed) { this._optimizeForSpeed = Array.isArray(props.children); this._sheet.setOptimizeForSpeed(this._optimizeForSpeed); this._optimizeForSpeed = this._sheet.isOptimizeForSpeed(); } if (this._isBrowser && !this._fromServer) { this._fromServer = this.selectFromServer(); this._instancesCounts = Object.keys(this._fromServer).reduce(function (acc, tagName) { acc[tagName] = 0; return acc; }, {}); } var _this$getIdAndRules = this.getIdAndRules(props), styleId = _this$getIdAndRules.styleId, rules = _this$getIdAndRules.rules; // Deduping: just increase the instances count. if (styleId in this._instancesCounts) { this._instancesCounts[styleId] += 1; return; } var indices = rules.map(function (rule) { return _this._sheet.insertRule(rule); }) // Filter out invalid rules .filter(function (index) { return index !== -1; }); this._indices[styleId] = indices; this._instancesCounts[styleId] = 1; } }, { key: "remove", value: function remove(props) { var _this2 = this; var _this$getIdAndRules2 = this.getIdAndRules(props), styleId = _this$getIdAndRules2.styleId; invariant(styleId in this._instancesCounts, "styleId: `".concat(styleId, "` not found")); this._instancesCounts[styleId] -= 1; if (this._instancesCounts[styleId] < 1) { var tagFromServer = this._fromServer && this._fromServer[styleId]; if (tagFromServer) { tagFromServer.parentNode.removeChild(tagFromServer); delete this._fromServer[styleId]; } else { this._indices[styleId].forEach(function (index) { return _this2._sheet.deleteRule(index); }); delete this._indices[styleId]; } delete this._instancesCounts[styleId]; } } }, { key: "update", value: function update(props, nextProps) { this.add(nextProps); this.remove(props); } }, { key: "flush", value: function flush() { this._sheet.flush(); this._sheet.inject(); this._fromServer = undefined; this._indices = {}; this._instancesCounts = {}; this.computeId = this.createComputeId(); this.computeSelector = this.createComputeSelector(); } }, { key: "cssRules", value: function cssRules() { var _this3 = this; var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function (styleId) { return [styleId, _this3._fromServer[styleId]]; }) : []; var cssRules = this._sheet.cssRules(); return fromServer.concat(Object.keys(this._indices).map(function (styleId) { return [styleId, _this3._indices[styleId].map(function (index) { return cssRules[index].cssText; }).join(_this3._optimizeForSpeed ? '' : '\n')]; }) // filter out empty rules .filter(function (rule) { return Boolean(rule[1]); })); } /** * createComputeId * * Creates a function to compute and memoize a jsx id from a basedId and optionally props. */ }, { key: "createComputeId", value: function createComputeId() { var cache = {}; return function (baseId, props) { if (!props) { return "jsx-".concat(baseId); } var propsToString = String(props); var key = baseId + propsToString; // return `jsx-${hashString(`${baseId}-${propsToString}`)}` if (!cache[key]) { cache[key] = "jsx-".concat((0, _stringHash.default)("".concat(baseId, "-").concat(propsToString))); } return cache[key]; }; } /** * createComputeSelector * * Creates a function to compute and memoize dynamic selectors. */ }, { key: "createComputeSelector", value: function createComputeSelector() { var selectoPlaceholderRegexp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : /__jsx-style-dynamic-selector/g; var cache = {}; return function (id, css) { // Sanitize SSR-ed CSS. // Client side code doesn't need to be sanitized since we use // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod). if (!this._isBrowser) { css = sanitize(css); } var idcss = id + css; if (!cache[idcss]) { cache[idcss] = css.replace(selectoPlaceholderRegexp, id); } return cache[idcss]; }; } }, { key: "getIdAndRules", value: function getIdAndRules(props) { var _this4 = this; var css = props.children, dynamic = props.dynamic, id = props.id; if (dynamic) { var styleId = this.computeId(id, dynamic); return { styleId: styleId, rules: Array.isArray(css) ? css.map(function (rule) { return _this4.computeSelector(styleId, rule); }) : [this.computeSelector(styleId, css)] }; } return { styleId: this.computeId(id), rules: Array.isArray(css) ? css : [css] }; } /** * selectFromServer * * Collects style tags from the document with id __jsx-XXX */ }, { key: "selectFromServer", value: function selectFromServer() { var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]')); return elements.reduce(function (acc, element) { var id = element.id.slice(2); acc[id] = element; return acc; }, {}); } }]); return StyleSheetRegistry; }(); exports.default = StyleSheetRegistry; function invariant(condition, message) { if (!condition) { throw new Error("StyleSheetRegistry: ".concat(message, ".")); } } }); unwrapExports(stylesheetRegistry); var style = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.flush = flush; exports.default = void 0; var _stylesheetRegistry = _interopRequireDefault(stylesheetRegistry); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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); return Constructor; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } 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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); 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); } var styleSheetRegistry = new _stylesheetRegistry.default(); var JSXStyle = /*#__PURE__*/ function (_Component) { _inherits(JSXStyle, _Component); function JSXStyle(props) { var _this; _classCallCheck(this, JSXStyle); _this = _possibleConstructorReturn(this, _getPrototypeOf(JSXStyle).call(this, props)); _this.prevProps = {}; return _this; } _createClass(JSXStyle, [{ key: "shouldComponentUpdate", // probably faster than PureComponent (shallowEqual) value: function shouldComponentUpdate(otherProps) { return this.props.id !== otherProps.id || // We do this check because `dynamic` is an array of strings or undefined. // These are the computed values for dynamic styles. String(this.props.dynamic) !== String(otherProps.dynamic); } }, { key: "componentWillUnmount", value: function componentWillUnmount() { styleSheetRegistry.remove(this.props); } }, { key: "render", value: function render() { // This is a workaround to make the side effect async safe in the "render" phase. // See https://github.com/zeit/styled-jsx/pull/484 if (this.shouldComponentUpdate(this.prevProps)) { // Updates if (this.prevProps.id) { styleSheetRegistry.remove(this.prevProps); } styleSheetRegistry.add(this.props); this.prevProps = this.props; } return null; } }], [{ key: "dynamic", value: function dynamic(info) { return info.map(function (tagInfo) { var baseId = tagInfo[0]; var props = tagInfo[1]; return styleSheetRegistry.computeId(baseId, props); }).join(' '); } }]); return JSXStyle; }(React__default.Component); exports.default = JSXStyle; function flush() { var cssRules = styleSheetRegistry.cssRules(); styleSheetRegistry.flush(); return cssRules; } }); unwrapExports(style); var style_1 = style.flush; var style$1 = style; /** * Button * * @param {String} text - The text to display. * @param {Function} [onClick] - An onClick handler. * @param {Object} [theme] - A theme object. * * @returns {HTMLElement} */var Button=function Button(_ref){var text=_ref.text,onClick=_ref.onClick,theme=_ref.theme;var tokens=useTheme(theme);return React__default.createElement(React.Fragment,null,React__default.createElement("button",{type:"button",onClick:onClick,className:style$1.dynamic([["4220076112",[tokens.fontBase,tokens.colorLink,tokens.colorBorder]]])+" "+'button'},text),React__default.createElement(style$1,{id:"4220076112",dynamic:[tokens.fontBase,tokens.colorLink,tokens.colorBorder]},[".button.__jsx-style-dynamic-selector{font-family:".concat(tokens.fontBase,";background-color:").concat(tokens.colorLink,";}"),".button.__jsx-style-dynamic-selector:hover{background-color:".concat(tokens.colorBorder,";}")]));};Button.propTypes={text:propTypes.string.isRequired,onClick:propTypes.func,theme:propTypes.object}; /** * Clicker * * @param {Object} [theme] - A theme object. * * @returns {HTMLElement} */var Clicker=function Clicker(_ref){var theme=_ref.theme;var _useState=React.useState(0),_useState2=_slicedToArray(_useState,2),count=_useState2[0],setCount=_useState2[1];var tokens=useTheme(theme);function updateCount(){setCount(count+1);}React.useEffect(function(){document.title="You clicked ".concat(count," times");});return React__default.createElement(React.Fragment,null,React__default.createElement("div",{className:style$1.dynamic([["3821067583",[tokens.fontBase]]])},React__default.createElement("p",{className:style$1.dynamic([["3821067583",[tokens.fontBase]]])+" "+'msg'},"You clicked ",count," ",count===1?'time':'times'),React__default.createElement(Button,{text:"Click Me!",onClick:updateCount})),React__default.createElement(style$1,{id:"3821067583",dynamic:[tokens.fontBase]},[".msg.__jsx-style-dynamic-selector{font-family:".concat(tokens.fontBase,";}")]));};Clicker.propTypes={theme:propTypes.object}; /** * Link * * @param {String} href - Link destination. * @param {String} text - The text to display. * @param {Object} [theme] - A theme object. * * @returns {HTMLElement} */var Link=function Link(_ref){var text=_ref.text,href=_ref.href,theme=_ref.theme;var tokens=useTheme(theme);return React__default.createElement(React.Fragment,null,React__default.createElement("a",{href:href,className:style$1.dynamic([["3524212557",[tokens.colorLink,tokens.fontBase,tokens.colorBorder]]])},text),React__default.createElement(style$1,{id:"3524212557",dynamic:[tokens.colorLink,tokens.fontBase,tokens.colorBorder]},["a.__jsx-style-dynamic-selector{color:".concat(tokens.colorLink,";font-family:").concat(tokens.fontBase,";}"),"a.__jsx-style-dynamic-selector:hover{color:".concat(tokens.colorBorder,";}")]));};Link.propTypes={href:propTypes.string.isRequired,text:propTypes.string.isRequired,theme:propTypes.object}; exports.Button = Button; exports.Clicker = Clicker; exports.Link = Link; exports.ThemeProvider = ThemeProvider; exports.useTheme = useTheme;