@blerp/design 1.2.11 → 1.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1495,215 +1495,6 @@ Blerp$1.propTypes = {
1495
1495
  handleClickTitle: PropTypes.func.isRequired
1496
1496
  };
1497
1497
 
1498
- var BlerpAudioContext = /*#__PURE__*/createContext({});
1499
- var BlerpAudioContextProvider$1 = function BlerpAudioContextProvider(_ref) {
1500
- var children = _ref.children;
1501
-
1502
- if (typeof window === "undefined") {
1503
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children);
1504
- }
1505
-
1506
- var _useState = useState(null),
1507
- _useState2 = _slicedToArray(_useState, 2),
1508
- selectedBlerp = _useState2[0],
1509
- _setSelectedBlerp = _useState2[1];
1510
-
1511
- var _useState3 = useState("stopped"),
1512
- _useState4 = _slicedToArray(_useState3, 2),
1513
- playState = _useState4[0],
1514
- setPlayState = _useState4[1];
1515
-
1516
- var _useState5 = useState(0),
1517
- _useState6 = _slicedToArray(_useState5, 2);
1518
- _useState6[0];
1519
- var setStartTime = _useState6[1]; // const [audioCtx, setAudioCtx] = useState(null);
1520
- // Refs
1521
-
1522
-
1523
- var audioRef = useRef(new Audio());
1524
-
1525
- var pause = /*#__PURE__*/function () {
1526
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1527
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1528
- while (1) {
1529
- switch (_context.prev = _context.next) {
1530
- case 0:
1531
- setPlayState("paused");
1532
- _context.next = 3;
1533
- return audioRef.current.pause();
1534
-
1535
- case 3:
1536
- case "end":
1537
- return _context.stop();
1538
- }
1539
- }
1540
- }, _callee);
1541
- }));
1542
-
1543
- return function pause() {
1544
- return _ref2.apply(this, arguments);
1545
- };
1546
- }();
1547
-
1548
- var play = /*#__PURE__*/function () {
1549
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
1550
- var _bite$audio, _bite$audio$mp;
1551
-
1552
- var bite, _ref3$gain, gain, _ref3$startTime, startTime, _ref3$forcePlay, forcePlay, newGain, audioCtx, gainNode, source;
1553
-
1554
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1555
- while (1) {
1556
- switch (_context3.prev = _context3.next) {
1557
- case 0:
1558
- bite = _ref3.bite, _ref3$gain = _ref3.gain, gain = _ref3$gain === void 0 ? 1 : _ref3$gain, _ref3$startTime = _ref3.startTime, startTime = _ref3$startTime === void 0 ? 0 : _ref3$startTime, _ref3$forcePlay = _ref3.forcePlay, forcePlay = _ref3$forcePlay === void 0 ? false : _ref3$forcePlay;
1559
- console.log("astats", startTime, playState);
1560
- startTime = audioRef.current.currentTime > 0 ? audioRef.current.currentTime : startTime;
1561
- console.log("play", playState, startTime);
1562
-
1563
- if (!((bite === null || bite === void 0 ? void 0 : bite._id) !== (selectedBlerp === null || selectedBlerp === void 0 ? void 0 : selectedBlerp._id) && playState === "playing")) {
1564
- _context3.next = 8;
1565
- break;
1566
- }
1567
-
1568
- _context3.next = 7;
1569
- return audioRef.current.pause();
1570
-
1571
- case 7:
1572
- if (!forcePlay) {
1573
- startTime = 0;
1574
- }
1575
-
1576
- case 8:
1577
- if (!(playState === "playing" && (bite === null || bite === void 0 ? void 0 : bite._id) === (selectedBlerp === null || selectedBlerp === void 0 ? void 0 : selectedBlerp._id))) {
1578
- _context3.next = 11;
1579
- break;
1580
- }
1581
-
1582
- pause();
1583
- return _context3.abrupt("return");
1584
-
1585
- case 11:
1586
- audioRef.current = new Audio(bite === null || bite === void 0 ? void 0 : (_bite$audio = bite.audio) === null || _bite$audio === void 0 ? void 0 : (_bite$audio$mp = _bite$audio.mp3) === null || _bite$audio$mp === void 0 ? void 0 : _bite$audio$mp.url);
1587
- audioRef.current.crossOrigin = "anonymous";
1588
- console.log("current time", startTime);
1589
- audioRef.current.currentTime = startTime;
1590
- newGain = gain;
1591
- audioRef.current.onended = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
1592
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1593
- while (1) {
1594
- switch (_context2.prev = _context2.next) {
1595
- case 0:
1596
- console.log("ended");
1597
- setPlayState("played");
1598
- _context2.next = 4;
1599
- return audioRef.current.pause();
1600
-
1601
- case 4:
1602
- audioRef.current.currentTime = 0;
1603
-
1604
- case 5:
1605
- case "end":
1606
- return _context2.stop();
1607
- }
1608
- }
1609
- }, _callee2);
1610
- }));
1611
- audioCtx = new (window.AudioContext || window.webkitAudioContext)();
1612
- gainNode = audioCtx.createGain(); // gainNode.gain.value = 2 // value between 0 and 2 https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API
1613
-
1614
- gainNode.gain.setValueAtTime(newGain, 0);
1615
- source = audioCtx.createMediaElementSource(audioRef.current);
1616
- source.connect(gainNode);
1617
- gainNode.connect(audioCtx.destination);
1618
- _context3.next = 25;
1619
- return audioRef.current.play().then(function () {
1620
- console.log("playing", bite === null || bite === void 0 ? void 0 : bite.title);
1621
- setPlayState("playing");
1622
- }).catch(function (e) {
1623
- setPlayState("stopped");
1624
- });
1625
-
1626
- case 25:
1627
- // const playPromise = audioRef.current.play();
1628
- // if (playPromise !== undefined) {
1629
- // playPromise
1630
- // .then((_) => {
1631
- // // Automatic playback started!
1632
- // // Show playing UI.
1633
- // setPlayState("playing");
1634
- // })
1635
- // .catch((error) => {
1636
- // // Auto-play was prevented
1637
- // // Show paused UI.
1638
- // console.log("playing failed witihin", error);
1639
- // });
1640
- // }
1641
- _setSelectedBlerp(bite);
1642
-
1643
- case 26:
1644
- case "end":
1645
- return _context3.stop();
1646
- }
1647
- }
1648
- }, _callee3);
1649
- }));
1650
-
1651
- return function play(_x) {
1652
- return _ref4.apply(this, arguments);
1653
- };
1654
- }();
1655
-
1656
- return /*#__PURE__*/React__default.createElement(BlerpAudioContext.Provider, {
1657
- value: {
1658
- selectedBlerp: selectedBlerp,
1659
- setSelectedBlerp: function setSelectedBlerp(_ref6) {
1660
- var bite = _ref6.bite;
1661
-
1662
- _setSelectedBlerp(bite);
1663
- },
1664
- pause: pause,
1665
- play: play,
1666
- stop: function () {
1667
- var _stop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
1668
- var _audioRef$current;
1669
-
1670
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
1671
- while (1) {
1672
- switch (_context4.prev = _context4.next) {
1673
- case 0:
1674
- setPlayState("stopped");
1675
- _context4.next = 3;
1676
- return (_audioRef$current = audioRef.current) === null || _audioRef$current === void 0 ? void 0 : _audioRef$current.pause();
1677
-
1678
- case 3:
1679
- audioRef.current.currentTime = 0;
1680
-
1681
- case 4:
1682
- case "end":
1683
- return _context4.stop();
1684
- }
1685
- }
1686
- }, _callee4);
1687
- }));
1688
-
1689
- function stop() {
1690
- return _stop.apply(this, arguments);
1691
- }
1692
-
1693
- return stop;
1694
- }(),
1695
- getPlayState: function getPlayState(_ref7) {
1696
- var biteId = _ref7.biteId;
1697
-
1698
- if (biteId === (selectedBlerp && selectedBlerp._id)) {
1699
- return playState;
1700
- }
1701
- },
1702
- setStartTime: setStartTime
1703
- }
1704
- }, children);
1705
- };
1706
-
1707
1498
  var _templateObject$f, _templateObject2$a;
