Skip to content

Commit 577c248

Browse files
authored
Enhance landing page (#4)
1 parent 17dcd29 commit 577c248

3 files changed

Lines changed: 104 additions & 47 deletions

File tree

src/components/PresetsCodeBlock.astro

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ import { Code } from "astro:components";
33
44
import CopyCodeButton from "./CopyCodeButton.astro";
55
6-
type Preset = {
7-
id: string;
8-
preset: string;
9-
code: string;
10-
};
11-
12-
type Props = {
13-
presets: Array<Preset>;
14-
};
15-
16-
const { presets = [] } = Astro.props;
6+
const presets = [
7+
{
8+
id: "laravel",
9+
preset: "Laravel",
10+
code: "curl -fsSL https://tryphp.dev/presets/laravel | bash",
11+
},
12+
];
1713
---
1814

1915
<section>
@@ -33,7 +29,7 @@ const { presets = [] } = Astro.props;
3329
<div>
3430
{
3531
presets.map((preset) => (
36-
<div class={`relative ${"preset"}`} id={preset.id}>
32+
<div class="relative preset" id={preset.id}>
3733
<Code
3834
class="p-4 rounded"
3935
code={preset.code}
@@ -58,8 +54,8 @@ const { presets = [] } = Astro.props;
5854

5955
buttons.forEach((button) => {
6056
button.addEventListener("click", () => {
61-
const presetId = button.getAttribute("data-id")!;
62-
const preset = document.getElementById(presetId)!;
57+
const id = button.getAttribute("data-id")!;
58+
const preset = document.getElementById(id)!;
6359
presets.forEach((preset) => preset.classList.add("hidden"));
6460
preset.classList.toggle("hidden");
6561
});
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
import { Code } from "astro:components";
3+
4+
import CopyCodeButton from "./CopyCodeButton.astro";
5+
6+
const versions = [
7+
{
8+
id: "php74",
9+
preset: "PHP7.4",
10+
code: "curl -fsSL https://tryphp.dev/7.4/install.sh | bash",
11+
},
12+
{
13+
id: "php81",
14+
preset: "PHP8.1",
15+
code: "curl -fsSL https://tryphp.dev/8.1/install.sh | bash",
16+
},
17+
{
18+
id: "php82",
19+
preset: "PHP8.2",
20+
code: "curl -fsSL https://tryphp.dev/8.2/install.sh | bash",
21+
},
22+
{
23+
id: "php83",
24+
preset: "PHP8.3",
25+
code: "curl -fsSL https://tryphp.dev/8.3/install.sh | bash",
26+
},
27+
];
28+
---
29+
30+
<section>
31+
<div class="flex flex-row gap-2 mb-2">
32+
{
33+
versions.map((preset) => (
34+
<button
35+
class="bg-[#1e1e2e] hover:bg-[#1e1e2e]/90 px-2 py-1 rounded font-bold text-white text-xs version-selector"
36+
data-id={preset.id}
37+
>
38+
{preset.preset}
39+
</button>
40+
))
41+
}
42+
</div>
43+
44+
<div>
45+
{
46+
versions.map((version) => (
47+
<div class="relative version" id={version.id}>
48+
<Code
49+
class="p-4 rounded"
50+
code={version.code}
51+
lang="bash"
52+
theme="catppuccin-mocha"
53+
/>
54+
<CopyCodeButton code={version.code} />
55+
</div>
56+
))
57+
}
58+
</div>
59+
</section>
60+
61+
<script>
62+
// Hide all code snippets except for first one
63+
const versions = document.querySelectorAll<HTMLDivElement>(".version");
64+
versions.forEach((preset) => preset.classList.add("hidden"));
65+
versions[0]?.classList.remove("hidden");
66+
67+
const buttons =
68+
document.querySelectorAll<HTMLButtonElement>(".version-selector");
69+
70+
buttons.forEach((button) => {
71+
button.addEventListener("click", () => {
72+
const id = button.getAttribute("data-id")!;
73+
const version = document.getElementById(id)!;
74+
versions.forEach((preset) => preset.classList.add("hidden"));
75+
version.classList.toggle("hidden");
76+
});
77+
});
78+
</script>

src/pages/index.astro

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Layout from "../layouts/Layout.astro";
66
import CopyCodeButton from "../components/CopyCodeButton.astro";
77
import PresetsCodeBlock from "../components/PresetsCodeBlock.astro";
88
import ThemeToggle from "../components/ThemeToggle.astro";
9+
import VersionsCodeBlock from "../components/VersionsCodeBlock.astro";
910
1011
const code = "curl -fsSL https://tryphp.dev/install.sh | bash";
1112
---
@@ -113,41 +114,23 @@ const code = "curl -fsSL https://tryphp.dev/install.sh | bash";
113114
</section>
114115

115116
<section>
116-
<h2 class="mb-4 font-semibold text-2xl">Custom Install</h2>
117+
<h2 class="mb-4 font-semibold text-2xl">Custom PHP Versions</h2>
117118
<p class="mb-4 text-lg">
118-
You can install custom php versions or tailored presets for various
119-
frameworks and applications. for example, the laravel preset installs
120-
php with all the extensions needed to run a laravel application.
119+
You can install custom PHP versions tailored to your needs. This allows
120+
flexibility for various projects and environments, ensuring you’re
121+
running the right version for your application.
121122
</p>
122-
<PresetsCodeBlock
123-
presets={[
124-
{
125-
id: "php74",
126-
preset: "PHP7.4",
127-
code: "curl -fsSL https://tryphp.dev/7.4/install.sh | bash",
128-
},
129-
{
130-
id: "php81",
131-
preset: "PHP8.1",
132-
code: "curl -fsSL https://tryphp.dev/8.1/install.sh | bash",
133-
},
134-
{
135-
id: "php82",
136-
preset: "PHP8.2",
137-
code: "curl -fsSL https://tryphp.dev/8.2/install.sh | bash",
138-
},
139-
{
140-
id: "php83",
141-
preset: "PHP8.3",
142-
code: "curl -fsSL https://tryphp.dev/8.3/install.sh | bash",
143-
},
144-
{
145-
id: "laravel",
146-
preset: "Laravel",
147-
code: "curl -fsSL https://tryphp.dev/presets/laravel | bash",
148-
},
149-
]}
150-
/>
123+
<VersionsCodeBlock />
124+
</section>
125+
126+
<section>
127+
<h2 class="mb-4 font-semibold text-2xl">Tailored Presets</h2>
128+
<p class="mb-4 text-lg">
129+
We also support tailored presets for popular frameworks and
130+
applications. For example, the Laravel preset installs PHP with all the
131+
necessary extensions to run a Laravel application smoothly.
132+
</p>
133+
<PresetsCodeBlock />
151134
</section>
152135

153136
<section>

0 commit comments

Comments
 (0)