Skip to content

Commit

Permalink
Deploying to gh-pages from @ 353f7c0 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Dovrol committed Feb 17, 2024
1 parent dda6767 commit 253c827
Show file tree
Hide file tree
Showing 235 changed files with 8,961 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* -text
Empty file added .nojekyll
Empty file.
43 changes: 43 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!--
If you need to add <link> or <script> elements to include CSS or JavaScript files
for canvas views of your Stories,
YOU SHOULD DO THAT IN THE "iframe.html" FILE, NOT HERE.
-->
<title>AdaptiveBlazor.Storybook</title>
<base href="/adaptive-blazor/" />
<link rel="stylesheet" href="css/blazor-ui.css" />
</head>

<body>
<div id="app">
<div class="loading-progress">
<svg>
<circle r="40%" cx="50%" cy="50%" />
<circle r="40%" cx="50%" cy="50%" />
</svg>
<div class="text"></div>
<img src="_content/BlazingStory/images/icon.min.svg" />
</div>
</div>

<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<!--
If you need to add <script> elements to include JavaScript files for canvas views of your Stories,
YOU SHOULD DO THAT IN THE "iframe.html" FILE, NOT HERE.
-->
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
<script src="brotliloader.min.js" type="module"></script>
</body>

</html>
2 changes: 2 additions & 0 deletions AdaptiveBlazor.Storybook.styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import '_content/Toolbelt.Blazor.SplitContainer/Toolbelt.Blazor.SplitContainer.bundle.scp.css';

3,138 changes: 3,138 additions & 0 deletions _content/AdaptiveBlazor/AdaptiveBlazor.lib.module.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bundled license information:

