2023-03-28 18:17:40 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import { useEffect } from "react";
|
|
|
|
import { useState } from "react";
|
2022-03-31 08:45:47 +00:00
|
|
|
import ReactDom from "react-dom";
|
|
|
|
|
2022-05-18 16:25:30 +00:00
|
|
|
import Cal, { getCalApi } from "./src/index";
|
|
|
|
|
|
|
|
const api = getCalApi();
|
2022-03-31 08:45:47 +00:00
|
|
|
|
|
|
|
function App() {
|
2022-04-25 04:33:00 +00:00
|
|
|
const [loaded, setLoaded] = useState(false);
|
|
|
|
useEffect(() => {
|
|
|
|
// Simulate state change causing config object to change, causing rerender of Cal
|
|
|
|
setTimeout(setLoaded.bind(true), 1000);
|
2022-05-18 16:25:30 +00:00
|
|
|
const callback = (event) => {
|
|
|
|
console.log(event.detail);
|
|
|
|
};
|
|
|
|
api.then((api) => {
|
|
|
|
api("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
2023-04-18 12:53:46 +00:00
|
|
|
|
|
|
|
api("ui", {
|
|
|
|
cssVarsPerTheme: {
|
|
|
|
light: {
|
|
|
|
"cal-border-booker": "red",
|
|
|
|
"cal-border-booker-width": "20px",
|
|
|
|
},
|
|
|
|
dark: {
|
|
|
|
"cal-border-booker": "red",
|
|
|
|
"cal-border-booker-width": "5px",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2022-05-18 16:25:30 +00:00
|
|
|
});
|
|
|
|
return () => {
|
|
|
|
api.then((api) => {
|
|
|
|
api("off", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
2022-04-25 04:33:00 +00:00
|
|
|
}, []);
|
2022-03-31 08:45:47 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h1>
|
|
|
|
There is <code>Cal</code> component below me
|
|
|
|
</h1>
|
|
|
|
<Cal
|
2022-04-14 02:47:34 +00:00
|
|
|
calOrigin="http://localhost:3000"
|
2022-05-06 15:56:26 +00:00
|
|
|
embedJsUrl="//localhost:3000/embed/embed.js"
|
2022-06-09 05:05:18 +00:00
|
|
|
style={{ width: "100%", height: "100%", overflow: "scroll" }}
|
2022-03-31 08:45:47 +00:00
|
|
|
calLink="pro"
|
|
|
|
config={{
|
|
|
|
name: "John Doe",
|
|
|
|
email: "johndoe@gmail.com",
|
|
|
|
notes: "Test Meeting",
|
|
|
|
guests: ["janedoe@gmail.com"],
|
|
|
|
theme: "dark",
|
2022-10-14 10:10:54 +00:00
|
|
|
}}
|
|
|
|
/>
|
2022-03-31 08:45:47 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2022-10-14 10:10:54 +00:00
|
|
|
ReactDom.render(<App />, document.getElementById("root"));
|