Skip to content

Commit

Permalink
code: Show a message when no preview content can be found
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Apr 28, 2024
1 parent b57e03b commit 948d395
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions code/src/node/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export class PreviewManager {
content="default-src 'none'; style-src 'nonce-${cssNonce}'; script-src 'nonce-${scriptNonce}'; frame-src http://localhost:*/" />
<style nonce="${cssNonce}">
* { box-sizing: border-box; }
* { box-sizing: border-box;}
:not(progress) { border: none;}
body {
height: 100vh;
Expand All @@ -201,6 +202,14 @@ export class PreviewManager {
padding: 0.5rem;
}
#no-content {
font-size: 1.2em;
line-height: 1.5;
height: 100%;
overflow-y: auto;
padding: 0.5rem;
}
#progress-bar {
flex-grow: 1;
}
Expand Down Expand Up @@ -259,6 +268,7 @@ export class PreviewManager {
const vscode = acquireVsCodeApi()
const viewer = document.getElementById("viewer")
const noContent = document.getElementById("no-content")
const status = document.getElementById("status")
console.debug(window.location)
Expand All @@ -275,7 +285,15 @@ export class PreviewManager {
// Control messages coming from the webview hosting this page
if (event.origin.startsWith("vscode-webview://")) {
if (message.show) {
if (message.show === "<nothing>") {
status.style.display = "none"
// Only show the "no content" message if there is not a previous page already being shown
if (!viewer.src) {
noContent.style.display = "block"
}
} else if (message.show) {
status.style.display = "flex"
noContent.style.display = "none"
viewer.src = message.show
Expand All @@ -289,6 +307,7 @@ export class PreviewManager {
if (event.origin.startsWith("http://localhost:")) {
if (message.ready) {
status.style.display = "none"
noContent.style.display = "none"
vscode.postMessage({ ready: true })
}
}
Expand Down

0 comments on commit 948d395

Please sign in to comment.