-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdemo.stx
More file actions
196 lines (176 loc) Β· 7.36 KB
/
demo.stx
File metadata and controls
196 lines (176 loc) Β· 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<script server>
import { defineProps, withDefaults } from 'stx'
// TypeScript Props for the demo page
interface DemoProps {
title?: string
description?: string
showFeatures?: boolean
}
const { title, description, showFeatures } = withDefaults(
defineProps<DemoProps>(),
{
title: 'stx Interactive Demo',
description: 'A powerful templating engine for Bun',
showFeatures: true
}
)
// Feature data with TypeScript interface
interface Feature {
name: string
icon: string
description: string
color: string
}
const features: Feature[] = [
{ name: "Templates", icon: "π", description: "Write HTML with powerful templating syntax", color: "violet" },
{ name: "Directives", icon: "β‘", description: "Use @if, @foreach, and other directives", color: "cyan" },
{ name: "Components", icon: "π§©", description: "Build reusable components", color: "emerald" },
{ name: "Streaming", icon: "π", description: "Support for streaming rendering", color: "rose" }
]
// User data with TypeScript interface
interface User {
name: string
isLoggedIn: boolean
role: string
}
const user: User = {
name: "Demo User",
isLoggedIn: true,
role: "Developer"
}
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>stx Demo</title>
</head>
<body class="min-h-screen bg-slate-900 text-white transition-colors duration-300" id="app-body">
<!-- Background Effects -->
<div class="fixed inset-0 overflow-hidden pointer-events-none">
<div class="absolute top-0 left-1/4 w-96 h-96 bg-violet-500/10 rounded-full blur-3xl"></div>
<div class="absolute bottom-0 right-1/4 w-96 h-96 bg-cyan-500/10 rounded-full blur-3xl"></div>
</div>
<div class="relative max-w-4xl mx-auto px-6 py-12">
<!-- Header -->
<header class="text-center mb-12">
<div class="inline-flex items-center gap-3 mb-4">
<div class="w-14 h-14 rounded-2xl bg-gradient-to-br from-violet-500 to-cyan-500 flex items-center justify-center shadow-lg shadow-violet-500/25">
<span class="text-3xl">π</span>
</div>
</div>
<h1 class="text-4xl font-bold bg-gradient-to-r from-violet-400 via-cyan-400 to-violet-400 bg-clip-text text-transparent mb-3">
{{ title }}
</h1>
<p class="text-slate-400 text-lg">{{ description }}</p>
</header>
<!-- User Bar -->
<div class="relative group mb-10">
<div class="absolute -inset-1 bg-gradient-to-r from-violet-600/20 to-cyan-600/20 rounded-2xl blur-xl opacity-50"></div>
<div class="relative bg-slate-800/50 backdrop-blur-xl border border-white/10 rounded-2xl p-4 flex items-center justify-between">
<div class="flex items-center gap-3">
@if (user.isLoggedIn)
<div class="w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center">
<span class="text-lg">π</span>
</div>
<div>
<p class="text-white font-medium">Welcome back, {{ user.name }}</p>
<p class="text-sm text-slate-400">{{ user.role }}</p>
</div>
@else
<div class="w-10 h-10 rounded-xl bg-slate-700 flex items-center justify-center">
<span class="text-lg">π</span>
</div>
<p class="text-slate-300">Welcome, Guest</p>
@endif
</div>
<button
id="themeToggle"
class="flex items-center gap-2 px-4 py-2 bg-slate-700/50 border border-white/10 rounded-xl hover:border-violet-500/50 transition-all"
@click="toggleTheme()"
>
<span id="themeIcon">π</span>
<span id="themeText" class="text-sm text-slate-300">Dark Mode</span>
</button>
</div>
</div>
<!-- Features Section -->
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-2">
<span class="w-8 h-8 rounded-lg bg-gradient-to-br from-violet-500 to-cyan-500 flex items-center justify-center text-sm">β¨</span>
Features
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-10">
@foreach (features as feature)
<div class="relative group cursor-pointer" @click="pulseCard(this)">
<div class="absolute -inset-1 bg-gradient-to-r from-{{ feature.color }}-600/20 to-{{ feature.color }}-400/20 rounded-2xl blur-xl opacity-0 group-hover:opacity-75 transition-opacity"></div>
<div class="relative bg-slate-800/50 backdrop-blur-xl border border-white/10 rounded-2xl p-5 hover:border-{{ feature.color }}-500/50 transition-all">
<div class="flex items-center gap-3 mb-3">
<div class="w-10 h-10 rounded-xl bg-gradient-to-br from-{{ feature.color }}-500 to-{{ feature.color }}-400 flex items-center justify-center shadow-lg">
<span class="text-lg">{{ feature.icon }}</span>
</div>
<h3 class="text-lg font-semibold text-white">{{ feature.name }}</h3>
</div>
<p class="text-slate-400 text-sm">{{ feature.description }}</p>
</div>
</div>
@endforeach
</div>
<!-- Counter Section with x-element reactivity -->
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-2">
<span class="w-8 h-8 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center text-sm">π’</span>
Interactive Counter
</h2>
<div class="relative group mb-10" x-data="{ count: 0 }">
<div class="absolute -inset-1 bg-gradient-to-r from-emerald-600/20 to-teal-600/20 rounded-2xl blur-xl opacity-50"></div>
<div class="relative bg-slate-800/50 backdrop-blur-xl border border-white/10 rounded-2xl p-6">
<div class="flex items-center justify-center gap-6">
<button
class="w-14 h-14 rounded-xl bg-slate-700/50 border border-white/10 text-2xl font-bold text-white hover:bg-rose-500/20 hover:border-rose-500/50 hover:text-rose-400 transition-all"
@click="count--"
>-</button>
<div class="w-24 h-20 rounded-2xl bg-gradient-to-br from-emerald-500/20 to-teal-500/20 border border-emerald-500/30 flex items-center justify-center text-4xl font-bold text-white">
<span x-text="count"></span>
</div>
<button
class="w-14 h-14 rounded-xl bg-slate-700/50 border border-white/10 text-2xl font-bold text-white hover:bg-emerald-500/20 hover:border-emerald-500/50 hover:text-emerald-400 transition-all"
@click="count++"
>+</button>
</div>
</div>
</div>
<!-- Footer -->
<div class="text-center text-sm text-slate-500">
<p>Built with <span class="text-violet-400 font-medium">stx</span> templating engine</p>
</div>
</div>
<script client>
document.addEventListener('DOMContentLoaded', () => {
let isDark = true
const body = document.getElementById('app-body')
const themeIcon = document.getElementById('themeIcon')
const themeText = document.getElementById('themeText')
window.toggleTheme = () => {
isDark = !isDark
if (isDark) {
body.classList.remove('bg-slate-100')
body.classList.add('bg-slate-900')
themeIcon.textContent = 'π'
themeText.textContent = 'Dark Mode'
} else {
body.classList.remove('bg-slate-900')
body.classList.add('bg-slate-100')
themeIcon.textContent = 'βοΈ'
themeText.textContent = 'Light Mode'
}
}
window.pulseCard = (card) => {
card.style.transform = 'scale(0.98)'
setTimeout(() => {
card.style.transform = 'scale(1)'
}, 150)
}
})
</script>
</body>
</html>