Skip to content

Commit 4336c96

Browse files
committed
add more theme updated
1 parent b244b6d commit 4336c96

5 files changed

Lines changed: 497 additions & 4139 deletions

File tree

add_registry_deps.php

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
<?php
2+
$file = __DIR__ . '/database/seeders/ThemeSeeder.php';
3+
$content = file_get_contents($file);
4+
5+
// Complete font mapping for ALL themes that need registryDependencies
6+
$fontOverrides = [
7+
// === First batch (original 7 had deps already - verify)
8+
9+
// === Already had deps: polar-drift, yeti, boho, tide, ember, noir-ice, verdant-future
10+
11+
// === First edit batch (18 themes)
12+
'brutal-industry' => ['font-inter.json', 'font-jetbrains-mono.json'],
13+
'retrowave' => ['font-inter.json', 'font-jetbrains-mono.json'],
14+
'synth-organica' => ['font-space-grotesk.json', 'font-jetbrains-mono.json'],
15+
'dreamscape' => ['font-work-sans.json', 'font-jetbrains-mono.json'],
16+
'minimalism' => ['font-inter.json', 'font-jetbrains-mono.json'],
17+
'soft-extrude' => ['font-inter.json', 'font-jetbrains-mono.json'],
18+
'frost' => ['font-inter.json', 'font-jetbrains-mono.json'],
19+
'structured' => ['font-inter.json', 'font-jetbrains-mono.json'],
20+
'corporate' => ['font-inter.json', 'font-jetbrains-mono.json'],
21+
'treasury' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
22+
'canopy' => ['font-inter.json', 'font-jetbrains-mono.json'],
23+
'wabi-sabi' => ['font-inter.json', 'font-jetbrains-mono.json'],
24+
'gatsby' => ['font-playfair-display.json', 'font-jetbrains-mono.json'],
25+
'comic-pop' => ['font-poppins.json', 'font-jetbrains-mono.json'],
26+
'storybook' => ['font-playfair-display.json', 'font-jetbrains-mono.json'],
27+
'millennium' => ['font-inter.json', 'font-jetbrains-mono.json'],
28+
'neon-horizon' => ['font-inter.json', 'font-jetbrains-mono.json'],
29+
'web-10' => [],
30+
31+
// === Second edit batch (24 themes)
32+
'letterpress' => ['font-playfair-display.json'],
33+
'green-screen' => ['font-jetbrains-mono.json'],
34+
'cosmos' => ['font-inter.json'],
35+
'tactical' => ['font-roboto.json', 'font-jetbrains-mono.json'],
36+
'inferno' => ['font-inter.json', 'font-jetbrains-mono.json'],
37+
'mauve' => ['font-inter.json', 'font-jetbrains-mono.json'],
38+
'haze' => ['font-inter.json', 'font-jetbrains-mono.json'],
39+
'gothic' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
40+
'fantasy' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
41+
'mythological' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
42+
'urban' => ['font-inter.json', 'font-jetbrains-mono.json'],
43+
'mid-century' => ['font-space-grotesk.json', 'font-jetbrains-mono.json'],
44+
'japanese-zen' => ['font-inter.json', 'font-jetbrains-mono.json'],
45+
'art-nouveau' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
46+
'coastal' => ['font-work-sans.json', 'font-jetbrains-mono.json'],
47+
'scandinavian' => ['font-inter.json', 'font-jetbrains-mono.json'],
48+
'techno' => ['font-inter.json', 'font-jetbrains-mono.json'],
49+
'rustic' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
50+
'surreal' => ['font-space-grotesk.json', 'font-jetbrains-mono.json'],
51+
'spring' => ['font-inter.json', 'font-jetbrains-mono.json'],
52+
'summer' => ['font-poppins.json'],
53+
'autumn' => ['font-playfair-display.json'],
54+
'winter' => ['font-inter.json'],
55+
'solarpunk' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
56+
57+
// === PHP script batch (34 themes)
58+
'steampunk' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
59+
'dieselpunk' => ['font-inter.json', 'font-jetbrains-mono.json'],
60+
'lunarpunk' => ['font-space-grotesk.json', 'font-jetbrains-mono.json'],
61+
'decopunk' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
62+
'atompunk' => ['font-inter.json', 'font-jetbrains-mono.json'],
63+
'biopunk' => ['font-inter.json', 'font-jetbrains-mono.json'],
64+
'ashwood-minimal' => ['font-inter.json', 'font-jetbrains-mono.json'],
65+
'walnut-luxe' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
66+
'cedar-harmony' => ['font-inter.json', 'font-jetbrains-mono.json'],
67+
'ebony-woodcraft' => ['font-space-grotesk.json', 'font-jetbrains-mono.json'],
68+
'theme-default' => ['font-inter.json'],
69+
'boho-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
70+
'bauhaus-theme' => ['font-poppins.json'],
71+
'artistic-gradient-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
72+
'clay-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
73+
'cyberpunk-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
74+
'editorial-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
75+
'acid-core-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
76+
'autumn-grain-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
77+
'brutalist-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
78+
'esports-arena-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
79+
'audio-wave-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
80+
'fashion-avant-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
81+
'edugeek-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
82+
'concrete-jungle-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
83+
'crypto-labs-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
84+
'zinc-stone-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
85+
'paper-stack-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
86+
'nordic-light-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
87+
'warehouse-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
88+
'void-dark-theme' => ['font-inter.json', 'font-jetbrains-mono.json'],
89+
'ember-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
90+
'retro-web-theme' => ['font-inter.json'],
91+
'eco-minimal-theme' => ['font-inter.json', 'font-playfair-display.json', 'font-jetbrains-mono.json'],
92+
];
93+
94+
$modified = 0;
95+
$skipped = 0;
96+
97+
foreach ($fontOverrides as $name => $slugs) {
98+
// Build registry block
99+
if (empty($slugs)) {
100+
$depBlock = " 'registryDependencies' => [],";
101+
} else {
102+
$depBlock = " 'registryDependencies' => [\n";
103+
foreach ($slugs as $slug) {
104+
$depBlock .= " 'https://ui.designbycode.co.za/r/fonts/{$slug}',\n";
105+
}
106+
$depBlock .= " ],";
107+
}
108+
109+
// Find the theme's name in the content
110+
$search = "'name' => '{$name}',";
111+
$pos = strpos($content, $search);
112+
if ($pos === false) {
113+
echo "Theme '{$name}' not found.\n";
114+
continue;
115+
}
116+
117+
// Find font_family line after this name
118+
$remaining = substr($content, $pos);
119+
if (!preg_match("/'font_family'\s*=>\s*'[^']+'/", $remaining, $ffm, PREG_OFFSET_CAPTURE)) {
120+
echo "font_family not found for '{$name}'.\n";
121+
continue;
122+
}
123+
124+
$ffPos = $pos + $ffm[0][1];
125+
$ffLineEnd = strpos($content, "\n", $ffPos);
126+
127+
// Check if registryDependencies already exists BETWEEN name and the NEXT theme's name
128+
// Search from $pos to the beginning of the next theme
129+
$nextThemePos = strpos($content, "\n [\n 'name' => ", $pos + strlen($search));
130+
if ($nextThemePos === false) {
131+
$nextThemePos = strlen($content);
132+
}
133+
$between = substr($content, $pos, $nextThemePos - $pos);
134+
if (str_contains($between, "'registryDependencies'")) {
135+
echo "Theme '{$name}' already has registryDependencies. Skipping.\n";
136+
$skipped++;
137+
continue;
138+
}
139+
140+
// Look at what comes after font_family line
141+
$afterFF = substr($content, $ffLineEnd + 1);
142+
$isBlankNext = (strlen($afterFF) > 0 && $afterFF[0] === "\n");
143+
144+
if ($isBlankNext) {
145+
// After font_family there's a blank line, then 'css' => [
146+
$insertPos = $ffLineEnd + 1; // Insert after newline (before blank line)
147+
$insert = $depBlock . "\n";
148+
} else {
149+
$insertPos = $ffLineEnd + 1;
150+
$insert = $depBlock . "\n\n";
151+
}
152+
153+
$content = substr_replace($content, $insert, $insertPos, 0);
154+
$modified++;
155+
echo "Added registryDependencies to '{$name}'.\n";
156+
}
157+
158+
file_put_contents($file, $content);
159+
echo "\nDone. Modified {$modified} themes, skipped {$skipped} themes.\n";
160+
161+
// Final verification
162+
$themes = preg_match_all("/'name'\s*=>\s*'[^']+'/", $content);
163+
$deps = preg_match_all("/'registryDependencies'\s*=>\s*\[/", $content);
164+
echo "Themes: {$themes}, registryDependencies: {$deps}\n";
165+
if ($themes === $deps) {
166+
echo "MATCH: All themes have exactly one registryDependencies each.\n";
167+
} else {
168+
echo "MISMATCH by " . abs($themes - $deps) . "\n";
169+
}

