@four-leaf-studios/rl-overlay 1.1.0 → 1.1.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.
@@ -2,6 +2,52 @@ import React, { useState, useEffect } from "react";
2
2
  import { Overlay } from "@four-leaf-studios/rl-overlay";
3
3
  import { mockBroadcastData } from "./mockBroadcast";
4
4
 
5
+ /**
6
+ * Build an overlay config from a CSS theme string.
7
+ * Each component in the registry gets its own entry.
8
+ * The CSS is applied to the first component since all CSS
9
+ * gets concatenated into a single <style> block anyway.
10
+ */
11
+ const buildOverlay = (css) => ({
12
+ components: [
13
+ {
14
+ id: "scoreboard",
15
+ name: "Scoreboard",
16
+ css: css, // all theme CSS goes here
17
+ code_id: "Scoreboard",
18
+ position: { top: 20, left: 560, width: 800, height: 130 },
19
+ },
20
+ {
21
+ id: "teams",
22
+ name: "Teams",
23
+ css: "",
24
+ code_id: "Teams",
25
+ position: { top: 200, left: 0, width: 350, height: 700 },
26
+ },
27
+ {
28
+ id: "target-player",
29
+ name: "Target Player",
30
+ css: "",
31
+ code_id: "TargetPlayer",
32
+ position: { top: 850, left: 560, width: 800, height: 200 },
33
+ },
34
+ {
35
+ id: "target-boost",
36
+ name: "Target Boost",
37
+ css: "",
38
+ code_id: "TargetBoost",
39
+ position: { top: 750, left: 1700, width: 200, height: 200 },
40
+ },
41
+ {
42
+ id: "replay",
43
+ name: "Replay",
44
+ css: "",
45
+ code_id: "Replay",
46
+ position: { top: 20, left: 860, width: 200, height: 50 },
47
+ },
48
+ ],
49
+ });
50
+
5
51
  export default function App() {
6
52
  const [cssText, setCssText] = useState("");
7
53
 
@@ -16,13 +62,17 @@ export default function App() {
16
62
  console.error(err);
17
63
  setCssText("");
18
64
  });
19
- }, [setCssText]);
65
+ }, []);
20
66
 
21
67
  if (!cssText) {
22
68
  return <div>Loading styles…</div>;
23
69
  }
24
70
 
25
71
  return (
26
- <Overlay broadcast={mockBroadcastData} styles={cssText} preview={true} />
72
+ <Overlay
73
+ broadcast={mockBroadcastData}
74
+ overlay={buildOverlay(cssText)}
75
+ preview={true}
76
+ />
27
77
  );
28
78
  }