generated from voorhoede/head-start
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreviewMode.astro
More file actions
68 lines (62 loc) · 1.31 KB
/
PreviewMode.astro
File metadata and controls
68 lines (62 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
const { datocmsEnvironment, datocmsToken, isPreview } = Astro.locals;
---
<preview-mode
data-datocms-environment={datocmsEnvironment}
data-datocms-token={isPreview && datocmsToken}
>
<preview-mode-bar>
Preview mode
<span role="presentation" data-status="closed"></span>
<a href={`/api/preview/exit/?location=${Astro.url}`}>exit preview</a>
</preview-mode-bar>
<slot />
</preview-mode>
<script src="./PreviewMode.client.ts"></script>
<style>
preview-mode-bar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1em;
background: black;
color: white;
margin-bottom: 16px;
border-radius: 8px;
max-width: 1440px;
margin-inline: auto;
}
a {
color: white;
}
[data-status]:before {
display: inline-block;
margin-left: 0.5em;
margin-right: 0.5em;
}
[data-status='closed']:before {
content: '⚪';
}
[data-status='connecting']:before {
content: '🟠';
animation: pulseAnimation 1s infinite;
}
[data-status='connected']:before {
content: '🟢';
animation: pulseAnimation 2s infinite;
}
[data-status='error']:before {
content: '🔴';
}
@keyframes pulseAnimation {
0% {
opacity: 1;
}
50% {
opacity: 0.2;
}
100% {
opacity: 1;
}
}
</style>