@streamlayer/react-ui 0.36.0 → 0.37.1

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.
@@ -1,20 +1,21 @@
1
- import { jsx as o, jsxs as f } from "react/jsx-runtime";
2
- import { useStore as A } from "@nanostores/react";
3
- import { useState as S, useCallback as F, useEffect as E } from "react";
4
- import { FeatureType as B } from "@streamlayer/sdk-web-types";
5
- import { StreamLayerThemeProvider as C } from "../theme/index.js";
6
- import { mastersVariables as O } from "../theme/masters.js";
7
- import { ActiveFeature as g } from "./Features/index.js";
8
- import { MastersNavigation as x } from "./Navigation/MastersNavigation/index.js";
9
- import { SDKContainer as I, SDKScrollContainer as L } from "./styles.js";
10
- import { useSdkFeature as M } from "./useSdkFeature.js";
11
- import { FeaturedGroupsButtonId as i } from "../navigation/button/FeaturedGroups.js";
12
- import { ChannelsButtonId as s } from "../navigation/button/Channels.js";
13
- import { LeaderBoardButtonId as v } from "../navigation/button/LeaderBoard.js";
1
+ import { jsx as t, jsxs as e } from "react/jsx-runtime";
2
+ import { StreamLayerThemeProvider as u } from "../theme/index.js";
3
+ import { mastersVariables as f } from "../theme/masters.js";
4
+ import { ActiveFeature as v } from "./Features/index.js";
5
+ import { MastersNavigation as y } from "./Navigation/MastersNavigation/index.js";
6
+ import { SDKContainer as S, SDKScrollContainer as h } from "./styles.js";
7
+ import { useMastersApp as b } from "./useMastersApp.js";
8
+ import { useSdkFeature as k } from "./useSdkFeature.js";
9
+ import { ChannelsButtonId as A } from "../navigation/button/Channels.js";
10
+ import { LeaderBoardButtonId as a } from "../navigation/button/LeaderBoard.js";
11
+ import { FeaturedGroupsButtonId as B } from "../navigation/button/FeaturedGroups.js";
14
12
  import "../theme/theme.js";
15
13
  import "@linaria/core";
16
14
  import "../theme/constants.js";
15
+ import "react";
16
+ import "@streamlayer/sdk-web-types";
17
17
  import "./Features/FeatureProvider.js";
18
+ import "@nanostores/react";
18
19
  import "@streamlayer/sdk-web-interfaces";
19
20
  import "./Features/Gamification/index.js";
20
21
  import "./Features/Gamification/Question.js";
@@ -74,49 +75,30 @@ import "../navigation/index.js";
74
75
  import "../icons/index.js";
75
76
  import "../navigation/button/index.js";
76
77
  import "../navigation/button/styles.js";
