Skip to content

Commit 2986c1b

Browse files
committed
Merge branch 'release'
2 parents 7307951 + 879cb36 commit 2986c1b

File tree

5 files changed

+354
-2
lines changed

5 files changed

+354
-2
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
---
3+
4+
<div data-challenges-signup-popover="true" class="contents">
5+
<slot />
6+
<dialog class="fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 border border-gray-300 dark:border-gray-700 p-6 rounded-none shadow-lg max-w-md w-full backdrop:bg-black/20 dark:backdrop:bg-black/50 backdrop:backdrop-blur-md">
7+
<form method="dialog">
8+
<p class="text-justify text-base mb-12">Sign up to be notified when the <strong>ShaderHunt</strong> platform is available, along with interactive examples teaching TypeGPU from the ground up.</p>
9+
<label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Your name (required)</label>
10+
<input type="text" id="name" name="name" required class="w-full mb-8 px-3 py-2 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-none focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400" />
11+
<label for="email" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Your email (required)</label>
12+
<input type="email" id="email" name="email" required class="w-full mb-8 px-3 py-2 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-none focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400" />
13+
<div class="mb-4"></div>
14+
<div class="flex items-start mb-4">
15+
<input type="checkbox" id="updates-agree" name="updates-agree" required class="relative appearance-none border-2 border-accent-600 rounded-none w-4 h-4 aspect-square mt-1 mr-3 checked:bg-accent-600 checked:border-accent-600 focus:outline-none focus:ring-2 focus:ring-accent-500 after:content-['✓'] after:absolute after:top-0 after:left-0 after:w-full after:h-full after:flex after:items-center after:justify-center after:text-white after:text-xs after:font-bold checked:after:opacity-100 after:opacity-0" />
16+
<label for="updates-agree" class="text-sm text-gray-700 dark:text-gray-300">I agree to receive updates, news, and marketing materials related to ShaderHunt. You can unsubscribe at any time. See our <a target="_blank" rel="noreferrer" href="/TypeGPU/privacy" class="text-black dark:text-white">Privacy Policy</a> for details. (required)</label>
17+
</div>
18+
19+
<div class="flex items-start mb-4">
20+
<input type="checkbox" id="newsletter-agree" name="newsletter-agree" class="relative appearance-none border-2 border-accent-600 rounded-none w-4 h-4 aspect-square mt-1 mr-3 checked:bg-accent-600 checked:border-accent-600 focus:outline-none focus:ring-2 focus:ring-accent-500 after:content-['✓'] after:absolute after:top-0 after:left-0 after:w-full after:h-full after:flex after:items-center after:justify-center after:text-white after:text-xs after:font-bold checked:after:opacity-100 after:opacity-0" />
21+
<label for="newsletter-agree" class="text-sm text-gray-700 dark:text-gray-300">I agree to receive the monthly Software Mansion newsletter with updates on TypeGPU and other React Native, AI, and multimedia projects. You can unsubscribe anytime. See our <a target="_blank" rel="noreferrer" href="/TypeGPU/privacy" class="text-black dark:text-white">Privacy Policy</a> for details.</label>
22+
</div>
23+
<button type="submit" class="mt-4 w-full px-4 py-2 bg-accent-600 dark:bg-accent-700 text-white font-medium border-none rounded-none hover:bg-accent-700 dark:hover:bg-accent-800 focus:outline-none focus:ring-2 focus:ring-accent-500 dark:focus:ring-accent-400">Get Notified</button>
24+
</form>
25+
</dialog>
26+
</div>
27+
28+
<script>
29+
const popovers = document.querySelectorAll('[data-challenges-signup-popover="true"]');
30+
popovers.forEach((popover) => {
31+
const linkElement: HTMLAnchorElement|null = popover.querySelector('a');
32+
const dialogElement: HTMLDialogElement|null = popover.querySelector('dialog');
33+
const formElement: HTMLFormElement|null = popover.querySelector('form');
34+
35+
if (!linkElement || !dialogElement || !formElement) {
36+
return;
37+
}
38+
39+
linkElement.addEventListener('click', (e) => {
40+
e.preventDefault();
41+
dialogElement?.showModal();
42+
});
43+
44+
formElement.addEventListener('submit', async (e) => {
45+
e.preventDefault();
46+
const formData = new FormData(formElement);
47+
const data = {
48+
name: formData.get('name'),
49+
email: formData.get('email'),
50+
newsletterAgree: formData.get('newsletter-agree') === 'on'
51+
};
52+
53+
try {
54+
const response = await fetch('https://swmansion.dev/api/shaderhunt/signin', {
55+
method: 'POST',
56+
headers: {
57+
'Content-Type': 'application/json'
58+
},
59+
body: JSON.stringify(data)
60+
});
61+
console.log(await response.text());
62+
if (response.ok) {
63+
formElement.reset();
64+
dialogElement.close();
65+
} else {
66+
alert('Error submitting form. Please try again.');
67+
}
68+
} catch (error) {
69+
alert('Network error. Please try again.');
70+
}
71+
});
72+
});
73+
</script>

apps/typegpu-docs/src/components/starlight/Sidebar.astro

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
---
22
import VanillaSidebar from "@astrojs/starlight/components/Sidebar.astro";
3+
import ChallengesSignupPopover from "../shaderhunt/ChallengesSignupPopover.astro";
34
---
45

56
<div class="md:sl-hidden">
6-
<a href="/TypeGPU/getting-started">Documentation</a>
7+
<a href="/TypeGPU/getting-started">Docs</a>
78
</div>
89
<div class="md:sl-hidden">
910
<a href="/TypeGPU/examples">Examples</a>
1011
</div>
12+
<ChallengesSignupPopover>
13+
<div class="md:sl-hidden">
14+
<a href="/TypeGPU/getting-started">Challenges</a>
15+
</div>
16+
</ChallengesSignupPopover>
1117
<div class="md:sl-hidden">
1218
<a href="/TypeGPU/blog">Blog</a>
1319
</div>

apps/typegpu-docs/src/components/starlight/ThemeSelect.astro

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
---
22
import StarlightThemeSelect from "@astrojs/starlight/components/ThemeSelect.astro";
3+
import ChallengesSignupPopover from "../shaderhunt/ChallengesSignupPopover.astro";
34
---
45

56
<div>
6-
<a href="/TypeGPU/getting-started">Documentation</a>
7+
<a href="/TypeGPU/getting-started">Docs</a>
78
</div>
89
<div>
910
<a href="/TypeGPU/examples">Examples</a>
1011
</div>
12+
<ChallengesSignupPopover>
13+
<div>
14+
<a href="/TypeGPU/examples">Challenges</a>
15+
</div>
16+
</ChallengesSignupPopover>
1117
<div>
1218
<a href="/TypeGPU/blog">Blog</a>
1319
</div>

0 commit comments

Comments
 (0)