fdfa4c44437a258029d39e2c7ccb1117.json 12 KB

1
  1. {"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nexport function isUnitless(value) {\n return String(parseFloat(value)).length === String(value).length;\n} // Ported from Compass\n// https://github.com/Compass/compass/blob/master/core/stylesheets/compass/typography/_units.scss\n// Emulate the sass function \"unit\"\n\nexport function getUnit(input) {\n return String(input).match(/[\\d.\\-+]*\\s*(.*)/)[1] || '';\n} // Emulate the sass function \"unitless\"\n\nexport function toUnitless(length) {\n return parseFloat(length);\n} // Convert any CSS <length> or <percentage> value to any another.\n// From https://github.com/KyleAMathews/convert-css-length\n\nexport function convertLength(baseFontSize) {\n return function (length, toUnit) {\n var fromUnit = getUnit(length); // Optimize for cases where `from` and `to` units are accidentally the same.\n\n if (fromUnit === toUnit) {\n return length;\n } // Convert input length to pixels.\n\n\n var pxLength = toUnitless(length);\n\n if (fromUnit !== 'px') {\n if (fromUnit === 'em') {\n pxLength = toUnitless(length) * toUnitless(baseFontSize);\n } else if (fromUnit === 'rem') {\n pxLength = toUnitless(length) * toUnitless(baseFontSize);\n return length;\n }\n } // Convert length in pixels to the output unit\n\n\n var outputLength = pxLength;\n\n if (toUnit !== 'px') {\n if (toUnit === 'em') {\n outputLength = pxLength / toUnitless(baseFontSize);\n } else if (toUnit === 'rem') {\n outputLength = pxLength / toUnitless(baseFontSize);\n } else {\n return length;\n }\n }\n\n return parseFloat(outputLength.toFixed(5)) + toUnit;\n };\n}\nexport function alignProperty(_ref) {\n var size = _ref.size,\n grid = _ref.grid;\n var sizeBelow = size - size % grid;\n var sizeAbove = sizeBelow + grid;\n return size - sizeBelow < sizeAbove - size ? sizeBelow : sizeAbove;\n} // fontGrid finds a minimal grid (in rem) for the fontSize values so that the\n// lineHeight falls under a x pixels grid, 4px in the case of Material Design,\n// without changing the relative line height\n\nexport function fontGrid(_ref2) {\n var lineHeight = _ref2.lineHeight,\n pixels = _ref2.pixels,\n htmlFontSize = _ref2.htmlFontSize;\n return pixels / (lineHeight * htmlFontSize);\n}\n/**\n * generate a responsive version of a given CSS property\n * @example\n * responsiveProperty({\n * cssProperty: 'fontSize',\n * min: 15,\n * max: 20,\n * unit: 'px',\n * breakpoints: [300, 600],\n * })\n *\n * // this returns\n *\n * {\n * fontSize: '15px',\n * '@media (min-width:300px)': {\n * fontSize: '17.5px',\n * },\n * '@media (min-width:600px)': {\n * fontSize: '20px',\n * },\n * }\n *\n * @param {Object} params\n * @param {string} params.cssProperty - The CSS property to be made responsive\n * @param {number} params.min - The smallest value of the CSS property\n * @param {number} params.max - The largest value of the CSS property\n * @param {string} [params.unit] - The unit to be used for the CSS property\n * @param {Array.number} [params.breakpoints] - An array of breakpoints\n * @param {number} [params.alignStep] - Round scaled value to fall under this grid\n * @returns {Object} responsive styles for {params.cssProperty}\n */\n\nexport function responsiveProperty(_ref3) {\n var cssProperty = _ref3.cssProperty,\n min = _ref3.min,\n max = _ref3.max,\n _ref3$unit = _ref3.unit,\n unit = _ref3$unit === void 0 ? 'rem' : _ref3$unit,\n _ref3$breakpoints = _ref3.breakpoints,\n breakpoints = _ref3$breakpoints === void 0 ? [600, 960, 1280] : _ref3$breakpoints,\n _ref3$transform = _ref3.transform,\n transform = _ref3$transform === void 0 ? null : _ref3$transform;\n\n var output = _defineProperty({}, cssProperty, \"\".concat(min).concat(unit));\n\n var factor = (max - min) / breakpoints[breakpoints.length - 1];\n breakpoints.forEach(function (breakpoint) {\n var value = min + factor * breakpoint;\n\n if (transform !== null) {\n value = transform(value);\n }\n\n output[\"@media (min-width:\".concat(breakpoint, \"px)\")] = _defineProperty({}, cssProperty, \"\".concat(Math.round(value * 10000) / 10000).concat(unit));\n });\n return output;\n}","map":{"version":3,"sources":["/Users/holunyeung/Documents/GitHub/Photo_React/photo/node_modules/@material-ui/core/esm/styles/cssUtils.js"],"names":["_defineProperty","isUnitless","value","String","parseFloat","length","getUnit","input","match","toUnitless","convertLength","baseFontSize","toUnit","fromUnit","pxLength","outputLength","toFixed","alignProperty","_ref","size","grid","sizeBelow","sizeAbove","fontGrid","_ref2","lineHeight","pixels","htmlFontSize","responsiveProperty","_ref3","cssProperty","min","max","_ref3$unit","unit","_ref3$breakpoints","breakpoints","_ref3$transform","transform","output","concat","factor","forEach","breakpoint","Math","round"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAO,SAASC,UAAT,CAAoBC,KAApB,EAA2B;AAChC,SAAOC,MAAM,CAACC,UAAU,CAACF,KAAD,CAAX,CAAN,CAA0BG,MAA1B,KAAqCF,MAAM,CAACD,KAAD,CAAN,CAAcG,MAA1D;AACD,C,CAAC;AACF;AACA;;AAEA,OAAO,SAASC,OAAT,CAAiBC,KAAjB,EAAwB;AAC7B,SAAOJ,MAAM,CAACI,KAAD,CAAN,CAAcC,KAAd,CAAoB,kBAApB,EAAwC,CAAxC,KAA8C,EAArD;AACD,C,CAAC;;AAEF,OAAO,SAASC,UAAT,CAAoBJ,MAApB,EAA4B;AACjC,SAAOD,UAAU,CAACC,MAAD,CAAjB;AACD,C,CAAC;AACF;;AAEA,OAAO,SAASK,aAAT,CAAuBC,YAAvB,EAAqC;AAC1C,SAAO,UAAUN,MAAV,EAAkBO,MAAlB,EAA0B;AAC/B,QAAIC,QAAQ,GAAGP,OAAO,CAACD,MAAD,CAAtB,CAD+B,CACC;;AAEhC,QAAIQ,QAAQ,KAAKD,MAAjB,EAAyB;AACvB,aAAOP,MAAP;AACD,KAL8B,CAK7B;;;AAGF,QAAIS,QAAQ,GAAGL,UAAU,CAACJ,MAAD,CAAzB;;AAEA,QAAIQ,QAAQ,KAAK,IAAjB,EAAuB;AACrB,UAAIA,QAAQ,KAAK,IAAjB,EAAuB;AACrBC,QAAAA,QAAQ,GAAGL,UAAU,CAACJ,MAAD,CAAV,GAAqBI,UAAU,CAACE,YAAD,CAA1C;AACD,OAFD,MAEO,IAAIE,QAAQ,KAAK,KAAjB,EAAwB;AAC7BC,QAAAA,QAAQ,GAAGL,UAAU,CAACJ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AA4B,KAAtC,EAA6CsC,MAA7C,CAAoDN,IAApD,CAAlB,CAAxE;AACD,GARD;AASA,SAAOK,MAAP;AACD","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nexport function isUnitless(value) {\n return String(parseFloat(value)).length === String(value).length;\n} // Ported from Compass\n// https://github.com/Compass/compass/blob/master/core/stylesheets/compass/typography/_units.scss\n// Emulate the sass function \"unit\"\n\nexport function getUnit(input) {\n return String(input).match(/[\\d.\\-+]*\\s*(.*)/)[1] || '';\n} // Emulate the sass function \"unitless\"\n\nexport function toUnitless(length) {\n return parseFloat(length);\n} // Convert any CSS <length> or <percentage> value to any another.\n// From https://github.com/KyleAMathews/convert-css-length\n\nexport function convertLength(baseFontSize) {\n return function (length, toUnit) {\n var fromUnit = getUnit(length); // Optimize for cases where `from` and `to` units are accidentally the same.\n\n if (fromUnit === toUnit) {\n return length;\n } // Convert input length to pixels.\n\n\n var pxLength = toUnitless(length);\n\n if (fromUnit !== 'px') {\n if (fromUnit === 'em') {\n pxLength = toUnitless(length) * toUnitless(baseFontSize);\n } else if (fromUnit === 'rem') {\n pxLength = toUnitless(length) * toUnitless(baseFontSize);\n return length;\n }\n } // Convert length in pixels to the output unit\n\n\n var outputLength = pxLength;\n\n if (toUnit !== 'px') {\n if (toUnit === 'em') {\n outputLength = pxLength / toUnitless(baseFontSize);\n } else if (toUnit === 'rem') {\n outputLength = pxLength / toUnitless(baseFontSize);\n } else {\n return length;\n }\n }\n\n return parseFloat(outputLength.toFixed(5)) + toUnit;\n };\n}\nexport function alignProperty(_ref) {\n var size = _ref.size,\n grid = _ref.grid;\n var sizeBelow = size - size % grid;\n var sizeAbove = sizeBelow + grid;\n return size - sizeBelow < sizeAbove - size ? sizeBelow : sizeAbove;\n} // fontGrid finds a minimal grid (in rem) for the fontSize values so that the\n// lineHeight falls under a x pixels grid, 4px in the case of Material Design,\n// without changing the relative line height\n\nexport function fontGrid(_ref2) {\n var lineHeight = _ref2.lineHeight,\n pixels = _ref2.pixels,\n htmlFontSize = _ref2.htmlFontSize;\n return pixels / (lineHeight * htmlFontSize);\n}\n/**\n * generate a responsive version of a given CSS property\n * @example\n * responsiveProperty({\n * cssProperty: 'fontSize',\n * min: 15,\n * max: 20,\n * unit: 'px',\n * breakpoints: [300, 600],\n * })\n *\n * // this returns\n *\n * {\n * fontSize: '15px',\n * '@media (min-width:300px)': {\n * fontSize: '17.5px',\n * },\n * '@media (min-width:600px)': {\n * fontSize: '20px',\n * },\n * }\n *\n * @param {Object} params\n * @param {string} params.cssProperty - The CSS property to be made responsive\n * @param {number} params.min - The smallest value of the CSS property\n * @param {number} params.max - The largest value of the CSS property\n * @param {string} [params.unit] - The unit to be used for the CSS property\n * @param {Array.number} [params.breakpoints] - An array of breakpoints\n * @param {number} [params.alignStep] - Round scaled value to fall under this grid\n * @returns {Object} responsive styles for {params.cssProperty}\n */\n\nexport function responsiveProperty(_ref3) {\n var cssProperty = _ref3.cssProperty,\n min = _ref3.min,\n max = _ref3.max,\n _ref3$unit = _ref3.unit,\n unit = _ref3$unit === void 0 ? 'rem' : _ref3$unit,\n _ref3$breakpoints = _ref3.breakpoints,\n breakpoints = _ref3$breakpoints === void 0 ? [600, 960, 1280] : _ref3$breakpoints,\n _ref3$transform = _ref3.transform,\n transform = _ref3$transform === void 0 ? null : _ref3$transform;\n\n var output = _defineProperty({}, cssProperty, \"\".concat(min).concat(unit));\n\n var factor = (max - min) / breakpoints[breakpoints.length - 1];\n breakpoints.forEach(function (breakpoint) {\n var value = min + factor * breakpoint;\n\n if (transform !== null) {\n value = transform(value);\n }\n\n output[\"@media (min-width:\".concat(breakpoint, \"px)\")] = _defineProperty({}, cssProperty, \"\".concat(Math.round(value * 10000) / 10000).concat(unit));\n });\n return output;\n}"]},"metadata":{},"sourceType":"module"}