app/Http/Controllers/ThemesController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ThemesController extends Controller
1010
{
1111
public function index()
1212
{
13-
$availableCategories = Cache::remember('themes:available_categories', 3600, fn () => Theme::query()
13+
$availableCategories = Cache::remember('themes:available_categories', 3600, fn() => Theme::query()
1414
->select('categories')
1515
->get()
1616
->pluck('categories')
@@ -21,10 +21,10 @@ public function index()
2121
->all());
2222

2323
return Inertia::render('themes/index', [
24-
'themes' => Inertia::scroll(Theme::paginate(50)->withQueryString()),
24+
'themes' => Inertia::scroll(Theme::paginate(12)->withQueryString()),
2525
'filters' => request()->only(['search', 'category']),
2626
'availableCategories' => $availableCategories,
27-
'totalThemesCount' => Cache::remember('themes:total_count', 3600, fn () => Theme::count()),
27+
'totalThemesCount' => Cache::remember('themes:total_count', 3600, fn() => Theme::count()),
2828
]);
2929
}
3030

@@ -33,7 +33,7 @@ public function apiIndex()
3333
$query = Theme::query();
3434

3535
if ($search = request('search')) {
36-
$query->where(fn ($q) => $q
36+
$query->where(fn($q) => $q
3737
->where('name', 'like', "%{$search}%")
3838
->orWhere('title', 'like', "%{$search}%")
3939
->orWhere('description', 'like', "%{$search}%")

0 commit comments

Comments
 (0)