create-isotope-app 1.2.5 → 1.2.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-isotope-app",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Atomic-based PHP & React hybrid framework for ATOMS GAMING",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -5,32 +5,30 @@ export const postsPageIsx = (styleChoice) => {
5
5
  export const nucleus = proton\`
6
6
  // DATABASE CRUD EXAMPLE
7
7
  try {
8
- // In a real setup, you would have a 'posts' table
9
- // $posts = \\Isotope\\Database::query("SELECT * FROM posts ORDER BY created_at DESC")->fetchAll();
8
+ // Attempt to fetch from database
9
+ $posts = \\Isotope\\Database::query("SELECT * FROM posts ORDER BY created_at DESC")->fetchAll();
10
10
 
11
- // Mock data for demonstration if DB is not connected
12
- $posts = [
13
- ['id' => 1, 'title' => 'Getting Started with Isotope', 'content' => 'Isotope is amazing!', 'created_at' => '2024-02-15'],
14
- ['id' => 2, 'title' => 'Atomic Fusion Explained', 'content' => 'Combine PHP and React easily.', 'created_at' => '2024-02-16']
15
- ];
16
-
17
11
  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
18
12
  $action = $_POST['action'] ?? '';
19
- if ($action === 'create') {
20
- $title = $_POST['title'] ?? 'New Post';
21
- // \\Isotope\\Database::query("INSERT INTO posts (title) VALUES (?)", [$title]);
13
+ if ($action === 'create' && !empty($_POST['title'])) {
14
+ $title = $_POST['title'];
15
+ \\Isotope\\Database::query("INSERT INTO posts (title, content) VALUES (?, ?)", [$title, "New content from Isotope"]);
22
16
  header("Location: /posts");
23
17
  exit;
24
18
  }
25
19
  }
26
-
27
- return [
28
- 'posts' => $posts,
29
- 'db_config' => $_ENV['DB_NAME'] ?? 'Not Configured'
30
- ];
31
20
  } catch (\\Exception $e) {
32
- return ['error' => $e->getMessage(), 'posts' => []];
21
+ // Fallback to mock data if database is not set up yet
22
+ $posts = [
23
+ ['id' => 1, 'title' => 'Getting Started with Isotope', 'content' => 'Isotope is amazing!', 'created_at' => '2024-02-15'],
24
+ ['id' => 2, 'title' => 'Atomic Fusion Explained', 'content' => 'Combine PHP and React easily.', 'created_at' => '2024-02-16']
25
+ ];
33
26
  }
27
+
28
+ return [
29
+ 'posts' => $posts,
30
+ 'db_config' => $_ENV['DB_NAME'] ?? 'Not Configured'
31
+ ];
34
32
  \`;
35
33
 
36
34
  "use client";
@@ -45,7 +43,6 @@ interface Post {
45
43
  interface PostsPageProps {
46
44
  posts: Post[];
47
45
  db_config?: string;
48
- error?: string;
49
46
  }
50
47
 
51
48
  export default function PostsPage({ posts, db_config }: PostsPageProps) {
@@ -61,6 +58,7 @@ export default function PostsPage({ posts, db_config }: PostsPageProps) {
61
58
  type="text"
62
59
  name="title"
63
60
  placeholder="Post title..."
61
+ required
64
62
  className="flex-1 bg-black/40 border border-white/20 rounded-lg px-4 py-2 focus:border-[#00d4ff] outline-none"
65
63
  />
66
64
  <button className="bg-[#00d4ff] text-black font-bold px-6 py-2 rounded-lg hover:bg-[#00b8e6] transition-colors">
@@ -71,7 +69,7 @@ export default function PostsPage({ posts, db_config }: PostsPageProps) {
71
69
  </div>
72
70
 
73
71
  <div className="space-y-4">
74
- {posts.map(post => (
72
+ {posts.map((post: Post) => (
75
73
  <div key={post.id} className="p-6 bg-white/5 rounded-xl border border-white/10 hover:border-[#00d4ff]/30 transition-all">
76
74
  <div className="flex justify-between items-start mb-2">
77
75
  <h3 className="text-2xl font-bold">{post.title}</h3>
@@ -89,10 +87,14 @@ export default function PostsPage({ posts, db_config }: PostsPageProps) {
89
87
  return `import { proton } from '../../src/isotope';
90
88
 
91
89
  export const nucleus = proton\`
92
- // DATABASE CRUD EXAMPLE (Mock)
93
- $posts = [
94
- ['id' => 1, 'title' => 'Default Template Post', 'content' => 'No Tailwind content here.']
95
- ];
90
+ // DATABASE CRUD EXAMPLE (Mock fallback)
91
+ try {
92
+ $posts = \\Isotope\\Database::query("SELECT * FROM posts ORDER BY created_at DESC")->fetchAll();
93
+ } catch (\\Exception $e) {
94
+ $posts = [
95
+ ['id' => 1, 'title' => 'Default Template Post', 'content' => 'No Tailwind content here.']
96
+ ];
97
+ }
96
98
  return [
97
99
  'posts' => $posts
98
100
  ];
@@ -115,7 +117,7 @@ export default function PostsPage({ posts }: PostsPageProps) {
115
117
  return (
116
118
  <div style={{ padding: '2rem', color: 'white' }}>
117
119
  <h1>CRUD Demo</h1>
118
- {posts.map(post => (
120
+ {posts.map((post: Post) => (
119
121
  <div key={post.id} style={{ marginBottom: '1rem', padding: '1rem', border: '1px solid #333' }}>
120
122
  <h3>{post.title}</h3>
121
123
  <p>{post.content}</p>