tabbable/dist/index.esm.js:
/*!
* tabbable 5.3.3
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
7 changes: 7 additions & 0 deletions _content/AdaptiveBlazor/AdaptiveBlazor.lib.module.js.map

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions _content/BlazingStory/Components/BlazingStoryApp.razor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export const ensureAllFontsAndStylesAreLoaded = async () => {
if (location.pathname !== "/")
return;
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
for (const font of document.fonts)
font.load();
for (;;) {
const fonts = Array.from(document.fonts);
if (fonts.every(font => font.status === "loaded"))
break;
await delay(10);
}
for (;;) {
const styleSheets = Array.from(document.head.querySelectorAll('link[rel="stylesheet"]'));
if (styleSheets.every(l => Boolean(l.sheet)))
break;
await delay(10);
}
};
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
export const getPrefersColorScheme = () => darkModeMediaQuery.matches ? "dark" : "light";
let subscriberIndex = 0;
const subscribers = new Map();
export const subscribePreferesColorSchemeChanged = (dotnetObjRef, methodName) => {
const subscriber = (e) => {
dotnetObjRef.invokeMethodAsync(methodName, getPrefersColorScheme());
};
darkModeMediaQuery.addEventListener("change", subscriber);
subscriberIndex++;
subscribers.set(subscriberIndex, subscriber);
return subscriberIndex;
};
export const unsubscribePreferesColorSchemeChanged = (subscriberIndex) => {
const subscriber = subscribers.get(subscriberIndex);
if (typeof (subscriber) === "undefined")
return;
darkModeMediaQuery.removeEventListener("change", subscriber);
subscribers.delete(subscriberIndex);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const getComputedColor = (colorText) => {
const element = document.createElement("div");
element.style.position = "fixed";
element.style.width = "0";
element.style.height = "0";
element.style.color = colorText;
document.body.appendChild(element);
const computedColorText = getComputedStyle(element).color;
element.remove();
return computedColorText;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const subscribeDocumentEvent = (eventType, dotnetObj, methodName, popupMenuElement) => {
const evendListener = (ev) => {
if (popupMenuElement.contains(ev.target))
return;
dotnetObj.invokeMethodAsync(methodName);
};
document.addEventListener(eventType, evendListener);
return ({ dispose: () => document.removeEventListener(eventType, evendListener) });
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
class TimeoutError extends Error {
constructor(message) { super(message); }
}
const waitFor = async (arg) => {
var _a, _b;
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
let retryCount = 0;
while (true) {
const result = arg.predecate();
if (result !== false)
return result;
if (retryCount >= ((_a = arg.maxRetryCount) !== null && _a !== void 0 ? _a : 500))
throw new TimeoutError("Timeout");
retryCount++;
await delay((_b = arg.retryInterval) !== null && _b !== void 0 ? _b : 10);
}
};
const waitForIFrameReady = async (iframe) => {
return await waitFor({
predecate: () => {
var _a;
if (iframe.contentWindow === null || iframe.contentDocument === null)
return false;
if (iframe.contentWindow.location.href === "about:blank")
return false;
if (((_a = iframe.contentWindow.BlazingStory) === null || _a === void 0 ? void 0 : _a.canvasFrameInitialized) !== true)
return false;
return ({ contentWindow: iframe.contentWindow, contentDocument: iframe.contentDocument });
}
});
};
export const navigatePreviewFrameTo = async (iframe, url) => {
if (iframe === null)
return;
const { contentWindow, contentDocument } = await waitForIFrameReady(iframe);
const event = new PopStateEvent("popstate", { state: {}, bubbles: true, cancelable: true });
contentWindow.history.pushState({}, "", url);
contentDocument.dispatchEvent(event);
};
export const reloadPreviewFrame = (iframe) => {
if (iframe === null || iframe.contentWindow === null)
return;
iframe.contentWindow.postMessage({ action: "reload" });
};
const zoomPreviewFrame = (iframe, getNextZoomLevel) => {
if (iframe === null || iframe.contentDocument === null)
return;
const style = iframe.contentDocument.body.style;
const currentZoomLevel = parseFloat(style.zoom || '1');
const nextZoomLevel = getNextZoomLevel(currentZoomLevel);
style.zoom = '' + nextZoomLevel;
};
export const zoomInPreviewFrame = (iframe) => zoomPreviewFrame(iframe, zoom => zoom * 1.25);
export const zoomOutPreviewFrame = (iframe) => zoomPreviewFrame(iframe, zoom => zoom / 1.25);
export const resetZoomPreviewFrame = (iframe) => zoomPreviewFrame(iframe, _ => 1);
export const subscribeComponentActionEvent = async (iframe, dotNetObj, methodName) => {
try {
if (iframe === null)
return { dispose: () => { } };
const { contentDocument } = await waitForIFrameReady(iframe);
const componentActionEventListener = (e) => dotNetObj.invokeMethodAsync(methodName, e.detail.name, e.detail.argsJson);
contentDocument.addEventListener('componentActionEvent', componentActionEventListener);
return { dispose: () => contentDocument.removeEventListener('componentActionEvent', componentActionEventListener) };
}
catch (e) {
if (e instanceof TimeoutError)
return { dispose: () => { } };
throw e;
}
};
const isDotnetWatchScriptInjected = (window) => {
var _a;
const scriptInjectedSentinel = '_dotnet_watch_ws_injected';
return (_a = window === null || window === void 0 ? void 0 : window.hasOwnProperty(scriptInjectedSentinel)) !== null && _a !== void 0 ? _a : false;
};
export const ensureDotnetWatchScriptInjected = async (iframe) => {
try {
if (iframe === null)
return;
const { contentWindow, contentDocument } = await waitForIFrameReady(iframe);
if (!isDotnetWatchScriptInjected(window))
return;
if (isDotnetWatchScriptInjected(contentWindow))
return;
const script = contentDocument.createElement('script');
script.src = '_framework/aspnetcore-browser-refresh.js';
contentDocument.body.appendChild(script);
}
catch (e) {
if (e instanceof TimeoutError)
return;
throw e;
}
};
25 changes: 25 additions & 0 deletions _content/BlazingStory/Internals/Pages/Canvas/CanvasFrame.razor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export const ensurePreviewStyle = (background, styleDescripters) => {
const doc = document;
const head = doc.head;
const bodyStyle = doc.body.style;
bodyStyle.transition = "background-color 0.3s";
setTimeout(() => { bodyStyle.backgroundColor = background; }, 10);
for (const descripter of styleDescripters) {
const linkElement = head.querySelector(`link#${descripter.id}`);
if (linkElement === null && descripter.enable) {
const newLinkElement = doc.createElement("link");
newLinkElement.id = descripter.id;
newLinkElement.href = descripter.href;
newLinkElement.rel = "stylesheet";
head.appendChild(newLinkElement);
}
else if (linkElement !== null && !descripter.enable) {
linkElement.remove();
}
}
};
export const dispatchComponentActionEvent = (name, argsJson) => {
const componentActionEventDetail = { name, argsJson };
const event = new CustomEvent('componentActionEvent', { detail: componentActionEventDetail });
document.dispatchEvent(event);
};
45 changes: 45 additions & 0 deletions _content/BlazingStory/Internals/Pages/Canvas/MeasureLayer.razor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const doc = document;
const targetEvents = [
"pointerenter",
"pointerover",
"pointerleave",
"scroll"
];
let lastHoveredElement = null;
let attachedOwner = null;
const pxToNumber = (px) => parseInt(px.replace("px", ""), 10);
const getSpacingSize = (style, prefix) => {
const [top, left, bottom, right] = ["Top", "Left", "Bottom", "Right"].map(sufix => pxToNumber(style[prefix + sufix]));
return { top, left, bottom, right };
};
const handler = (ev) => {
if (attachedOwner === null)
return;
let hoveredElement = (ev instanceof MouseEvent) && document.elementFromPoint(ev.clientX, ev.clientY);
let measurement = null;
if (lastHoveredElement !== null && hoveredElement === null) {
lastHoveredElement = null;
}
else if (hoveredElement !== null && lastHoveredElement !== hoveredElement) {
lastHoveredElement = hoveredElement === false ? lastHoveredElement : hoveredElement;
if (lastHoveredElement !== null) {
const computedStyle = window.getComputedStyle(lastHoveredElement);
measurement = {
boundary: lastHoveredElement.getBoundingClientRect(),
padding: getSpacingSize(computedStyle, "padding"),
margin: getSpacingSize(computedStyle, "margin"),
};
}
}
else
return;
attachedOwner.invokeMethodAsync("TargetElementChanged", measurement);
};
export const attach = (owner) => {
attachedOwner = owner;
targetEvents.forEach(eventName => doc.addEventListener(eventName, handler));
};
export const detach = () => {
attachedOwner = null;
targetEvents.forEach(eventName => doc.removeEventListener(eventName, handler));
};
54 changes: 54 additions & 0 deletions _content/BlazingStory/Internals/Pages/IFrame.razor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const keydown = "keydown";
const pointerdown = "pointerdown";
const SessionStateKey = "IFrame.SessionState";
export const initializeCanvasFrame = () => {
var _a;
const doc = document;
const wnd = window;
const sessionState = {
...{ zoom: 1 }, ...JSON.parse(sessionStorage.getItem(SessionStateKey) || "{}")
};
doc.body.style.zoom = "" + sessionState.zoom;
wnd.addEventListener("message", (event) => {
const message = event.data;
if (event.origin !== location.origin || message.action !== "reload")
return;
sessionState.zoom = doc.body.style.zoom || "1";
sessionStorage.setItem(SessionStateKey, JSON.stringify(sessionState));
location.reload();
}, false);
doc.addEventListener(keydown, event => {
const targetElement = event.target;
if (['INPUT', 'TEXTAREA', 'SELECT'].includes(targetElement.tagName))
return;
if (targetElement.contentEditable === "true")
return;
wnd.parent.postMessage({
action: keydown,
eventArgs: {
key: event.key,
code: event.code,
altKey: event.altKey,
shiftKey: event.shiftKey,
ctrlKey: event.ctrlKey,
metaKey: event.metaKey,
}
}, location.origin);
});
doc.addEventListener(pointerdown, event => {
wnd.parent.postMessage({
action: pointerdown
}, location.origin);
});
wnd.BlazingStory = wnd.BlazingStory || {};
wnd.BlazingStory.canvasFrameInitialized = true;
const frameElementId = ((_a = wnd.frameElement) === null || _a === void 0 ? void 0 : _a.id) || '';
const htmlElement = document.body.parentElement;
const scrollHeight = (htmlElement === null || htmlElement === void 0 ? void 0 : htmlElement.scrollHeight) || 0;
wnd.parent.postMessage({
action: "frameview-height",
frameId: frameElementId,
height: scrollHeight
}, location.origin);
setTimeout(() => htmlElement === null || htmlElement === void 0 ? void 0 : htmlElement.classList.add("_blazing_story_ready_for_visible"), 300);
};
Loading

0 comments on commit 253c827

Please sign in to comment.