77
- const j = ({ sdk: t }) => {
78
- const [, m] = M(t);
79
- return /* @__PURE__ */ o(g, { feature: m, sdk: t });
80
- }, rr = ({ sdk: t, overlays: m, children: l, event: c }) => {
81
- const [e, u] = S(!1), a = A(t.status) === "ready", [r, d] = S(i), n = F(
82
- (p) => {
83
- d(p), p === i ? (t.createEventSession(c), t.openFeature(B.GAMES)) : t.closeFeature();
84
- },
85
- [c, t]
78
+ const F = ({ sdk: o }) => {
79
+ const [, i] = k(o);
80
+ return /* @__PURE__ */ t(v, { feature: i, sdk: o });
81
+ }, Ur = ({ sdk: o, overlays: i, children: p, event: n }) => {
82
+ const { sdkEnabled: m, sdkReady: s, activeOverlay: r, activateAndLoadOverlay: d, enableSdk: l, disableSdk: c } = b(
83
+ o,
84
+ n
86
85
  );
87
- E(() => {
88
- !a && r === i && (d(s), t.closeFeature());
89
- }, [a, r, t]);
90
- const y = () => {
91
- t.initializeApp().then(({ enabled: p, err: h }) => {
92
- if (u(!0), h) {
93
- n(s);
94
- return;
95
- }
96
- if (p) {
97
- n(i);
98
- return;
99
- }
100
- });
101
- }, b = () => {
102
- u(!1), t.disableApp();
103
- };
104
- return /* @__PURE__ */ o(C, { style: { height: "100%" }, children: /* @__PURE__ */ f(I, { className: O, children: [
105
- e && /* @__PURE__ */ o(
106
- x,
86
+ return /* @__PURE__ */ t(u, { style: { height: "100%" }, children: /* @__PURE__ */ e(S, { className: f, children: [
87
+ m && /* @__PURE__ */ t(
88
+ y,
107
89
  {
108
- sdkReady: a,
90
+ sdkReady: s,
109
91
  activeOverlay: r,
110
- setActiveOverlay: n
92
+ setActiveOverlay: d
111
93
  }
112
94
  ),
113
- /* @__PURE__ */ f(L, { "data-nav": e.toString(), children: [
114
- /* @__PURE__ */ o("div", { style: { display: !e || r === s ? "block" : "none" }, children: l && l({ enableSdk: y, disableSdk: b }) }),
115
- /* @__PURE__ */ o("div", { style: { display: r === v ? "block" : "none" }, children: m && r === v && m[r] }),
116
- e && r === i && /* @__PURE__ */ o(j, { sdk: t })
95
+ /* @__PURE__ */ e(h, { "data-nav": m.toString(), children: [
96
+ /* @__PURE__ */ t("div", { style: { display: !m || r === A ? "block" : "none" }, children: p && p({ enableSdk: l, disableSdk: c }) }),
97
+ /* @__PURE__ */ t("div", { style: { display: r === a ? "block" : "none" }, children: i && r === a && i[r] }),
98
+ m && r === B && /* @__PURE__ */ t(F, { sdk: o })
117
99
  ] })
118
100
  ] }) });
119
101
  };
120
102
  export {
121
- rr as MastersApp
103
+ Ur as MastersApp
122
104
  };
@@ -0,0 +1,21 @@
1
+ import { type StreamLayerSDK } from '@streamlayer/sdk-web-interfaces';
2
+ import { AvailableOverlays } from './Navigation/MastersNavigation';
3
+ /**
4
+ * A hook that provides functionality for managing the StreamLayerSDK in the Masters app.
5
+ * - On activate FG+ button, the SDK is initialized and the FG+ overlay is opened.
6
+ * - On activate Channels or Leaderboard button, the SDK is disabled and the FG+ overlay is closed.
7
+ * - On sdk status change, if sdk disabled (f.e some errors occurred), the SDK is disabled and the FG+ overlay is closed.
8
+ * @param sdk - The StreamLayerSDK instance to use.
9
+ * @param event - The name of the event to create a session for.
10
+ * @returns An object containing various functions and state values for managing the SDK and app overlays.
11
+ * @returns disableSdk - A function that disables the SDK and closes the FG+ overlay.
12
+ * @returns enableSdk - A function that initializes the SDK and opens the FG+ overlay.
13
+ */
14
+ export declare const useMastersApp: (sdk: StreamLayerSDK, event: string) => {
15
+ sdkEnabled: boolean;
16
+ sdkReady: boolean;
17
+ activeOverlay: any;
18
+ activateAndLoadOverlay: (overlay: AvailableOverlays) => void;
19
+ enableSdk: () => void;
20
+ disableSdk: () => void;
21
+ };
@@ -0,0 +1,47 @@
1
+ import { useStore as d } from "@nanostores/react";
2
+ import { useState as u, useCallback as f, useEffect as S } from "react";
3
+ import { FeatureType as b } from "@streamlayer/sdk-web-types";
4
+ import "react/jsx-runtime";
5
+ import { ChannelsButtonId as l } from "../navigation/button/Channels.js";
6
+ import { FeaturedGroupsButtonId as r } from "../navigation/button/FeaturedGroups.js";
7
+ import "../navigation/button/LeaderBoard.js";
8
+ import "../navigation/masters.js";
9
+ import "@linaria/react";
10
+ import "../icons/index.js";
11
+ import "../navigation/button/index.js";
12
+ import "../navigation/button/styles.js";
13
+ import "../navigation/index.js";
14
+ const R = (e, s) => {
15
+ const [m, n] = u(!1), o = d(e.status) === "ready", [a, p] = u(r), i = f(
16
+ (t) => {
17
+ p(t), t === r ? (e.createEventSession(s), e.openFeature(b.GAMES)) : e.closeFeature();
18
+ },
19
+ [s, e]
20
+ );
21
+ return S(() => {
22
+ !o && a === r && (p(l), e.closeFeature());
23
+ }, [o, a, e]), {
24
+ sdkEnabled: m,
25
+ sdkReady: o,
26
+ activeOverlay: a,
27
+ activateAndLoadOverlay: i,
28
+ enableSdk: () => {
29
+ e.initializeApp().then(({ enabled: t, err: c }) => {
30
+ if (n(!0), c) {
31
+ i(l);
32
+ return;
33
+ }
34
+ if (t) {
35
+ i(r);
36
+ return;
37
+ }
38
+ });
39
+ },
40
+ disableSdk: () => {
41
+ n(!1), e.disableApp();
42
+ }
43
+ };
44
+ };
45
+ export {
46
+ R as useMastersApp
47
+ };
@@ -1,4 +1,9 @@
1
1
  import { Features } from '@streamlayer/sdk-web-features';
2
2
  import { type StreamLayerSDK } from '@streamlayer/sdk-web-interfaces';
3
3
  import { FeatureType } from '@streamlayer/sdk-web-types';
4
+ /**
5
+ * A hook that manages the active feature of a StreamLayerSDK instance.
6
+ * @param sdk - The StreamLayerSDK instance to manage the feature for.
7
+ * @returns A tuple containing the active feature type and the active feature instance, or null if there is no active feature.
8
+ */
4
9
  export declare const useSdkFeature: (sdk: StreamLayerSDK) => [FeatureType, Features | null];
@@ -1,38 +1,33 @@
1
1
  import { jsxs as e, jsx as o } from "react/jsx-runtime";
2
- import { styled as i } from "@linaria/react";
3
- import { useMemo as x, useState as g } from "react";
4
- import { DeveloperStorage as h } from "../../storage.js";
5
- import { BypassLogin as u } from "./bypassLogin.js";
6
- import { EnvToggle as b } from "./envToggle.js";
2
+ import { styled as p } from "@linaria/react";
3
+ import { useMemo as f, useState as g } from "react";
4
+ import { DeveloperStorage as u } from "../../storage.js";
5
+ import { BypassLogin as b } from "./bypassLogin.js";
6
+ import { EnvToggle as h } from "./envToggle.js";
7
7
  import { EventInput as v } from "./eventInput.js";
8
8
  import { SdkKey as y } from "./sdkKey.js";
9
9
  import "@streamlayer/sdk-web-storage";
10
10
  import "@nanostores/react";
11
11
  import "@streamlayer/sdk-web-core";
12
12
  import "./styles.js";
13
- const w = i.div`
13
+ const w = p.div`
14
14
  position: fixed;
15
15
  bottom: 0;
16
16
  right: 0;
17
17
  max-width: 600px;
18
- `, D = i.div`
18
+
19
+ font-family: system-ui;
20
+ background: rgba(29, 123, 255, 0.5);
21
+ border-top-left-radius: 10px;
22
+ backdrop-filter: blur(5px);
23
+ `, D = p.div`
19
24
  flex-direction: column;
20
25
  gap: 10px;
21
26
  margin-right: 60px;
22
27
  display: flex;
23
- animation: show-dev-items 0.3s ease-in-out;
24
- transform-origin: bottom right;
25
-
26
- @keyframes show-dev-items {
27
- from {
28
- transform: scale(0);
29
- }
30
-
31
- to {
32
- transform: scale(1);
33
- }
34
- }
35
- `, j = i.button`
28
+ margin-left: 10px;
29
+ margin-top: 10px;
30
+ `, j = p.button`
36
31
  position: absolute;
37
32
  z-index: 10000;
38
33
  bottom: 10px;
@@ -71,19 +66,19 @@ const w = i.div`
71
66
  width: 100%;
72
67
  height: 4px;
73
68
  }
74
- `, q = ({ sdk: t, sdkKey: s, setSdkKey: n, env: m, setEnv: p, event: d, setEvent: l }) => {
75
- const r = x(() => new h(), []), [a, c] = g(!1);
69
+ `, q = ({ sdk: t, sdkKey: d, setSdkKey: i, env: s, setEnv: n, event: m, setEvent: l }) => {
70
+ const r = f(() => new u(), []), [a, x] = g(!1);
76
71
  return /* @__PURE__ */ e(w, { children: [
77
- /* @__PURE__ */ e(j, { "data-opened": a.toString(), onClick: () => c((f) => !f), children: [
72
+ /* @__PURE__ */ e(j, { "data-opened": a.toString(), onClick: () => x((c) => !c), children: [
78
73
  /* @__PURE__ */ o("span", {}),
79
74
  /* @__PURE__ */ o("span", {}),
80
75
  /* @__PURE__ */ o("span", {})
81
76
  ] }),
82
77
  a && /* @__PURE__ */ e(D, { children: [
83
- p && /* @__PURE__ */ o(b, { env: m, setEnv: p, storage: r }),
84
- n && /* @__PURE__ */ o(y, { sdkKey: s, setSdkKey: n, storage: r }),
85
- t && /* @__PURE__ */ o(v, { sdk: t, storage: r, event: d, setEvent: l }),
86
- t && /* @__PURE__ */ o(u, { sdk: t, storage: r })
78
+ n && /* @__PURE__ */ o(h, { env: s, setEnv: n, storage: r }),
79
+ i && /* @__PURE__ */ o(y, { sdkKey: d, setSdkKey: i, storage: r }),
80
+ t && /* @__PURE__ */ o(v, { sdk: t, storage: r, event: m, setEvent: l }),
81
+ t && /* @__PURE__ */ o(b, { sdk: t, storage: r })
87
82
  ] })
88
83
  ] });
89
84
  };
@@ -22,6 +22,8 @@ const d = o.div`
22
22
  opacity: 0;
23
23
  position: relative;
24
24
  z-index: 1;
25
+ width: 100%;
26
+ cursor: pointer;
25
27
 
26
28
  &:checked + span {
27
29
  transform: translate3d(100%, 0, 0);
@@ -36,6 +36,14 @@ const n = r.div`
36
36
  cursor: pointer;
37
37
  border: none;
38
38
  text-transform: uppercase;
39
+
40
+ &:hover {
41
+ transform: scale(1.1);
42
+ }
43
+
44
+ &:active {
45
+ transform: scale(0.9);
46
+ }
39
47
  }
40
48
  `;
41
49
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/react-ui",
3
- "version": "0.36.0",
3
+ "version": "0.37.1",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./lib/index.d.ts",
@@ -26,17 +26,17 @@
26
26
  "package.json"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@streamlayer/sl-eslib": "^5.45.1",
30
- "@streamlayer/feature-gamification": "^0.17.4",
31
- "@streamlayer/sdk-web": "^0.28.1",
32
- "@streamlayer/sdk-web-anonymous-auth": "^0.10.10",
33
- "@streamlayer/sdk-web-api": "^0.0.5",
34
- "@streamlayer/sdk-web-core": "^0.14.1",
35
- "@streamlayer/sdk-web-features": "^0.10.4",
36
- "@streamlayer/sdk-web-interfaces": "^0.18.3",
37
- "@streamlayer/sdk-web-notifications": "^0.10.2",
38
- "@streamlayer/sdk-web-storage": "^0.3.5",
39
- "@streamlayer/sdk-web-types": "^0.16.3"
29
+ "@streamlayer/sl-eslib": "^5.52.0",
30
+ "@streamlayer/feature-gamification": "^0.18.0",
31
+ "@streamlayer/sdk-web": "^0.28.2",
32
+ "@streamlayer/sdk-web-anonymous-auth": "^0.10.11",
33
+ "@streamlayer/sdk-web-api": "^0.0.6",
34
+ "@streamlayer/sdk-web-core": "^0.14.2",
35
+ "@streamlayer/sdk-web-features": "^0.10.5",
36
+ "@streamlayer/sdk-web-interfaces": "^0.18.4",
37
+ "@streamlayer/sdk-web-notifications": "^0.10.3",
38
+ "@streamlayer/sdk-web-storage": "^0.3.6",
39
+ "@streamlayer/sdk-web-types": "^0.16.4"
40
40
  },
41
41
  "nx": {
42
42
  "implicitDependencies": [
@@ -48,11 +48,11 @@
48
48
  "@connectrpc/connect-web": "^1.1.3",
49
49
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
50
50
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
51
- "@linaria/babel-preset": "^5.0.3",
51
+ "@linaria/babel-preset": "^5.0.4",
52
52
  "@linaria/core": "^5.0.2",
53
- "@linaria/esbuild": "^5.0.3",
53
+ "@linaria/esbuild": "^5.0.4",
54
54
  "@linaria/react": "^5.0.3",
55
- "@linaria/vite": "^5.0.3",
55
+ "@linaria/vite": "^5.0.4",
56
56
  "@nanostores/react": "^0.7.1",
57
57
  "@storybook/addon-docs": "^7.5.3",
58
58
  "@storybook/addon-styling": "^1.3.7",
@@ -73,6 +73,6 @@
73
73
  "vite-plugin-svgr": "^4.1.0",
74
74
  "vite-svg-loader": "^4.0.0",
75
75
  "vite-tsconfig-paths": "^4.2.1",
76
- "@streamlayer/react": "^0.23.0"
76
+ "@streamlayer/react": "^0.23.2"
77
77
  }
78
78
  }