style updates
This commit is contained in:
@@ -13,10 +13,13 @@ final class Stylist
|
||||
public function current(): Theme
|
||||
{
|
||||
$requested = $this->resolver->resolve();
|
||||
try { return $this->loader->find($requested); }
|
||||
catch (ThemeNotFoundException) {
|
||||
try {
|
||||
return $this->loader->find($requested);
|
||||
} catch (ThemeNotFoundException) {
|
||||
$fallback = (string) config('stylist.default_theme', 'default');
|
||||
if ($requested !== $fallback) return $this->loader->find($fallback);
|
||||
if ($requested !== $fallback) {
|
||||
return $this->loader->find($fallback);
|
||||
}
|
||||
throw ThemeNotFoundException::forKey($requested);
|
||||
}
|
||||
}
|
||||
@@ -44,21 +47,45 @@ final class Stylist
|
||||
);
|
||||
}
|
||||
|
||||
public function settings(): array { return $this->settings->get($this->current()); }
|
||||
public function variant(): string { return $this->settings->variant($this->current()); }
|
||||
public function appearance(): string { return $this->settings->appearance($this->current()); }
|
||||
public function accent(): string { return $this->settings->accent($this->current()); }
|
||||
public function all() { return $this->loader->all(); }
|
||||
public function settings(): array
|
||||
{
|
||||
return $this->settings->get($this->current());
|
||||
}
|
||||
|
||||
public function variant(): string
|
||||
{
|
||||
return $this->settings->variant($this->current());
|
||||
}
|
||||
|
||||
public function appearance(): string
|
||||
{
|
||||
return $this->settings->appearance($this->current());
|
||||
}
|
||||
|
||||
public function accent(): string
|
||||
{
|
||||
return $this->settings->accent($this->current());
|
||||
}
|
||||
|
||||
public function all()
|
||||
{
|
||||
return $this->loader->all();
|
||||
}
|
||||
|
||||
private function inheritedVariables(Theme $theme, array $seen = []): array
|
||||
{
|
||||
if (in_array($theme->key(), $seen, true)) return [];
|
||||
if (in_array($theme->key(), $seen, true)) {
|
||||
return [];
|
||||
}
|
||||
$seen[] = $theme->key();
|
||||
$parent = [];
|
||||
if ($theme->parent()) {
|
||||
try { $parent = $this->inheritedVariables($this->loader->find($theme->parent()), $seen); }
|
||||
catch (ThemeNotFoundException) {}
|
||||
try {
|
||||
$parent = $this->inheritedVariables($this->loader->find($theme->parent()), $seen);
|
||||
} catch (ThemeNotFoundException) {
|
||||
}
|
||||
}
|
||||
|
||||
return array_replace($parent, $theme->variables());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user