chore: rename callbacks to onLoading and onLoaded
This commit is contained in:
@@ -146,13 +146,13 @@ export const Reader = () => {
|
||||
]);
|
||||
}, [componentId, path, shadowRoot, state]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
if (state.value instanceof Error) return <TechDocsNotFound />;
|
||||
if (state.value instanceof Error) {
|
||||
return <TechDocsNotFound />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<TechDocsPageWrapper title={componentId} subtitle={componentId}>
|
||||
<div ref={shadowDomRef} />
|
||||
</TechDocsPageWrapper>
|
||||
</>
|
||||
<TechDocsPageWrapper title={componentId} subtitle={componentId}>
|
||||
<div ref={shadowDomRef} />
|
||||
</TechDocsPageWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -18,19 +18,19 @@ import type { Transformer } from './index';
|
||||
|
||||
type OnCssReadyOptions = {
|
||||
docStorageURL: string;
|
||||
onCssLoading: (dom: Element) => void;
|
||||
onCssReady: (dom: Element) => void;
|
||||
onLoading: (dom: Element) => void;
|
||||
onLoaded: (dom: Element) => void;
|
||||
};
|
||||
|
||||
export const onCssReady = ({
|
||||
docStorageURL,
|
||||
onLoad,
|
||||
onReady,
|
||||
onLoading,
|
||||
onLoaded,
|
||||
}: OnCssReadyOptions): Transformer => {
|
||||
return dom => {
|
||||
const cssPages = Array.from(
|
||||
dom.querySelectorAll('head > link[rel="stylesheet"]'),
|
||||
).filter(elem => elem.getAttribute('href').startsWith(docStorageURL));
|
||||
).filter(elem => elem.getAttribute('href')?.startsWith(docStorageURL));
|
||||
|
||||
let count = cssPages.length;
|
||||
|
||||
@@ -43,9 +43,11 @@ export const onCssReady = ({
|
||||
count -= 1;
|
||||
|
||||
if (count === 0) {
|
||||
onReady(dom);
|
||||
onLoaded(dom);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
return dom;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user