html-squircle
Version:
Utilities for generating superellipse squircles in the form of SVG strings, to be used in clip-path and background inline styles.
37 lines (36 loc) • 1.26 kB
JavaScript
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = /*#__PURE__*/factory(require, exports);
if (v !== undefined) module.exports = v;
} else if (typeof define === "function" && define.amd) {
define(["require", "exports", "react/jsx-runtime", "react", "../utils/LRUCache.js"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CacheProvider = exports.useCache = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const React = require("react");
const LRUCache_js_1 = require("../utils/LRUCache.js");
const CacheContext = React.createContext(null);
const useCache = () => React.useContext(CacheContext);
exports.useCache = useCache;
/**
* Optional cache provider component for enabling global caching of computed
* squircle values.
*/
const CacheProvider = ({
capacity = 20,
children
}) => {
const [cache] = React.useState(() => new LRUCache_js_1.LRUCache(capacity));
cache.setCapacity(capacity);
return (0, jsx_runtime_1.jsx)(CacheContext, {
value: cache,
children: children
});
};
exports.CacheProvider = CacheProvider;
});