@nuraly/lumenjs 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { useDb } from '@nuraly/lumenjs/db';
4
+
5
+ export function loader({ params }: { params: { slug: string } }) {
6
+ const db = useDb();
7
+ const post = db.get('SELECT id, title, slug, content, date FROM posts WHERE slug = ?', params.slug);
8
+ return { post: post || null };
9
+ }
10
+
11
+ @customElement('page-post')
12
+ export class PagePost extends LitElement {
13
+ @property({ type: Object }) data: any;
14
+
15
+ static styles = css`
16
+ :host { display: block; max-width: 720px; margin: 0 auto; padding: 2rem; font-family: system-ui, sans-serif; }
17
+ a { color: #0066cc; text-decoration: none; }
18
+ a:hover { text-decoration: underline; }
19
+ .date { color: #666; font-size: 0.875rem; }
20
+ .content { margin-top: 1rem; line-height: 1.6; color: #333; }
21
+ `;
22
+
23
+ render() {
24
+ const post = this.data?.post;
25
+ if (!post) {
26
+ return html`<p>Post not found. <a href="/">Back to blog</a></p>`;
27
+ }
28
+ return html`
29
+ <a href="/">&larr; Back to blog</a>
30
+ <h1>${post.title}</h1>
31
+ <span class="date">${post.date}</span>
32
+ <div class="content">${post.content}</div>
33
+ `;
34
+ }
35
+ }
@@ -0,0 +1,7 @@
1
+ import { useDb } from '@nuraly/lumenjs/db';
2
+
3
+ export function GET() {
4
+ const db = useDb();
5
+ const stats = db.all('SELECT id, label, value, unit, updated_at FROM stats ORDER BY id');
6
+ return { stats };
7
+ }
@@ -0,0 +1,13 @@
1
+ CREATE TABLE IF NOT EXISTS stats (
2
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
3
+ label TEXT NOT NULL UNIQUE,
4
+ value REAL NOT NULL,
5
+ unit TEXT NOT NULL DEFAULT '',
6
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
7
+ );
8
+
9
+ INSERT INTO stats (label, value, unit) VALUES
10
+ ('Total Users', 1284, 'users'),
11
+ ('Revenue', 42500, 'USD'),
12
+ ('Active Sessions', 89, 'sessions'),
13
+ ('Uptime', 99.97, '%');
@@ -0,0 +1,41 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { useDb } from '@nuraly/lumenjs/db';
4
+
5
+ export function loader() {
6
+ const db = useDb();
7
+ const stats = db.all('SELECT id, label, value, unit, updated_at FROM stats ORDER BY id');
8
+ return { stats };
9
+ }
10
+
11
+ @customElement('page-dashboard')
12
+ export class PageDashboard extends LitElement {
13
+ @property({ type: Object }) data: any;
14
+
15
+ static styles = css`
16
+ :host { display: block; max-width: 960px; margin: 0 auto; padding: 2rem; font-family: system-ui, sans-serif; }
17
+ h1 { font-size: 2rem; margin-bottom: 1.5rem; }
18
+ .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
19
+ .card { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1.5rem; }
20
+ .card .label { font-size: 0.875rem; color: #6b7280; margin-bottom: 0.25rem; }
21
+ .card .value { font-size: 1.75rem; font-weight: 600; color: #111827; }
22
+ .card .unit { font-size: 0.75rem; color: #9ca3af; margin-left: 0.25rem; }
23
+ `;
24
+
25
+ render() {
26
+ const stats = this.data?.stats || [];
27
+ return html`
28
+ <h1>Dashboard</h1>
29
+ <div class="grid">
30
+ ${stats.map((stat: any) => html`
31
+ <div class="card">
32
+ <div class="label">${stat.label}</div>
33
+ <div class="value">
34
+ ${stat.value}<span class="unit">${stat.unit}</span>
35
+ </div>
36
+ </div>
37
+ `)}
38
+ </div>
39
+ `;
40
+ }
41
+ }