Skip to content

Commit

Permalink
feat(app): Add Pop Culture references interaction using Preact
Browse files Browse the repository at this point in the history
Implementing Astro Islands concept!
  • Loading branch information
djsiddz committed Feb 8, 2024
1 parent 31b5980 commit 8a8b359
Show file tree
Hide file tree
Showing 6 changed files with 328 additions and 13 deletions.
7 changes: 5 additions & 2 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { defineConfig } from 'astro/config';

import preact from "@astrojs/preact";

// https://astro.build/config
export default defineConfig({
site: "https://djsiddz.github.io",
base: "/space-ahead"
});
base: "/space-ahead",
integrations: [preact()]
});
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "space-ahead",
"type": "module",
"version": "0.1.0",
"version": "0.6.0",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
Expand All @@ -10,7 +10,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/preact": "^3.1.0",
"@astrojs/rss": "^4.0.5",
"astro": "^4.3.1"
"astro": "^4.3.1",
"preact": "^10.19.4"
}
}
8 changes: 8 additions & 0 deletions src/components/SpaceEmoji.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useState } from "preact/hooks";

export default function SpaceEmoji({emojis}) {
const getRandomEmoji = () => emojis[(Math.floor(Math.random() * emojis.length))];
const [emoji, setEmoji] = useState(getRandomEmoji());

return <button class="kanit-regular text-balance" title="Click Me!" style={{fontSize: "1rem", background: "transparent", border: "none", cursor: "pointer", color: "whitesmoke", marginBottom: 0}} onClick={() => setEmoji(getRandomEmoji())}>{emoji}</button>;
}
23 changes: 22 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
---
import SpaceEmoji from "../components/SpaceEmoji";
import MainLayout from "../layouts/MainLayout.astro";
const emojis = [
"πŸš€ To Infinity, And Beyond!",
"🌌 In a galaxy far far away...",
"⭐ May the force be with you!",
"β˜„οΈ Game Over",
"β˜€οΈ β€œTime is an illusion. Lunchtime doubly so.” β€” Douglas Adams, H2G2",
"πŸŒ‘ The Eagle has landed!",
"πŸ›°οΈ 42",
"πŸ€– Wall-E",
"πŸ‘½ E.T. Phone Home",
"🌠 We'll be Counting Stars",
"πŸ‘Ύ Press Start",
"🌍 Powered by Astro & Preact",
"πŸ–– Live long and prosper!",
];
---

<MainLayout pageTitle="Space Ahead - An Astro Blog">
<h1 class="honk-ff balance-text">Space Ahead <span class="blinking">!</span></h1>
<h1 class="honk-ff balance-text">
Space Ahead <span class="blinking">!</span>
</h1>
<SpaceEmoji client:load emojis={emojis} />
</MainLayout>
8 changes: 6 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "astro/tsconfigs/base"
}
"extends": "astro/tsconfigs/base",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
Loading

0 comments on commit 8a8b359

Please sign in to comment.