Skip to content

Commit f68a8ed

Browse files
committed
fix(demo): prevent flash of source bar in hosted envs
1 parent ed22777 commit f68a8ed

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

docs/index.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Python Friendly Error Messages - Demo</title>
8+
<script>
9+
(() => {
10+
const localHosts = new Set(['localhost', '127.0.0.1', '::1']);
11+
const isLocalDevelopment = window.location.protocol === 'file:' || localHosts.has(window.location.hostname);
12+
window.__PFEM_IS_LOCAL_DEVELOPMENT__ = isLocalDevelopment;
13+
if (isLocalDevelopment) {
14+
document.documentElement.classList.add('demo--local-dev');
15+
}
16+
})();
17+
</script>
818
<link rel="stylesheet" href="styles.css">
919
</head>
1020

@@ -24,8 +34,7 @@ <h1>Python Friendly Error Messages - Demo</h1>
2434
<script type="module">
2535
import { examples } from './demo-examples.js';
2636

27-
const localHosts = new Set(['localhost', '127.0.0.1', '::1']);
28-
const isLocalDevelopment = window.location.protocol === 'file:' || localHosts.has(window.location.hostname);
37+
const isLocalDevelopment = Boolean(window.__PFEM_IS_LOCAL_DEVELOPMENT__);
2938

3039
const pageParams = new URLSearchParams(window.location.search);
3140
const useLocal = isLocalDevelopment && pageParams.has('local');

docs/styles.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ h1 {
2828
padding: 0.5rem 1rem;
2929
font-size: 0.85rem;
3030
font-family: monospace;
31-
display: flex;
31+
display: none;
3232
align-items: center;
3333
margin-bottom: 1.5rem;
3434
}
3535

36+
.demo--local-dev .demo__source-bar {
37+
display: flex;
38+
}
39+
3640
.demo__source-bar .container {
3741
display: flex;
3842
align-items: center;

0 commit comments

Comments
 (0)