Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.16k stars 893 forks source link

[Bug] Сonfig file "ui.php" doesn't add style files #5406

Closed smart4you closed 9 months ago

smart4you commented 10 months ago

Bug report

What I did

In the config file "config/backpack/ui.php" in the block "styles => []" I add 'css/style.css'

What I expected to happen

I expect the code @if (backpack_theme_config('styles') && count(backpack_theme_config('styles'))) @foreach (backpack_theme_config('styles') as $path) @if(is_array($path)) @basset(...$path) @else @basset($path) @endif @endforeach @endif in file "ui/inc/styles.blade.php" to add my file through the helper "basset"

What happened

The helper "backpack_theme_config" will add the files that are specified in the config file "config/backpack/theme-tabler.php" in the block "'styles' => []" and will ignore config file "config/backpack/ui.php 'styles' => []"

What I've already tried to fix it

Nothing, I can add the path to the style file in another config file, but I expect all configurations to be merged together

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 8.1.23 (cli) (built: Sep 1 2023 17:27:48) (NTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.1.23, Copyright (c) Zend Technologies with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans

LARAVEL VERSION:

10.37.3.0

BACKPACK PACKAGE VERSIONS:

backpack/backupmanager: v5.0.0 backpack/basset: 1.2.2 backpack/crud: 6.4.2 backpack/generators: v4.0.2 backpack/language-switcher: 1.0.1 backpack/logmanager: v5.0.1 backpack/medialibrary-uploaders: 1.0.3 backpack/permissionmanager: 7.1.1 backpack/pro: 2.0.20 backpack/settings: 3.1.0 backpack/theme-tabler: 1.1.2

pxpm commented 9 months ago

Hello @smart4you sorry I totally missed this issue.

I think that's the expected result. Any key from the ui.php config file that a theme-xxx.php config overwrites, the theme config takes precedence. And the configs are not merged because we want to guarantee that the theme has the full control of the styles/scripts/any key it overwrites from backpack. Otherwise how would a theme developer create a theme without the ui.php styles ? Or when the styles in ui.php break the theme styles ? If we merge the configs the "theme developer" would need to tell their users to "remove xxx.css from ui.php because it breaks the theme". And then the "backpack developer" has a second theme that needs xxx.css from ui.

It would become messy in no time, that's the reason why this kind of configs are not merged. If you are using a theme you should add your custom styles along with the theme ones in config/vendor/backpack/theme-xxx.php

Have a look a the docs, and let me know if you still have any questions. https://backpackforlaravel.com/docs/6.x/base-themes#theme-configs-1

Cheers

smart4you commented 9 months ago

Thanks for the explanation, it seems like time has passed since adding themes, but I still can’t adapt to this innovation and understand its concept.

pxpm commented 9 months ago

It was the first themes interaction. We already have some ideas to ease out the process and make it less confuse.

Any doubt you have please post the question, if you see it's taking time to answer (it shouldn't, but sometimes happen) please ping @pxpm again.

Thanks for your patience 🙏