|
| 1 | +--- |
| 2 | +export interface Props { |
| 3 | + calLink?: string; |
| 4 | + namespace?: string; |
| 5 | + origin?: string; |
| 6 | + minHeight?: string; |
| 7 | +} |
| 8 | +
|
| 9 | +const { |
| 10 | + calLink = 'book/30min', |
| 11 | + namespace = '30min', |
| 12 | + origin = 'https://cal.draftlab.org', |
| 13 | + minHeight = '720px', |
| 14 | +} = Astro.props; |
| 15 | +
|
| 16 | +const containerId = `cal-inline-${namespace}`; |
| 17 | +--- |
| 18 | + |
| 19 | +<div class="mx-auto -my-6 w-full max-w-5xl sm:-my-8"> |
| 20 | + <div |
| 21 | + id={containerId} |
| 22 | + class="w-full overflow-scroll" |
| 23 | + style={`min-height:${minHeight}`} |
| 24 | + ></div> |
| 25 | +</div> |
| 26 | + |
| 27 | +<script |
| 28 | + is:inline |
| 29 | + type="text/javascript" |
| 30 | + define:vars={{ containerId, calLink, namespace, origin }} |
| 31 | +> |
| 32 | + (function (C, A, L) { |
| 33 | + let p = function (a, ar) { a.q.push(ar); }; |
| 34 | + let d = C.document; |
| 35 | + C.Cal = C.Cal || function () { |
| 36 | + let cal = C.Cal; |
| 37 | + let ar = arguments; |
| 38 | + if (!cal.loaded) { |
| 39 | + cal.ns = {}; |
| 40 | + cal.q = cal.q || []; |
| 41 | + d.head.appendChild(d.createElement("script")).src = A; |
| 42 | + cal.loaded = true; |
| 43 | + } |
| 44 | + if (ar[0] === L) { |
| 45 | + const api = function () { p(api, arguments); }; |
| 46 | + const ns = ar[1]; |
| 47 | + api.q = api.q || []; |
| 48 | + if (typeof ns === "string") { |
| 49 | + cal.ns[ns] = cal.ns[ns] || api; |
| 50 | + p(cal.ns[ns], ar); |
| 51 | + p(cal, ["initNamespace", ns]); |
| 52 | + } else { |
| 53 | + p(cal, ar); |
| 54 | + } |
| 55 | + return; |
| 56 | + } |
| 57 | + p(cal, ar); |
| 58 | + }; |
| 59 | + })(window, origin + "/embed/embed.js", "init"); |
| 60 | + |
| 61 | + Cal("init", namespace, { origin: origin }); |
| 62 | + |
| 63 | + Cal.ns[namespace]("inline", { |
| 64 | + elementOrSelector: "#" + containerId, |
| 65 | + config: { layout: "month_view", useSlotsViewOnSmallScreen: "true" }, |
| 66 | + calLink: calLink, |
| 67 | + }); |
| 68 | + |
| 69 | + Cal.ns[namespace]("ui", { hideEventTypeDetails: false, layout: "month_view" }); |
| 70 | +</script> |
0 commit comments