-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLiquidGlassThemeServiceProvider.php
More file actions
342 lines (314 loc) · 16.5 KB
/
Copy pathLiquidGlassThemeServiceProvider.php
File metadata and controls
342 lines (314 loc) · 16.5 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<?php
declare(strict_types=1);
namespace Capell\ThemeLiquidGlass;
use Capell\Core\Data\RenderableDefinitionData;
use Capell\Core\Data\VendorAssetData;
use Capell\Core\Enums\FrontendRuntime;
use Capell\Core\Enums\VendorAssetEnum;
use Capell\Core\Facades\CapellCore;
use Capell\Core\Models\Theme;
use Capell\Core\Support\Renderables\RenderableRegistry;
use Capell\Core\ThemeStudio\Data\ThemeDefinitionData;
use Capell\Core\ThemeStudio\Data\ThemeFrontendBuildAssetsData;
use Capell\Core\ThemeStudio\Data\ThemePresetData;
use Capell\Core\ThemeStudio\Theme\ThemeRegistry;
use Capell\FoundationTheme\Support\Editor\StandardThemeEditorSchema;
use Capell\FoundationTheme\Support\Providers\RegistersLayoutNativeThemeDefaults;
use Capell\ThemeLiquidGlass\Console\Commands\DemoCommand;
use Capell\ThemeLiquidGlass\Enums\WidgetComponentEnum;
use Capell\ThemeLiquidGlass\Support\Interceptors\Themes\LiquidGlassThemeInterceptor;
use Illuminate\Support\ServiceProvider;
use Override;
class LiquidGlassThemeServiceProvider extends ServiceProvider
{
use RegistersLayoutNativeThemeDefaults;
public const string THEME_KEY = 'liquid-glass';
public const string CSS_SOURCE = 'resources/css/theme-liquid-glass.css';
public const string CSS_BUILD_INPUT = 'resources/css/capell/themes/liquid-glass.css';
public const string CSS_CONDITION = 'theme-css:liquid-glass';
public const string PUBLIC_PREVIEW_IMAGE = '/vendor/capell/themes/liquid-glass.svg';
public static string $packageName = 'capell-app/theme-liquid-glass';
public static function definition(): ThemeDefinitionData
{
return new ThemeDefinitionData(
key: self::THEME_KEY,
name: 'Liquid Glass',
description: 'A free modern glass interface with translucent panels, crisp content rhythm, and warm accent actions.',
package: self::$packageName,
previewImage: self::PUBLIC_PREVIEW_IMAGE,
tags: ['Glass', 'Modern', 'Launch'],
bestFit: ['Modern service sites', 'Product launches', 'Design-led teams'],
presets: [
new ThemePresetData(
key: 'clarity',
name: 'Clarity',
description: 'Bright glass surfaces, teal structure, and warm action accents.',
previewImage: self::PUBLIC_PREVIEW_IMAGE,
values: [
'primaryColor' => '#0f766e',
'accentColor' => '#f97316',
'neutralColor' => '#24313a',
'surfaceColor' => '#f3fbfa',
'foregroundColor' => '#10202a',
'headingFont' => 'manrope',
'bodyFont' => 'inter',
'spacing' => 'balanced',
'cardStyle' => 'elevated',
'navigationStyle' => 'standard',
'layoutPresentation' => 'editorial',
'motionIntensity' => 'subtle',
'mediaTreatment' => 'framed',
'radius' => 'xl',
'headingScale' => 'balanced',
'cardDensity' => 'comfortable',
'overlayTreatment' => 'subtle',
'glassDepth' => 'balanced',
],
),
new ThemePresetData(
key: 'prism',
name: 'Prism',
description: 'Fresh cyan glass, rose highlights, and spacious editorial cards.',
previewImage: self::PUBLIC_PREVIEW_IMAGE,
values: [
'primaryColor' => '#0e7490',
'accentColor' => '#db2777',
'neutralColor' => '#1f2933',
'surfaceColor' => '#edf7fb',
'foregroundColor' => '#111827',
'headingFont' => 'sora',
'bodyFont' => 'inter',
'spacing' => 'spacious',
'cardStyle' => 'raised',
'navigationStyle' => 'prominent',
'layoutPresentation' => 'full-bleed',
'motionIntensity' => 'subtle',
'mediaTreatment' => 'framed',
'radius' => 'xl',
'headingScale' => 'expressive',
'cardDensity' => 'spacious',
'overlayTreatment' => 'subtle',
'glassDepth' => 'prismatic',
],
),
new ThemePresetData(
key: 'graphite',
name: 'Graphite',
description: 'Dark glass panels with amber contrast and compact information density.',
previewImage: self::PUBLIC_PREVIEW_IMAGE,
values: [
'primaryColor' => '#334155',
'accentColor' => '#f59e0b',
'neutralColor' => '#111827',
'surfaceColor' => '#151917',
'foregroundColor' => '#f7faf7',
'headingFont' => 'manrope',
'bodyFont' => 'inter',
'spacing' => 'balanced',
'cardStyle' => 'bordered',
'navigationStyle' => 'minimal',
'layoutPresentation' => 'structured',
'motionIntensity' => 'subtle',
'mediaTreatment' => 'framed',
'radius' => 'lg',
'headingScale' => 'compact',
'cardDensity' => 'compact',
'overlayTreatment' => 'strong',
'glassDepth' => 'restrained',
],
),
],
frontend: [
'editor' => StandardThemeEditorSchema::withExtraTokens(
groups: ['identity' => ['glassDepth']],
tokens: ['glassDepth' => ['options' => ['restrained', 'balanced', 'prismatic']]],
),
'assets' => new ThemeFrontendBuildAssetsData(
cssSource: self::CSS_SOURCE,
cssBuildInput: self::CSS_BUILD_INPUT,
condition: self::CSS_CONDITION,
),
],
assets: [],
runtime: FrontendRuntime::Blade,
extends: 'default',
);
}
#[Override]
public function register(): void {}
public function boot(ThemeRegistry $registry): void
{
if ($this->app->runningInConsole()) {
$this->commands([DemoCommand::class]);
$this->publishes([
__DIR__ . '/../docs/assets/marketplace/extension-card.svg' => public_path(ltrim(self::PUBLIC_PREVIEW_IMAGE, '/')),
], 'capell-theme-liquid-glass-assets');
}
if (! CapellCore::isPackageInstalled(self::$packageName)) {
return;
}
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'capell-theme-liquid-glass');
// See RegistersLayoutNativeThemeDefaults::registerThemeViewNamespace()'s
// docblock for why this theme needs both a plain view namespace AND
// an anonymous-component namespace registered for the same views —
// in short, the `Theme::meta.header_file` / `footer_file`
// chrome-override seam (documented further below, at
// registerLayoutAreas()'s docblock) resolves through
// `<x-dynamic-component>`, which only consults the component
// namespace, not the plain view namespace.
$this->registerThemeViewNamespace('capell-theme-liquid-glass', __DIR__ . '/../resources/views');
$this->registerVendorCssAssets();
$this->registerLayoutAreas();
$this->registerBespokeWidgetRenderables();
$this->registerModelInterceptors();
// Definition-only registration: Liquid Glass no longer ships a
// ThemeRenderer or section renderers. Public pages render through
// the shared `x-capell::layout` + layout-builder container pipeline
// instead of this package's own page shell, so
// ThemeRegistry::has(self::THEME_KEY) is false from here on.
$registry->register(definition: self::definition());
}
private function registerVendorCssAssets(): void
{
CapellCore::registerVendorAsset(
new VendorAssetData(
type: VendorAssetEnum::TailwindImport,
value: self::CSS_SOURCE,
packageName: self::$packageName,
condition: self::CSS_CONDITION,
),
);
CapellCore::registerVendorAsset(
VendorAssetData::tailwindSource('resources/views/**/*.blade.php', self::$packageName),
);
}
/**
* Registers this theme's layout-builder areas: `header` and `footer`,
* via `RegistersLayoutNativeThemeDefaults::registerStandardLayoutAreas()`,
* which mirrors `FoundationThemeServiceProvider::registerLayoutAreas()`
* exactly (global scope — omitting `$themeKey` — since these are the
* same two areas every theme shares, not a Liquid-Glass-only region).
*
* These areas are rendered by this package's own
* `resources/views/header/index.blade.php` and
* `resources/views/footer.blade.php`, wired in as the active `Theme`
* row's `meta.header_file` / `meta.footer_file` (see
* `x-capell::layout.index`'s `<x-dynamic-component>` fallback — the
* real, already-built per-theme chrome override seam, not a Blade
* view-chain override of the `capell::header.index` / `capell::footer.index`
* component tags, which are registered as *class-aliased* components
* (`Blade::component(...)`) and therefore cannot be overridden by
* placing a same-named view earlier in a namespace's view-chain: Laravel's
* `ComponentTagCompiler::componentClass()` resolves a registered class
* alias unconditionally, before any anonymous-view/namespace guessing
* ever runs).
*
* `meta.header_file` / `meta.footer_file` are set by
* {@see LiquidGlassThemeInterceptor} whenever a `liquid-glass`-keyed
* `Theme` row is created (see {@see registerModelInterceptors()}), not
* here — this method only makes the `header` / `footer` areas
* selectable by LayoutAreaRegistry so an admin can place widgets (e.g. a
* navigation widget) into them, exactly like Foundation's own
* header/footer areas.
*
* NOTE on scope (deliberately deferred, not overlooked): the `hero`,
* `features`, `proof`, and `content-listing` sections are NOT given
* bespoke Liquid Glass treatment in this pilot. Those four map to
* *shared* foundation widget views (`capell.widget.hero`,
* `capell.widget.asset.features`, `capell.widget.asset.testimonials`,
* `capell.widget.page.latest`) resolved through the single, global,
* theme-unaware `Capell\LayoutBuilder\Models\Widget::getComponent()` ->
* `RenderableRegistry` lookup — there is no per-theme scoping anywhere in
* that resolution path today. Re-registering those same keys here would
* silently change hero/features/testimonials/latest-pages rendering for
* every other currently-active theme, not just Liquid Glass; inventing a
* new theme-scoped override seam inside `Widget::getComponent()` /
* `RenderableRegistry` is a real, separate, cross-cutting design decision
* that needs its own review, not something to bolt on inside a single
* theme's pilot conversion. Liquid Glass intentionally uses Foundation's
* shared views verbatim for these four sections for now. Raise per-theme
* widget-view override support explicitly before the next themes in this
* program need bespoke hero/feature/proof/listing treatment of their own.
*/
private function registerLayoutAreas(): void
{
$this->registerStandardLayoutAreas();
}
/**
* Registers Liquid Glass's own bespoke layout-builder widget component
* keys (`capell.widget.liquid-glass.{cta,showcase,presets,glass-feature-card,
* translucent-stat-band,layered-depth-hero,refraction-grid,floating-glass-nav}`)
* against the shared `RenderableRegistry`, mirroring the established
* pattern `Capell\Blog\Providers\BlogServiceProvider::registerWidgetRenderables()`
* and `Capell\LayoutBuilder\Support\LayoutBuilderCoreRegistrar` already
* use for their own widget component enums. The last five keys are Wave
* 4c's (§D "glassmorphism showcase") signature widgets, added on top of
* the original three.
*
* These keys are new and owned solely by Liquid Glass — unlike the
* shared `capell.widget.hero` / `asset.features` / `asset.testimonials` /
* `page.latest` keys documented in {@see registerLayoutAreas()}'s
* "NOTE on scope", registering brand-new keys here is additive and
* cannot collide with or change any other theme's rendering.
*
* Defensive registration, NOT graceful degradation at render time: each
* blade target is only registered if `view()->exists()` for it,
* mirroring the same defensive check
* `Capell\ContentSections\Support\SectionPublicLayoutWidgetPayloadContributor::renderSection()`
* already uses before trusting a dynamically-resolved component view.
* This only prevents registering a *dangling* renderable (one whose
* blade view does not exist) during this package's own boot.
*
* It does NOT protect a stale `Widget` row that still references one of
* these keys after this package's views are removed (e.g. mid-uninstall,
* or after a downgrade). That row's `Widget::getComponent()` call goes
* through `Capell\Core\Actions\Renderables\ResolveRenderableComponentAction`
* to `RenderableRegistry::get()`, which throws `InvalidArgumentException`
* naming the missing key when nothing was ever registered for it.
* `Capell\LayoutBuilder`'s `container.blade.php` has no catch for this —
* its `if (! $component) continue;` null-skip is unreachable via this
* path, since `getComponent()` never returns null on a miss; it throws
* first. In practice a stale bespoke-widget key therefore causes a 500 on
* the public page, not a silent skip. Changing that shared
* throw-vs-catch-and-skip behaviour in `RenderableRegistry` /
* `container.blade.php` is a separate, cross-cutting layout-builder
* decision affecting every widget type, not just this theme's three
* bespoke ones — out of scope here.
*/
private function registerBespokeWidgetRenderables(): void
{
$registry = resolve(RenderableRegistry::class);
$blade = [
WidgetComponentEnum::Cta->value => 'capell-theme-liquid-glass::widget.cta',
WidgetComponentEnum::Showcase->value => 'capell-theme-liquid-glass::widget.showcase',
WidgetComponentEnum::Presets->value => 'capell-theme-liquid-glass::widget.presets',
WidgetComponentEnum::GlassFeatureCard->value => 'capell-theme-liquid-glass::widget.glass-feature-card',
WidgetComponentEnum::TranslucentStatBand->value => 'capell-theme-liquid-glass::widget.translucent-stat-band',
WidgetComponentEnum::LayeredDepthHero->value => 'capell-theme-liquid-glass::widget.layered-depth-hero',
WidgetComponentEnum::RefractionGrid->value => 'capell-theme-liquid-glass::widget.refraction-grid',
WidgetComponentEnum::FloatingGlassNav->value => 'capell-theme-liquid-glass::widget.floating-glass-nav',
];
foreach (WidgetComponentEnum::cases() as $widgetComponent) {
$bladeView = $blade[$widgetComponent->value];
if (! view()->exists($bladeView)) {
continue;
}
$registry->register(new RenderableDefinitionData(
key: $widgetComponent->value,
type: 'layout-widget',
blade: $bladeView,
));
}
}
/**
* Registers {@see LiquidGlassThemeInterceptor}, scoped to
* `self::THEME_KEY` so it only fires for a Theme row keyed
* `liquid-glass` — see that class's docblock for why this is scoped
* (unlike `FoundationThemeInterceptor`, which is unscoped) and for the
* `header_file` / `footer_file` defaults it sets.
*/
private function registerModelInterceptors(): void
{
CapellCore::registerModelInterceptor(Theme::class, interceptorClass: LiquidGlassThemeInterceptor::class, key: self::THEME_KEY);
}
}