Skip to content

Commit 8857d74

Browse files
Merge pull request #15 from designbycode/feature/advanced-theme-creation-2953705128562490666
Advanced Theme Creation: AI, Manual, and Forking
2 parents c20725d + 58ffc64 commit 8857d74

105 files changed

Lines changed: 7869 additions & 3946 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/inertia-react-development/SKILL.md

Lines changed: 0 additions & 524 deletions
This file was deleted.

.claude/skills/inertia-react-development/SKILL.md

Lines changed: 0 additions & 524 deletions
This file was deleted.

AGENTS.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
99

1010
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1111

12-
- php - 8.4
12+
- php - 8.3
1313
- inertiajs/inertia-laravel (INERTIA_LARAVEL) - v3
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
@@ -118,13 +118,6 @@ This project has domain-specific skills available in `**/skills/**`. You MUST ac
118118

119119
- Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/), which is the fastest way to deploy and scale production Laravel applications.
120120

121-
=== herd rules ===
122-
123-
# Laravel Herd
124-
125-
- The application is served by Laravel Herd at `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate valid URLs. Never run commands to serve the site. It is always available.
126-
- Use the `herd` CLI to manage services, PHP versions, and sites (e.g. `herd sites`, `herd services:start <service>`, `herd php:list`). Run `herd list` to discover all available commands.
127-
128121
=== tests rules ===
129122

130123
# Test Enforcement

CLAUDE.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
99

1010
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1111

12-
- php - 8.4
12+
- php - 8.3
1313
- inertiajs/inertia-laravel (INERTIA_LARAVEL) - v3
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
@@ -118,13 +118,6 @@ This project has domain-specific skills available in `**/skills/**`. You MUST ac
118118

119119
- Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/), which is the fastest way to deploy and scale production Laravel applications.
120120

121-
=== herd rules ===
122-
123-
# Laravel Herd
124-
125-
- The application is served by Laravel Herd at `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate valid URLs. Never run commands to serve the site. It is always available.
126-
- Use the `herd` CLI to manage services, PHP versions, and sites (e.g. `herd sites`, `herd services:start <service>`, `herd php:list`). Run `herd list` to discover all available commands.
127-
128121
=== tests rules ===
129122

130123
# Test Enforcement

GEMINI.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
99

1010
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1111

12-
- php - 8.4
12+
- php - 8.3
1313
- inertiajs/inertia-laravel (INERTIA_LARAVEL) - v3
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
@@ -118,13 +118,6 @@ This project has domain-specific skills available in `**/skills/**`. You MUST ac
118118

119119
- Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/), which is the fastest way to deploy and scale production Laravel applications.
120120

121-
=== herd rules ===
122-
123-
# Laravel Herd
124-
125-
- The application is served by Laravel Herd at `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate valid URLs. Never run commands to serve the site. It is always available.
126-
- Use the `herd` CLI to manage services, PHP versions, and sites (e.g. `herd sites`, `herd services:start <service>`, `herd php:list`). Run `herd list` to discover all available commands.
127-
128121
=== tests rules ===
129122

130123
# Test Enforcement

app/Http/Controllers/ThemesController.php

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers;
44

55
use App\Models\Theme;
6+
use App\Services\AiService;
67
use Illuminate\Http\Request;
78
use Illuminate\Support\Facades\Cache;
89
use Illuminate\Support\Facades\DB;
@@ -13,24 +14,42 @@
1314

1415
class ThemesController extends Controller
1516
{
16-
public function create()
17+
public function create(Request $request)
1718
{
18-
return Inertia::render('themes/create');
19+
$baseTheme = null;
20+
if ($fork = $request->query('fork')) {
21+
$baseTheme = Theme::where('name', $fork)->first();
22+
if ($baseTheme) {
23+
$baseTheme->load('tags');
24+
$tags = $baseTheme->tags->pluck('name')->toArray();
25+
$baseTheme = $baseTheme->toArray();
26+
$baseTheme['tags'] = $tags;
27+
}
28+
}
29+
30+
return Inertia::render('themes/create', [
31+
'baseTheme' => $baseTheme,
32+
]);
1933
}
2034

2135
public function store(Request $request)
2236
{
2337
$request->validate([
24-
'url' => ['required', 'url'],
38+
'url' => ['required_without:theme_data', 'nullable', 'url'],
39+
'theme_data' => ['required_without:url', 'nullable', 'array'],
2540
]);
2641

27-
$response = Http::get($request->url);
42+
if ($request->url) {
43+
$response = Http::get($request->url);
2844

29-
if ($response->failed()) {
30-
return back()->withErrors(['url' => 'Could not fetch registry from the provided URL.']);
31-
}
45+
if ($response->failed()) {
46+
return back()->withErrors(['url' => 'Could not fetch registry from the provided URL.']);
47+
}
3248

33-
$data = $response->json();
49+
$data = $response->json();
50+
} else {
51+
$data = $request->theme_data;
52+
}
3453

3554
if (empty($data) || ! is_array($data)) {
3655
return back()->withErrors(['url' => 'Invalid registry JSON format.']);
@@ -56,6 +75,12 @@ public function store(Request $request)
5675
$errors[] = '"cssVars.dark" must be an object.';
5776
}
5877
}
78+
} elseif (isset($data['vars_light']) && isset($data['vars_dark'])) {
79+
// Support direct vars_light/vars_dark for manual/AI creation
80+
$data['cssVars'] = [
81+
'light' => $data['vars_light'],
82+
'dark' => $data['vars_dark'],
83+
];
5984
}
6085

6186
if (isset($data['files'])) {
@@ -100,22 +125,28 @@ public function store(Request $request)
100125
}
101126

102127
if (! empty($errors)) {
103-
return back()->withErrors(['url' => implode(' ', $errors)]);
128+
$errorKey = $request->url ? 'url' : 'theme_data';
129+
130+
return back()->withErrors([$errorKey => implode(' ', $errors)]);
104131
}
105132

106133
$data['name'] = Str::kebab($data['name']);
107134
$data['type'] = 'registry:theme';
108135

109136
if (! ($data['author'] ?? null)) {
110-
$host = Str::of(parse_url($request->url, PHP_URL_HOST))
111-
->replaceFirst('www.', '')
112-
->before('.')
113-
->toString();
114-
$data['author'] = $host;
137+
if ($request->url) {
138+
$host = Str::of(parse_url($request->url, PHP_URL_HOST))
139+
->replaceFirst('www.', '')
140+
->before('.')
141+
->toString();
142+
$data['author'] = $host;
143+
} else {
144+
$data['author'] = auth()->user()->name;
145+
}
115146
}
116147

117148
if (Theme::where('name', $data['name'])->exists()) {
118-
return back()->withErrors(['url' => "A theme named [{$data['name']}] already exists."]);
149+
$data['name'] = $data['name'].'-'.Str::random(4);
119150
}
120151

121152
$theme = Theme::fromRegistry($data);
@@ -133,6 +164,21 @@ public function store(Request $request)
133164
->with('success', 'Theme created successfully.');
134165
}
135166

167+
public function generate(Request $request, AiService $aiService)
168+
{
169+
$request->validate([
170+
'prompt' => ['required', 'string', 'max:500'],
171+
]);
172+
173+
$themeData = $aiService->generateFullTheme($request->prompt);
174+
175+
if (empty($themeData)) {
176+
return response()->json(['error' => 'Failed to generate theme.'], 500);
177+
}
178+
179+
return response()->json($themeData);
180+
}
181+
136182
public function index()
137183
{
138184
$availableTags = Cache::remember('themes:available_tags', 3600, function () {

app/Models/Theme.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Observers\ThemeObserver;
77
use Illuminate\Database\Eloquent\Attributes\Fillable;
88
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
9+
use Illuminate\Database\Eloquent\Factories\HasFactory;
910
use Illuminate\Database\Eloquent\Model;
1011
use Illuminate\Database\Eloquent\Relations\BelongsTo;
1112
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -27,7 +28,7 @@
2728
#[ObservedBy(ThemeObserver::class)]
2829
class Theme extends Model
2930
{
30-
use HasTags, HasTheme, SoftDeletes;
31+
use HasFactory, HasTags, HasTheme, SoftDeletes;
3132

3233
protected $table = 'themes';
3334

boost.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"socialite-development",
1616
"wayfinder-development",
1717
"pest-testing",
18-
"inertia-react-development",
1918
"tailwindcss-development"
2019
]
2120
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"laravel/tinker": "^3.0",
2020
"laravel/wayfinder": "^0.1.14",
2121
"spatie/laravel-permission": "^7.4",
22-
"spatie/laravel-tags": "^4.11"
22+
"spatie/laravel-tags": "^4.11",
23+
"symfony/var-dumper": "7.4.*"
2324
},
2425
"require-dev": {
2526
"fakerphp/faker": "^1.24",

composer.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)