Skip to content

Commit 6e11f8f

Browse files
plowsofredsh4de
andcommitted
ui/components: add PreviewBanner with commit hash for coolify
Update PreviewBanner.astro with design tokens from styles/global.css: Co-authored-by: redsh4de <25299353+redsh4de@users.noreply.github.com>
1 parent ca59341 commit 6e11f8f

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
const isCoolifyPreview = import.meta.env.COOLIFY_PREVIEW;
3+
const sourceCommit = import.meta.env.SOURCE_COMMIT;
4+
const coolifyBranch = import.meta.env.COOLIFY_BRANCH; // "pull/2639/head:pr-2639-coolify",
5+
const coolifyRepo = import.meta.env.COOLIFY_REPO;
6+
if (!isCoolifyPreview) return;
7+
const coolifyPrNum = coolifyBranch.split("/")[1];
8+
---
9+
10+
<div class="preview-banner">
11+
<span class="preview-banner-style">
12+
<a href={`${coolifyRepo}/pull/${coolifyPrNum}/changes/${sourceCommit}`}
13+
>{sourceCommit.slice(0, 7)}</a
14+
> Preview powered by <a href="https://coolify.io/">Coolify</a>
15+
</span>
16+
</div>
17+
18+
<style>
19+
.preview-banner {
20+
position: fixed;
21+
bottom: 0;
22+
left: 0;
23+
right: 0;
24+
text-align: center;
25+
z-index: 999;
26+
}
27+
28+
.preview-banner-style {
29+
display: inline-block;
30+
background: black;
31+
color: white;
32+
padding: var(--space-2xs) var(--space-md);
33+
border-radius: var(--radius-md);
34+
}
35+
</style>

src/layouts/Layout.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import PreviewBanner from "@/components/ui/PreviewBanner.astro";
23
import Footer from "@/components/ui/Footer.astro";
34
import Header from "@/components/ui/header/Header.astro";
45
import { locales } from "@/i18n/config";
@@ -130,6 +131,7 @@ const fullTitle = title.includes("|")
130131
<slot />
131132
</main>
132133
<Footer />
134+
<PreviewBanner />
133135
</body>
134136
</html>
135137

0 commit comments

Comments
 (0)