1708
1499
  var PremiumContainer = styled.div(_templateObject$f || (_templateObject$f = _taggedTemplateLiteral(["\n background: transparent;\n overflow: hidden;\n min-width: 210px;\n max-width: 260px;\n width: 100%;\n max-height: 322px;\n flex: 1;\n min-height: 272px;\n margin: 20px;\n aspect-ratio: 260 / 322;\n gap: 10px;\n border-radius: 18px;\n box-sizing: border-box;\n padding: 2px;\n position: relative;\n transition: 0.3s;\n"])));
1709
1500
  var Container$1 = styled.div(_templateObject2$a || (_templateObject2$a = _taggedTemplateLiteral(["\n background-color: ", ";\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n position: relative;\n height: 100%;\n padding: 10px;\n border-radius: 17px;\n box-sizing: border-box;\n"])), function (props) {
@@ -2111,15 +1902,10 @@ var ReportedWarning = function ReportedWarning(_ref7) {
2111
1902
  var NewBlerp$1 = function NewBlerp(_ref8) {
2112
1903
  var _bite$image, _bite$image$original, _bite$ownerObject;
2113
1904
 
2114
- var _ref8$Waveform = _ref8.Waveform,
2115
- Waveform = _ref8$Waveform === void 0 ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null) : _ref8$Waveform,
2116
- bite = _ref8.bite;
2117
- _ref8.playState;
2118
-
2119
- var _useContext = useContext(BlerpAudioContext),
2120
- play = _useContext.play,
2121
- getPlayState = _useContext.getPlayState;
2122
- _useContext.stop;
1905
+ var Waveform = _ref8.Waveform,
1906
+ bite = _ref8.bite,
1907
+ playState = _ref8.playState,
1908
+ play = _ref8.play;
2123
1909
 
2124
1910
  var _useState9 = useState(false),
2125
1911
  _useState10 = _slicedToArray(_useState9, 2),
@@ -2137,10 +1923,6 @@ var NewBlerp$1 = function NewBlerp(_ref8) {
2137
1923
  var saveCount = formatter.format(bite === null || bite === void 0 ? void 0 : bite.totalSaveCount);
2138
1924
 
2139
1925
  var renderPlayStateIcon = function renderPlayStateIcon() {
2140
- var playState = getPlayState({
2141
- biteId: bite === null || bite === void 0 ? void 0 : bite._id
2142
- });
2143
-
2144
1926
  if (playState === "played") {
2145
1927
  return /*#__PURE__*/React__default.createElement("svg", {
2146
1928
  xmlns: "http://www.w3.org/2000/svg",
@@ -2296,7 +2078,9 @@ var NewBlerp$1 = function NewBlerp(_ref8) {
2296
2078
  pointerEvents: "none",
2297
2079
  zIndex: "1"
2298
2080
  }
2299
- }, renderPlayStateIcon()), Waveform && /*#__PURE__*/React__default.createElement(Waveform, null)), /*#__PURE__*/React__default.createElement(Text, {
2081
+ }, renderPlayStateIcon()), Waveform({
2082
+ hovering: hovering
2083
+ })), /*#__PURE__*/React__default.createElement(Text, {
2300
2084
  sx: {
2301
2085
  fontSize: "16px",
2302
2086
  fontWeight: "400",
@@ -2392,6 +2176,211 @@ var NewBlerp$1 = function NewBlerp(_ref8) {
2392
2176
  }, ((bite === null || bite === void 0 ? void 0 : bite.audioDuration) / 1000).toFixed(0), "s"))));
2393
2177
  };
2394
2178
 
2179
+ var BlerpAudioContext = /*#__PURE__*/createContext({});
2180
+ var BlerpAudioContextProvider$1 = function BlerpAudioContextProvider(_ref) {
2181
+ var children = _ref.children;
2182
+
2183
+ var _useState = useState(null),
2184
+ _useState2 = _slicedToArray(_useState, 2),
2185
+ selectedBlerp = _useState2[0],
2186
+ _setSelectedBlerp = _useState2[1];
2187
+
2188
+ var _useState3 = useState("stopped"),
2189
+ _useState4 = _slicedToArray(_useState3, 2),
2190
+ playState = _useState4[0],
2191
+ setPlayState = _useState4[1];
2192
+
2193
+ var _useState5 = useState(0),
2194
+ _useState6 = _slicedToArray(_useState5, 2);
2195
+ _useState6[0];
2196
+ var setStartTime = _useState6[1]; // const [audioCtx, setAudioCtx] = useState(null);
2197
+ // Refs
2198
+
2199
+
2200
+ var audioRef = useRef(null);
2201
+
2202
+ var pause = /*#__PURE__*/function () {
2203
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
2204
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
2205
+ while (1) {
2206
+ switch (_context.prev = _context.next) {
2207
+ case 0:
2208
+ setPlayState("paused");
2209
+ _context.next = 3;
2210
+ return audioRef.current.pause();
2211
+
2212
+ case 3:
2213
+ case "end":
2214
+ return _context.stop();
2215
+ }
2216
+ }
2217
+ }, _callee);
2218
+ }));
2219
+
2220
+ return function pause() {
2221
+ return _ref2.apply(this, arguments);
2222
+ };
2223
+ }();
2224
+
2225
+ var play = /*#__PURE__*/function () {
2226
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
2227
+ var _bite$audio, _bite$audio$mp;
2228
+
2229
+ var bite, _ref3$gain, gain, _ref3$startTime, startTime, _ref3$forcePlay, forcePlay, newGain, audioCtx, gainNode, source;
2230
+
2231
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
2232
+ while (1) {
2233
+ switch (_context3.prev = _context3.next) {
2234
+ case 0:
2235
+ bite = _ref3.bite, _ref3$gain = _ref3.gain, gain = _ref3$gain === void 0 ? 1 : _ref3$gain, _ref3$startTime = _ref3.startTime, startTime = _ref3$startTime === void 0 ? 0 : _ref3$startTime, _ref3$forcePlay = _ref3.forcePlay, forcePlay = _ref3$forcePlay === void 0 ? false : _ref3$forcePlay;
2236
+ console.log("astats", startTime, playState);
2237
+ startTime = audioRef.current.currentTime > 0 ? audioRef.current.currentTime : startTime;
2238
+ console.log("play", playState, startTime);
2239
+
2240
+ if (!((bite === null || bite === void 0 ? void 0 : bite._id) !== (selectedBlerp === null || selectedBlerp === void 0 ? void 0 : selectedBlerp._id) && playState === "playing")) {
2241
+ _context3.next = 8;
2242
+ break;
2243
+ }
2244
+
2245
+ _context3.next = 7;
2246
+ return audioRef.current.pause();
2247
+
2248
+ case 7:
2249
+ if (!forcePlay) {
2250
+ startTime = 0;
2251
+ }
2252
+
2253
+ case 8:
2254
+ if (!(playState === "playing" && (bite === null || bite === void 0 ? void 0 : bite._id) === (selectedBlerp === null || selectedBlerp === void 0 ? void 0 : selectedBlerp._id))) {
2255
+ _context3.next = 11;
2256
+ break;
2257
+ }
2258
+
2259
+ pause();
2260
+ return _context3.abrupt("return");
2261
+
2262
+ case 11:
2263
+ audioRef.current = new Audio(bite === null || bite === void 0 ? void 0 : (_bite$audio = bite.audio) === null || _bite$audio === void 0 ? void 0 : (_bite$audio$mp = _bite$audio.mp3) === null || _bite$audio$mp === void 0 ? void 0 : _bite$audio$mp.url);
2264
+ audioRef.current.crossOrigin = "anonymous";
2265
+ console.log("current time", startTime);
2266
+ audioRef.current.currentTime = startTime;
2267
+ newGain = gain;
2268
+ audioRef.current.onended = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
2269
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
2270
+ while (1) {
2271
+ switch (_context2.prev = _context2.next) {
2272
+ case 0:
2273
+ console.log("ended");
2274
+ setPlayState("played");
2275
+ _context2.next = 4;
2276
+ return audioRef.current.pause();
2277
+
2278
+ case 4:
2279
+ audioRef.current.currentTime = 0;
2280
+
2281
+ case 5:
2282
+ case "end":
2283
+ return _context2.stop();
2284
+ }
2285
+ }
2286
+ }, _callee2);
2287
+ }));
2288
+ audioCtx = new (window.AudioContext || window.webkitAudioContext)();
2289
+ gainNode = audioCtx.createGain(); // gainNode.gain.value = 2 // value between 0 and 2 https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API
2290
+
2291
+ gainNode.gain.setValueAtTime(newGain, 0);
2292
+ source = audioCtx.createMediaElementSource(audioRef.current);
2293
+ source.connect(gainNode);
2294
+ gainNode.connect(audioCtx.destination);
2295
+ _context3.next = 25;
2296
+ return audioRef.current.play().then(function () {
2297
+ console.log("playing", bite === null || bite === void 0 ? void 0 : bite.title);
2298
+ setPlayState("playing");
2299
+ }).catch(function (e) {
2300
+ setPlayState("stopped");
2301
+ });
2302
+
2303
+ case 25:
2304
+ // const playPromise = audioRef.current.play();
2305
+ // if (playPromise !== undefined) {
2306
+ // playPromise
2307
+ // .then((_) => {
2308
+ // // Automatic playback started!
2309
+ // // Show playing UI.
2310
+ // setPlayState("playing");
2311
+ // })
2312
+ // .catch((error) => {
2313
+ // // Auto-play was prevented
2314
+ // // Show paused UI.
2315
+ // console.log("playing failed witihin", error);
2316
+ // });
2317
+ // }
2318
+ _setSelectedBlerp(bite);
2319
+
2320
+ case 26:
2321
+ case "end":
2322
+ return _context3.stop();
2323
+ }
2324
+ }
2325
+ }, _callee3);
2326
+ }));
2327
+
2328
+ return function play(_x) {
2329
+ return _ref4.apply(this, arguments);
2330
+ };
2331
+ }();
2332
+
2333
+ return /*#__PURE__*/React__default.createElement(BlerpAudioContext.Provider, {
2334
+ value: {
2335
+ selectedBlerp: selectedBlerp,
2336
+ setSelectedBlerp: function setSelectedBlerp(_ref6) {
2337
+ var bite = _ref6.bite;
2338
+
2339
+ _setSelectedBlerp(bite);
2340
+ },
2341
+ pause: pause,
2342
+ play: play,
2343
+ stop: function () {
2344
+ var _stop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
2345
+ var _audioRef$current;
2346
+
2347
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
2348
+ while (1) {
2349
+ switch (_context4.prev = _context4.next) {
2350
+ case 0:
2351
+ setPlayState("stopped");
2352
+ _context4.next = 3;
2353
+ return (_audioRef$current = audioRef.current) === null || _audioRef$current === void 0 ? void 0 : _audioRef$current.pause();
2354
+
2355
+ case 3:
2356
+ audioRef.current.currentTime = 0;
2357
+
2358
+ case 4:
2359
+ case "end":
2360
+ return _context4.stop();
2361
+ }
2362
+ }
2363
+ }, _callee4);
2364
+ }));
2365
+
2366
+ function stop() {
2367
+ return _stop.apply(this, arguments);
2368
+ }
2369
+
2370
+ return stop;
2371
+ }(),
2372
+ getPlayState: function getPlayState(_ref7) {
2373
+ var biteId = _ref7.biteId;
2374
+
2375
+ if (biteId === (selectedBlerp && selectedBlerp._id)) {
2376
+ return playState;
2377
+ }
2378
+ },
2379
+ setStartTime: setStartTime
2380
+ }
2381
+ }, children);
2382
+ };
2383
+
2395
2384
  var _templateObject$e, _templateObject2$9, _templateObject3$7, _templateObject4$6, _templateObject5$4, _templateObject6$4, _templateObject7$2;
2396
2385
  var BlerpImage$1 = styled.div(_templateObject$e || (_templateObject$e = _taggedTemplateLiteral(["\n height: 150px;\n width: 150px;\n background-image: url(", ");\n background-size: cover;\n border-radius: 50%;\n position: relative;\n transition: 0.2s;\n\n &:hover {\n transform: scale(1.1);\n }\n"])), function (props) {
2397
2386
  return props.url;
@@ -5684,7 +5673,7 @@ var BlerpTheme = function BlerpTheme(_ref) {
5684
5673
  icons: icons,
5685
5674
  mode: mode === "dark" ? "dark" : "light"
5686
5675
  }, currentTheme)
5687
- }, /*#__PURE__*/React__default.createElement(SnackbarProvider, null, /*#__PURE__*/React__default.createElement(BlerpAudioContextProvider$1, null, children))));
5676
+ }, /*#__PURE__*/React__default.createElement(SnackbarProvider, null, children)));
5688
5677
  };
5689
5678
 
5690
5679
  var LottieAnimation = function LottieAnimation(_ref) {