Hasnayeen / themes

Themes for Filament panels.
MIT License
235 stars 31 forks source link

[Bug]: Install package bugs #3

Closed Thiktak closed 1 year ago

Thiktak commented 1 year ago

What happened?

Hello,

I have a serie of bug when installing this package on an existing installation. Run upgrade/update, in order to use he last version if Laravel, filament & your package.

pages/themes.blade.php

@if ($this->getCurrentTheme() instanceof \Hasnayeen\Themes\Contracts\HasChangeableColor)

GetCurrentTheme() is a class, but getCurrentTheme return a string (getName)

    public function getCurrentTheme()
    {
        return app(\Hasnayeen\Themes\Themes::class)->getCurrentTheme(); //->getName();
    }

Themes.php

For the function getCurrentThemeColor(), I had to modify like this:

        if (Arr::has($this->getCurrentTheme()->getThemeColor(), $color)) {
            return ['primary' => Arr::get($this->getCurrentTheme()->getThemeColor(), $color)];
        } else {
            return $this->getCurrentTheme()->getPrimaryColor();
        }

The ['primary' => null] always exists. And Arr::get(Array, null) return the full array. Need to check existence with has (or use collect()->get(null, default)).

Sunset Theme

Here I removed the Color:rgb in order to avoid Filament\Support\Colors\Color::rgb(): Argument #1 ($color) must be of type string, array given. Maybe DefaultTheme too ?

    public function getPrimaryColor(): array
    {
        return ['primary' => $this->getThemeColor()['blue']];
    }

How to reproduce the bug

Follow installation notes. Go to Themes, and play with options

Package Version

v3.0.8

PHP Version

8.2.4

Laravel Version

v3.0.39

Which operating systems does with happen with?

Windows

Notes

(Thank you for this great package :) )

Hasnayeen commented 1 year ago

@Thiktak thanks for reporting the bug and hints, a fix has been deployed. If it's not fixed please reopen the issue. Thank you.