Skip to content

Commit 7e18e84

Browse files
committed
wip
1 parent 7c94eab commit 7e18e84

File tree

3 files changed

+90
-9
lines changed

3 files changed

+90
-9
lines changed

src/Web/Code/CodeController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,23 @@ public function preview(
5252

5353
$language = $request->get('lang') ?? 'php';
5454

55-
$editUrl = uri([self::class, 'paste'], lang: $language, code: $code);
5655

5756
$highlightedCode = $highlighter->parse(urldecode(base64_decode($code, strict: true)), $language);
5857

5958
$center = $request->has('center');
6059

60+
$clean = $request->has('clean');
61+
62+
$editUrl = uri([self::class, 'paste'], lang: $language, code: $code);
63+
$cleanUrl = uri([self::class, 'preview'], lang: $language, code: $code, center: $center, clean: true);
64+
6165
return view(__DIR__ . '/code_preview.view.php')->data(
6266
code: $highlightedCode,
6367
editUrl: $editUrl,
6468
language: $language,
6569
center: $center,
70+
clean: $clean,
71+
cleanUrl: $cleanUrl,
6672
);
6773
}
6874
}

src/Web/Code/code_preview.view.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
<x-base>
2-
<x-aurora class="dark:hidden"/>
3-
<x-moonlight />
4-
<x-rain />
5-
6-
<div class="bg-red p-4 fixed z-[99] right-0 top-0 flex gap-2">
1+
<x-base-code>
2+
<div class="bg-red p-4 fixed z-[99] right-0 top-0 flex gap-2" :if="!$clean">
3+
<a
4+
:href="$cleanUrl"
5+
class="
6+
cursor-pointer
7+
bg-white
8+
p-2
9+
rounded-full
10+
shadow-xl
11+
border-2 border-transparent
12+
hover:bg-tempest-blue-500
13+
hover:border-white
14+
">
15+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
16+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25" />
17+
</svg>
18+
</a>
719
<a
820
:href="$editUrl"
921
class="
@@ -23,9 +35,16 @@ class="
2335
</div>
2436

2537
<div class="flex items-center justify-center h-full absolute top-0 left-0 w-full">
26-
<div class="bg-(--ui-bg) border border-(--ui-border) rounded-md p-8 max-h-[75%] overflow-scroll" :class="$center ? 'text-center' : ''" id="screenshot">
38+
<div
39+
class="bg-(--ui-bg) border-(--ui-border) rounded-md p-8 max-h-[75%] overflow-scroll"
40+
:class="implode([
41+
$center ? 'text-center' : '',
42+
$clean ?: 'border'
43+
])"
44+
id="screenshot"
45+
>
2746
<pre data-lang="<?= $language ?>"><?= $code ?></pre>
2847
</div>
2948
</div>
3049

31-
</x-base>
50+
</x-base-code>

src/Web/x-base-code.view.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<html lang="en" class="h-dvh flex flex-col scroll-smooth">
2+
<head>
3+
<!-- Meta title -->
4+
<?php use App\Web\Meta\MetaType;
5+
6+
$title = match (true) {
7+
isset($fullTitle) => $fullTitle,
8+
isset($title) => "{$title} — Tempest",
9+
default => 'Tempest',
10+
}; ?>
11+
12+
<title>{{ $title }}</title>
13+
14+
<link :if="$meta['canonical'] ?? null" rel="canonical" :href="$meta['canonical']" />
15+
16+
<meta name="title" :content="$title">
17+
<meta name="twitter:title" :content="$title">
18+
<meta property="og:title" :content="$title">
19+
<meta itemprop="name" :content="$title">
20+
21+
<meta charset="UTF-8"/>
22+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
23+
24+
<!-- Meta description -->
25+
<?php $description = match (true) {
26+
isset($description) => $description,
27+
default => 'Tempest is a modern framework designed to enable developers to write as little framework-specific code as possible, so that they can focus on application code instead.',
28+
}; ?>
29+
30+
<meta name="description" :content="$description">
31+
<meta name="twitter:description" :content="$description">
32+
<meta property="og:description" :content="$description">
33+
<meta itemprop="description" :content="$description">
34+
35+
36+
<!-- Favicon -->
37+
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png"/>
38+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png"/>
39+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png"/>
40+
<link rel="manifest" href="/favicon/site.webmanifest"/>
41+
42+
<!-- Vite tags -->
43+
<x-vite-tags/>
44+
45+
<x-slot name="head"/>
46+
</head>
47+
<body
48+
class="relative antialiased flex flex-col grow selection:bg-(--ui-primary)/20 selection:text-(--ui-primary) font-sans text-(--ui-text) bg-(--ui-bg) scheme-light dark:scheme-dark !overflow-visible !pr-0"
49+
>
50+
<x-aurora class="dark:hidden" :if="! ($clean ?? null)" />
51+
<x-moonlight :if="! ($clean ?? null)" />
52+
<x-rain :if="! ($clean ?? null)" />
53+
54+
<x-slot/>
55+
</body>
56+
</html>

0 commit comments

Comments
 (0)