feat(ui-mode): pr feedback
This commit is contained in:
parent
561b4b6362
commit
58712445d3
|
|
@ -59,6 +59,11 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.network-font-preview-error {
|
||||||
|
margin-top: 8px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.tab-network .toolbar {
|
.tab-network .toolbar {
|
||||||
min-height: 30px !important;
|
min-height: 30px !important;
|
||||||
background-color: initial !important;
|
background-color: initial !important;
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ const BodyTab: React.FunctionComponent<{
|
||||||
reader.readAsDataURL(blob);
|
reader.readAsDataURL(blob);
|
||||||
setResponseBody({ dataUrl: (await eventPromise).target.result });
|
setResponseBody({ dataUrl: (await eventPromise).target.result });
|
||||||
} else if (isFont) {
|
} else if (isFont) {
|
||||||
const font = await response.blob().then(blob => blob.arrayBuffer());
|
const font = await response.arrayBuffer();
|
||||||
setResponseBody({ font });
|
setResponseBody({ font });
|
||||||
} else {
|
} else {
|
||||||
const formattedBody = formatBody(await response.text(), resource.response.content.mimeType);
|
const formattedBody = formatBody(await response.text(), resource.response.content.mimeType);
|
||||||
|
|
@ -141,15 +141,23 @@ const BodyTab: React.FunctionComponent<{
|
||||||
const FontPreview: React.FunctionComponent<{
|
const FontPreview: React.FunctionComponent<{
|
||||||
font: BinaryData;
|
font: BinaryData;
|
||||||
}> = ({ font }) => {
|
}> = ({ font }) => {
|
||||||
|
const [isError, setIsError] = React.useState(false);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const fontFace = new FontFace('font-preview', font);
|
const fontFace = new FontFace('font-preview', font);
|
||||||
|
if (fontFace.status === 'loaded')
|
||||||
document.fonts.add(fontFace);
|
document.fonts.add(fontFace);
|
||||||
|
if (fontFace.status === 'error')
|
||||||
|
setIsError(true);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
document.fonts.delete(fontFace);
|
document.fonts.delete(fontFace);
|
||||||
};
|
};
|
||||||
}, [font]);
|
}, [font]);
|
||||||
|
|
||||||
|
if (isError)
|
||||||
|
return <div className='network-font-preview-error'>Could not load font preview</div>;
|
||||||
|
|
||||||
return <div className='network-font-preview'>
|
return <div className='network-font-preview'>
|
||||||
ABCDEFGHIJKLM<br />
|
ABCDEFGHIJKLM<br />
|
||||||
NOPQRSTUVWXYZ<br />
|
NOPQRSTUVWXYZ<br />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue