@gympass/yoga-helpers
Advanced tools
Comparing version 1.0.4 to 1.0.5
136
cjs/hide.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var hide_exports = {}; | ||
__export(hide_exports, { | ||
default: () => hide_default | ||
}); | ||
exports["default"] = void 0; | ||
var _yogaTokens = _interopRequireDefault(require("@gympass/yoga-tokens")); | ||
var _styledComponents = require("styled-components"); | ||
var _media = require("./media"); | ||
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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 _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var breakpoints = _yogaTokens["default"].breakpoints; | ||
var availableBreakpoints = Object.entries(breakpoints); | ||
var hide = function hide(isNot) { | ||
return availableBreakpoints.reduce(function (acc, _ref, index) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
key = _ref2[0], | ||
breakpoint = _ref2[1]; | ||
if (index === 0) { | ||
var _availableBreakpoints = _slicedToArray(availableBreakpoints[index + 1], 2), | ||
secondBreakpoint = _availableBreakpoints[1]; | ||
acc[key] = (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n @media ", " (max-width: ", "px) {\n display: none !important;\n }\n "])), (0, _media.not)(isNot), secondBreakpoint.width); | ||
acc["".concat(key, "-start")] = (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media ", " (min-width: ", "px) {\n display: none !important;\n }\n "])), (0, _media.not)(isNot), breakpoint.width); | ||
return acc; | ||
} | ||
if (index === availableBreakpoints.length - 1) { | ||
acc[key] = (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n @media ", " (min-width: ", "px) {\n display: none !important;\n }\n "])), (0, _media.not)(isNot), breakpoint.width); | ||
return acc; | ||
} | ||
var _availableBreakpoints2 = _slicedToArray(availableBreakpoints[index + 1], 2), | ||
nextBreakpoint = _availableBreakpoints2[1]; | ||
acc[key] = (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n @media ", " (min-width: ", "px) and (max-width: ", "px) {\n display: none !important;\n }\n "])), (0, _media.not)(isNot), breakpoint.width, nextBreakpoint.width - 1); | ||
acc["".concat(key, "-start")] = (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n @media ", " (min-width: ", "px) {\n display: none !important;\n }\n "])), (0, _media.not)(isNot), breakpoint.width); | ||
module.exports = __toCommonJS(hide_exports); | ||
var import_yoga_tokens = __toESM(require("@gympass/yoga-tokens")); | ||
var import_styled_components = require("styled-components"); | ||
var import_media = require("./media"); | ||
const { breakpoints } = import_yoga_tokens.default; | ||
const availableBreakpoints = Object.entries(breakpoints); | ||
const hide = (isNot) => availableBreakpoints.reduce((acc, [key, breakpoint], index) => { | ||
if (index === 0) { | ||
const [, secondBreakpoint] = availableBreakpoints[index + 1]; | ||
acc[key] = import_styled_components.css` | ||
@media ${(0, import_media.not)(isNot)} (max-width: ${secondBreakpoint.width}px) { | ||
display: none !important; | ||
} | ||
`; | ||
acc[`${key}-start`] = import_styled_components.css` | ||
@media ${(0, import_media.not)(isNot)} (min-width: ${breakpoint.width}px) { | ||
display: none !important; | ||
} | ||
`; | ||
return acc; | ||
}, {}); | ||
}; | ||
var _default = hide; | ||
exports["default"] = _default; | ||
} | ||
if (index === availableBreakpoints.length - 1) { | ||
acc[key] = import_styled_components.css` | ||
@media ${(0, import_media.not)(isNot)} (min-width: ${breakpoint.width}px) { | ||
display: none !important; | ||
} | ||
`; | ||
return acc; | ||
} | ||
const [, nextBreakpoint] = availableBreakpoints[index + 1]; | ||
acc[key] = import_styled_components.css` | ||
@media ${(0, import_media.not)( | ||
isNot | ||
)} (min-width: ${breakpoint.width}px) and (max-width: ${nextBreakpoint.width - 1}px) { | ||
display: none !important; | ||
} | ||
`; | ||
acc[`${key}-start`] = import_styled_components.css` | ||
@media ${(0, import_media.not)(isNot)} (min-width: ${breakpoint.width}px) { | ||
display: none !important; | ||
} | ||
`; | ||
return acc; | ||
}, {}); | ||
var hide_default = hide; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "media", { | ||
enumerable: true, | ||
get: function get() { | ||
return _media["default"]; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
media: () => import_media.default | ||
}); | ||
var _media = _interopRequireDefault(require("./media")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
module.exports = __toCommonJS(src_exports); | ||
var import_media = __toESM(require("./media")); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
media | ||
}); |
153
cjs/media.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var media_exports = {}; | ||
__export(media_exports, { | ||
default: () => media_default, | ||
matcher: () => matcher, | ||
not: () => not | ||
}); | ||
exports.not = exports.matcher = exports["default"] = void 0; | ||
var _yogaTokens = _interopRequireDefault(require("@gympass/yoga-tokens")); | ||
var _styledComponents = require("styled-components"); | ||
var _hide = _interopRequireDefault(require("./hide")); | ||
var _templateObject; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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 _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var breakpoints = _yogaTokens["default"].breakpoints; | ||
var media = { | ||
module.exports = __toCommonJS(media_exports); | ||
var import_yoga_tokens = __toESM(require("@gympass/yoga-tokens")); | ||
var import_styled_components = require("styled-components"); | ||
var import_hide = __toESM(require("./hide")); | ||
const { breakpoints } = import_yoga_tokens.default; | ||
const media = { | ||
not: {} | ||
}; | ||
var not = function not(isNot) { | ||
return isNot ? 'not all and ' : ''; | ||
}; | ||
exports.not = not; | ||
var availableBreakpoints = Object.keys(breakpoints); | ||
var getRange = function getRange(width, range) { | ||
const not = (isNot) => isNot ? "not all and " : ""; | ||
const availableBreakpoints = Object.keys(breakpoints); | ||
const getRange = (width, range) => { | ||
try { | ||
if (Array.isArray(width)) { | ||
var _width = _slicedToArray(width, 2), | ||
min = _width[0], | ||
max = _width[1]; | ||
var minBreakpoint = breakpoints[min].width, | ||
maxBreakpoint = breakpoints[max].width; | ||
return "(min-width: ".concat(minBreakpoint, "px) and (max-width: ").concat(maxBreakpoint, "px)"); | ||
const [min, max] = width; | ||
const { | ||
[min]: { width: minBreakpoint }, | ||
[max]: { width: maxBreakpoint } | ||
} = breakpoints; | ||
return `(min-width: ${minBreakpoint}px) and (max-width: ${maxBreakpoint}px)`; | ||
} | ||
return "(".concat(range, "-width: ").concat(breakpoints[width].width, "px)"); | ||
} catch (_unused) { | ||
var msg = "Make sure you've entered the right breakpoints. \n Your input: ".concat(Array.isArray(width) ? width.join(', ') : width, "\n Available breakpoints: ").concat(availableBreakpoints.join(', ')); | ||
return `(${range}-width: ${breakpoints[width].width}px)`; | ||
} catch (e) { | ||
const msg = `Make sure you've entered the right breakpoints. | ||
Your input: ${Array.isArray(width) ? width.join(", ") : width} | ||
Available breakpoints: ${availableBreakpoints.join(", ")}`; | ||
throw new Error(msg); | ||
} | ||
}; | ||
var matcher = function matcher(width) { | ||
var isNot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var range = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'min'; | ||
return function () { | ||
return (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n @media ", "", " {\n ", "\n }\n "])), not(isNot), getRange(width, range), _styledComponents.css.apply(void 0, arguments)); | ||
}; | ||
}; | ||
exports.matcher = matcher; | ||
availableBreakpoints.forEach(function (breakpoint) { | ||
const matcher = (width, isNot = false, range = "min") => (...style) => import_styled_components.css` | ||
@media ${not(isNot)}${getRange(width, range)} { | ||
${(0, import_styled_components.css)(...style)} | ||
} | ||
`; | ||
availableBreakpoints.forEach((breakpoint) => { | ||
media[breakpoint] = matcher(breakpoint); | ||
media.not[breakpoint] = matcher(breakpoint, true); | ||
}); | ||
media.max = function (width) { | ||
return matcher(width, false, 'max'); | ||
}; | ||
media.not.max = function (width) { | ||
return matcher(width, true, 'max'); | ||
}; | ||
media.between = function (min, max) { | ||
return matcher([min, max], false, 'max'); | ||
}; | ||
media.not.between = function (min, max) { | ||
return matcher([min, max], true, 'max'); | ||
}; | ||
media.hide = (0, _hide["default"])(); | ||
media.not.hide = (0, _hide["default"])(true); | ||
var _default = media; | ||
exports["default"] = _default; | ||
media.max = (width) => matcher(width, false, "max"); | ||
media.not.max = (width) => matcher(width, true, "max"); | ||
media.between = (min, max) => matcher([min, max], false, "max"); | ||
media.not.between = (min, max) => matcher([min, max], true, "max"); | ||
media.hide = (0, import_hide.default)(); | ||
media.not.hide = (0, import_hide.default)(true); | ||
var media_default = media; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
matcher, | ||
not | ||
}); |
@@ -1,52 +0,47 @@ | ||
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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 _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
import tokens from '@gympass/yoga-tokens'; | ||
import { css } from 'styled-components'; | ||
import { not } from './media'; | ||
var breakpoints = tokens.breakpoints; | ||
var availableBreakpoints = Object.entries(breakpoints); | ||
var hide = function hide(isNot) { | ||
return availableBreakpoints.reduce(function (acc, _ref, index) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
key = _ref2[0], | ||
breakpoint = _ref2[1]; | ||
if (index === 0) { | ||
var _availableBreakpoints = _slicedToArray(availableBreakpoints[index + 1], 2), | ||
secondBreakpoint = _availableBreakpoints[1]; | ||
acc[key] = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n @media ", " (max-width: ", "px) {\n display: none !important;\n }\n "])), not(isNot), secondBreakpoint.width); | ||
acc["".concat(key, "-start")] = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media ", " (min-width: ", "px) {\n display: none !important;\n }\n "])), not(isNot), breakpoint.width); | ||
return acc; | ||
} | ||
if (index === availableBreakpoints.length - 1) { | ||
acc[key] = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n @media ", " (min-width: ", "px) {\n display: none !important;\n }\n "])), not(isNot), breakpoint.width); | ||
return acc; | ||
} | ||
var _availableBreakpoints2 = _slicedToArray(availableBreakpoints[index + 1], 2), | ||
nextBreakpoint = _availableBreakpoints2[1]; | ||
acc[key] = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n @media ", " (min-width: ", "px) and (max-width: ", "px) {\n display: none !important;\n }\n "])), not(isNot), breakpoint.width, nextBreakpoint.width - 1); | ||
acc["".concat(key, "-start")] = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n @media ", " (min-width: ", "px) {\n display: none !important;\n }\n "])), not(isNot), breakpoint.width); | ||
import tokens from "@gympass/yoga-tokens"; | ||
import { css } from "styled-components"; | ||
import { not } from "./media"; | ||
const { breakpoints } = tokens; | ||
const availableBreakpoints = Object.entries(breakpoints); | ||
const hide = (isNot) => availableBreakpoints.reduce((acc, [key, breakpoint], index) => { | ||
if (index === 0) { | ||
const [, secondBreakpoint] = availableBreakpoints[index + 1]; | ||
acc[key] = css` | ||
@media ${not(isNot)} (max-width: ${secondBreakpoint.width}px) { | ||
display: none !important; | ||
} | ||
`; | ||
acc[`${key}-start`] = css` | ||
@media ${not(isNot)} (min-width: ${breakpoint.width}px) { | ||
display: none !important; | ||
} | ||
`; | ||
return acc; | ||
}, {}); | ||
} | ||
if (index === availableBreakpoints.length - 1) { | ||
acc[key] = css` | ||
@media ${not(isNot)} (min-width: ${breakpoint.width}px) { | ||
display: none !important; | ||
} | ||
`; | ||
return acc; | ||
} | ||
const [, nextBreakpoint] = availableBreakpoints[index + 1]; | ||
acc[key] = css` | ||
@media ${not( | ||
isNot | ||
)} (min-width: ${breakpoint.width}px) and (max-width: ${nextBreakpoint.width - 1}px) { | ||
display: none !important; | ||
} | ||
`; | ||
acc[`${key}-start`] = css` | ||
@media ${not(isNot)} (min-width: ${breakpoint.width}px) { | ||
display: none !important; | ||
} | ||
`; | ||
return acc; | ||
}, {}); | ||
var hide_default = hide; | ||
export { | ||
hide_default as default | ||
}; | ||
export default hide; |
@@ -1,2 +0,4 @@ | ||
import media from './media'; | ||
export { media }; | ||
import media from "./media"; | ||
export { | ||
media | ||
}; |
100
esm/media.js
@@ -1,78 +0,48 @@ | ||
var _templateObject; | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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 _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
import tokens from '@gympass/yoga-tokens'; | ||
import { css } from 'styled-components'; | ||
import hide from './hide'; | ||
var breakpoints = tokens.breakpoints; | ||
var media = { | ||
import tokens from "@gympass/yoga-tokens"; | ||
import { css } from "styled-components"; | ||
import hide from "./hide"; | ||
const { breakpoints } = tokens; | ||
const media = { | ||
not: {} | ||
}; | ||
export var not = function not(isNot) { | ||
return isNot ? 'not all and ' : ''; | ||
}; | ||
var availableBreakpoints = Object.keys(breakpoints); | ||
var getRange = function getRange(width, range) { | ||
const not = (isNot) => isNot ? "not all and " : ""; | ||
const availableBreakpoints = Object.keys(breakpoints); | ||
const getRange = (width, range) => { | ||
try { | ||
if (Array.isArray(width)) { | ||
var _width = _slicedToArray(width, 2), | ||
min = _width[0], | ||
max = _width[1]; | ||
var minBreakpoint = breakpoints[min].width, | ||
maxBreakpoint = breakpoints[max].width; | ||
return "(min-width: ".concat(minBreakpoint, "px) and (max-width: ").concat(maxBreakpoint, "px)"); | ||
const [min, max] = width; | ||
const { | ||
[min]: { width: minBreakpoint }, | ||
[max]: { width: maxBreakpoint } | ||
} = breakpoints; | ||
return `(min-width: ${minBreakpoint}px) and (max-width: ${maxBreakpoint}px)`; | ||
} | ||
return "(".concat(range, "-width: ").concat(breakpoints[width].width, "px)"); | ||
} catch (_unused) { | ||
var msg = "Make sure you've entered the right breakpoints. \n Your input: ".concat(Array.isArray(width) ? width.join(', ') : width, "\n Available breakpoints: ").concat(availableBreakpoints.join(', ')); | ||
return `(${range}-width: ${breakpoints[width].width}px)`; | ||
} catch (e) { | ||
const msg = `Make sure you've entered the right breakpoints. | ||
Your input: ${Array.isArray(width) ? width.join(", ") : width} | ||
Available breakpoints: ${availableBreakpoints.join(", ")}`; | ||
throw new Error(msg); | ||
} | ||
}; | ||
export var matcher = function matcher(width) { | ||
var isNot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var range = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'min'; | ||
return function () { | ||
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n @media ", "", " {\n ", "\n }\n "])), not(isNot), getRange(width, range), css.apply(void 0, arguments)); | ||
}; | ||
}; | ||
availableBreakpoints.forEach(function (breakpoint) { | ||
const matcher = (width, isNot = false, range = "min") => (...style) => css` | ||
@media ${not(isNot)}${getRange(width, range)} { | ||
${css(...style)} | ||
} | ||
`; | ||
availableBreakpoints.forEach((breakpoint) => { | ||
media[breakpoint] = matcher(breakpoint); | ||
media.not[breakpoint] = matcher(breakpoint, true); | ||
}); | ||
media.max = function (width) { | ||
return matcher(width, false, 'max'); | ||
}; | ||
media.not.max = function (width) { | ||
return matcher(width, true, 'max'); | ||
}; | ||
media.between = function (min, max) { | ||
return matcher([min, max], false, 'max'); | ||
}; | ||
media.not.between = function (min, max) { | ||
return matcher([min, max], true, 'max'); | ||
}; | ||
media.max = (width) => matcher(width, false, "max"); | ||
media.not.max = (width) => matcher(width, true, "max"); | ||
media.between = (min, max) => matcher([min, max], false, "max"); | ||
media.not.between = (min, max) => matcher([min, max], true, "max"); | ||
media.hide = hide(); | ||
media.not.hide = hide(true); | ||
export default media; | ||
var media_default = media; | ||
export { | ||
media_default as default, | ||
matcher, | ||
not | ||
}; |
{ | ||
"version": "1.0.4", | ||
"name": "@gympass/yoga-helpers", | ||
"version": "1.0.5", | ||
"description": "Gympass helpers", | ||
@@ -14,6 +15,3 @@ "keywords": [ | ||
"main": "./cjs", | ||
"module": "./esm", | ||
"name": "@gympass/yoga-helpers", | ||
"private": false, | ||
"gitHead": "5f9883db8abeab6f4857005d3ea90a999ecb8453", | ||
"types": "./typings/index.d.ts", | ||
"publishConfig": { | ||
@@ -29,3 +27,6 @@ "access": "public", | ||
"url": "https://github.com/Gympass/yoga/issues" | ||
} | ||
} | ||
}, | ||
"gitHead": "ebe92119ee741b48f012de3ae4db802e5175143d", | ||
"module": "./esm", | ||
"private": false | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12
14121
316