chore: rename callbacks to onLoading and onLoaded

This commit is contained in:
Bilawal Hameed
2020-07-06 14:02:16 +02:00
parent b44d4a4467
commit 4eca08efd1
2 changed files with 14 additions and 12 deletions
@@ -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;
};
};