-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to load different Admin LTE skins #6378
Conversation
Seems nice ! You just need to fix the lint build. I'm currently using in my project two different skins:
Any idea about how we could improve the config option you created to do this ? |
Thank you. Instead of overwriting the Still custom but then you do not need to overwrite the template. |
How would you do this ? |
skins:
skin-black: [ priority: 1, roles: ['ROLE_USER']]
skin-blue: null
skin-yellow: [ priority: 10, roles: ['ROLE_PREMIUM']] |
@@ -113,7 +115,7 @@ file that was distributed with this source code. | |||
</head> | |||
<body | |||
{% block body_attributes -%} | |||
class="sonata-bc skin-black fixed | |||
class="sonata-bc {{ _skin }} fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class="sonata-bc {{ _skin }} fixed | |
class="sonata-bc {% block adminlte_2_skin_class %}skin-black{% endblock %} fixed |
Only this change is require to add this PR feature. We shouldn't add skin
option becouse we working on add support for other templates.
@fastnloud WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the css are not loaded by default, that's why the option is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not problem. People can add css by sonata_admin.assets.extra_stylesheets
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we already have the code to remove stylesheets and add new ones built in. So adding a block seems the best option to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some doc should be added then.
How to use another LTE skin:
- Remove black stylesheet
- Add you favorite stylesheet
- Override the layout file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wbloszyk that'd be another option. The thing is, that'd you'd still need to override a template block and you'd need to remove and add the template(s) manually. The option I introduced will do that automatically based on the available Admin LTE skins.
I think introducing this block is still a good idea but then I'd name it differently (e.g. sonata_body_class
).
@VincentLanglet I think in your case a block like this would be very helpful so you're able to switch skins more easily based on the user role.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fastnloud
Lets create "sonata.admin.template.skin_selector" or something simmilar. Then skin can be return by people preference(time, roles ...), can be validate by used template(AdminLTE2, AdminLTE3, custom)... Then new option like templete_skin_service
can be add. skin
option is not related to AdminBundle but to AdminLTE2.
Update
I mean service + interface to allow write people own service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO that would bind php to css and would be bad for when we want to integrate webpack. There is a way currently in the code to replace javascript or css, and we should use that, the only need is to be able to override the main class, which is easy to do in twig with a simple block, no need to introduce complex logics
@wbloszyk I'm not sure to understand. |
I only explain how it can be done. IMO we shouldn't do in in option. Some service like |
👍 Add simply block 👎 Add service "sonata.admin.template.skin_selector" For both solution documentation about how to use skin should be add. @sonata-project/contributors Lets vote |
Im for 👍. |
@@ -113,7 +115,7 @@ file that was distributed with this source code. | |||
</head> | |||
<body | |||
{% block body_attributes -%} | |||
class="sonata-bc skin-black fixed | |||
class="sonata-bc {{ _skin }} fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class="sonata-bc {{ _skin }} fixed | |
class="sonata-bc {% block admin_lte_skin_class %}{{ _skin }}{% endblock %} fixed |
I'm not against a skin option for simple usage, and a skin block to easily override the template when there is more complex needs (like a role dependant skin).
when we switch to webpack encore with admin LTE 3 things wil work different anyway because then you could override the sass variables and create your own skin. But I also think we should improve Sonata 3.x and it's usability to switch skins. An skin option like this is the most easy way to consume and would be great for the time being until we reach sonata 4.x. We have settings for using select2, confirms etc. so it would be strange in my opnion to not have a skin setting and let the user remove / add stylesheets themselves. |
I've added an additional Twig block that allows you to add more complex logic. Is this something you can work with @VincentLanglet? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please kindly squash your commits together. If you don't, we'll try to remember to do it for you but it's best if you save us this trouble.
How to do that?
git rebase -i origin/3.x
, assumingorigin
is a git remote that points to this repository, and not your fork. If you're not sure what your remotes are, rungit remote -vvv
, there should be your fork and the holy/reference/base/origin/whatever-you-call-it repository.- A window will show up with many lines, replace
pick
withfixup
on every line but the first one - Close your editor, git should do its magic, and you should end up with one commit
- Use
git push --force
to overwrite what you already push. Don't forget the--force
option otherwise git will try to merge both things together.
@@ -134,6 +134,26 @@ public function getConfigTreeBuilder() | |||
->booleanNode('sort_admins')->defaultFalse()->info('Auto order groups and admins by label or id')->end() | |||
->booleanNode('confirm_exit')->defaultTrue()->end() | |||
->booleanNode('js_debug')->defaultFalse()->end() | |||
->scalarNode('skin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using enumNode, so there is no need of manual validation.
bfa1c3a
Thanks @fastnloud |
Added option to load different Admin LTE skins
Added the option
skin
to load different Admin LTE skins, making thebody
class configurable and thus allowing you to change the skin without the need to overriding thebody_attributes
block.I am targeting this branch, because this option is currently missing.
Closes #6368.
Changelog