-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhello-world.stx
More file actions
173 lines (156 loc) · 6.74 KB
/
hello-world.stx
File metadata and controls
173 lines (156 loc) · 6.74 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
<script server>
import { defineProps, withDefaults } from 'stx'
interface HelloWorldProps {
name?: string
showCounter?: boolean
showThemeSelector?: boolean
}
const { name, showCounter, showThemeSelector } = withDefaults(
defineProps<HelloWorldProps>(),
{
name: 'World',
showCounter: true,
showThemeSelector: true
}
)
// Runtime data
const currentTime = new Date().toLocaleTimeString()
// Color options with TypeScript interface
interface ColorOption {
name: string
value: string
}
const colors: ColorOption[] = [
{ name: 'Violet', value: '#8b5cf6' },
{ name: 'Cyan', value: '#06b6d4' },
{ name: 'Emerald', value: '#10b981' },
{ name: 'Rose', value: '#f43f5e' },
{ name: 'Amber', value: '#f59e0b' }
]
</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 - Hello World</title>
</head>
<body class="min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 text-white">
<!-- Background Effects -->
<div class="fixed inset-0 overflow-hidden pointer-events-none">
<div class="absolute top-1/4 left-1/4 w-96 h-96 bg-violet-500/20 rounded-full blur-3xl"></div>
<div class="absolute bottom-1/4 right-1/4 w-96 h-96 bg-cyan-500/20 rounded-full blur-3xl"></div>
</div>
<div class="relative max-w-2xl mx-auto px-6 py-12">
<!-- Header -->
<div class="text-center mb-12">
<div class="inline-flex items-center gap-3 mb-4">
<div class="w-12 h-12 rounded-xl bg-gradient-to-br from-violet-500 to-cyan-500 flex items-center justify-center shadow-lg shadow-violet-500/25">
<span class="text-2xl">✨</span>
</div>
<h1 id="mainTitle" class="text-4xl font-bold bg-gradient-to-r from-violet-400 to-cyan-400 bg-clip-text text-transparent">
Hello, {{ name }}!
</h1>
</div>
<p class="text-slate-400">Welcome to the stx templating engine</p>
</div>
<!-- Welcome Card -->
<div class="relative group mb-6">
<div class="absolute -inset-1 bg-gradient-to-r from-violet-600/20 to-cyan-600/20 rounded-2xl blur-xl opacity-50 group-hover:opacity-75 transition-opacity"></div>
<div class="relative bg-slate-800/50 backdrop-blur-xl border border-white/10 rounded-2xl p-6">
<p class="text-slate-300 mb-4">
This page is rendered using the stx templating engine. Try modifying
<code class="px-2 py-1 bg-slate-700/50 rounded text-violet-400 text-sm">examples/hello-world.stx</code>
to see changes automatically reload.
</p>
<div class="flex items-center gap-2 text-sm text-slate-500">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
Page loaded at: {{ currentTime }}
</div>
</div>
</div>
<!-- Counter Card with x-element -->
<div class="relative group mb-6" 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">
<h3 class="text-lg font-semibold text-white mb-4 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
</h3>
<div class="flex items-center justify-center gap-4">
<button
class="w-12 h-12 rounded-xl bg-slate-700/50 border border-white/10 text-xl font-bold text-white hover:bg-slate-600/50 hover:border-violet-500/50 transition-all"
@click="count--"
>-</button>
<div class="w-20 h-16 rounded-xl bg-gradient-to-br from-violet-500/20 to-cyan-500/20 border border-white/10 flex items-center justify-center text-3xl font-bold text-white">
<span x-text="count"></span>
</div>
<button
class="w-12 h-12 rounded-xl bg-slate-700/50 border border-white/10 text-xl font-bold text-white hover:bg-slate-600/50 hover:border-violet-500/50 transition-all"
@click="count++"
>+</button>
</div>
</div>
</div>
<!-- Theme Color Card -->
<div class="relative group">
<div class="absolute -inset-1 bg-gradient-to-r from-rose-600/20 to-amber-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">
<h3 class="text-lg font-semibold text-white mb-4 flex items-center gap-2">
<span class="w-8 h-8 rounded-lg bg-gradient-to-br from-rose-500 to-amber-500 flex items-center justify-center text-sm">🎨</span>
Theme Color
</h3>
<p class="text-slate-400 text-sm mb-4">Click a color to change the theme:</p>
<div class="flex items-center gap-3">
@foreach (colors as color)
<button
class="color-option w-10 h-10 rounded-full border-2 border-transparent hover:scale-110 transition-all shadow-lg"
style="background-color: {{ color.value }}; box-shadow: 0 4px 20px {{ color.value }}40"
title="{{ color.name }}"
data-color="{{ color.value }}"
@click="changeThemeColor('{{ color.value }}')"
></button>
@endforeach
</div>
</div>
</div>
<!-- Footer -->
<div class="text-center mt-12 text-sm text-slate-500">
<p>Built with <span class="text-violet-400">stx</span> templating engine</p>
</div>
</div>
<script client>
document.addEventListener('DOMContentLoaded', () => {
window.changeThemeColor = (color) => {
const title = document.getElementById('mainTitle')
if (title) {
title.style.background = `linear-gradient(to right, ${color}, ${adjustColor(color, 40)})`
title.style.webkitBackgroundClip = 'text'
title.style.backgroundClip = 'text'
}
document.querySelectorAll('.color-option').forEach(option => {
const optionColor = option.dataset.color
if (optionColor === color) {
option.style.borderColor = 'white'
option.style.transform = 'scale(1.1)'
} else {
option.style.borderColor = 'transparent'
option.style.transform = 'scale(1)'
}
})
}
function adjustColor(color, amount) {
const hex = color.replace('#', '')
const r = Math.min(255, parseInt(hex.substring(0, 2), 16) + amount)
const g = Math.min(255, parseInt(hex.substring(2, 4), 16) + amount)
const b = Math.min(255, parseInt(hex.substring(4, 6), 16) + amount)
return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`
}
// Set initial active color
changeThemeColor('#8b5cf6')
})
</script>
</body>
</html>