Skip to content
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

Pull together all Flask-Admin theme configuration #2462

Merged

Conversation

samuelhwilliams
Copy link
Contributor

fix: #2423

@princerb
Copy link
Contributor

Will you plan to expect the new theming frameworks? Not just Bootstrap. Like adding Tailwind, Materialize etc?

@samuelhwilliams
Copy link
Contributor Author

I don't necessarily expect them - but this would support them fairly easily and allow end users to provide whatever configuration they want for their template mode by subclassing TemplateMode with additional attributes.

@princerb
Copy link
Contributor

Would it be better if we create a seperate module for their understanding then? The usage would look like this:

from flask_admin.theming import Bootstrap5Theme, TailwindTheme

admin = Admin(..., theme=TailwindTheme(**parameters))

@samuelhwilliams
Copy link
Contributor Author

Yes, that feels like a good shout 👌

@samuelhwilliams samuelhwilliams changed the title WIP: example template mode configuration Pull together all Flask-Admin theme configuration Jul 19, 2024
@samuelhwilliams samuelhwilliams marked this pull request as ready for review July 19, 2024 17:55
@hasansezertasan
Copy link
Member

hasansezertasan commented Jul 19, 2024

I like how the things are going 🤓. I might have few ideas about this:

First of all, I think the base class should not have a swatch attribute because future implementations (etc. Tabler #2444 or Tailwind) might not have that option.

I will get back with more if/when I get chance to review 🧐.

Great ideas 🚀.

Also, this should be definetely in v2.

@samuelhwilliams
Copy link
Contributor Author

samuelhwilliams commented Jul 19, 2024

The base class doesn't have a swatch attribute - just a folder 🙂

Tablet, Tailwind etc should inherit from the base 'Theme'

@hasansezertasan
Copy link
Member

The base class doesn't have a swatch attribute - just a folder 🙂

Oh sorry, I was mistaken. I had my phone while looking at the change you made and ı probably didn't notice it 😅.

Tablet, Tailwind etc should inherit from the base 'Theme'

You are right 🧐.

Currently, Flask-Admin themes can be changed through a combination of
configuration modes:

* Through Admin() arguments; Admin(template_mode='bootstrap2')
* Through environment variables, eg FLASK_ADMIN_SWATCH='cerulean'.

These two modes work together to decide the UI framework/version used,
and then the colour/styling applied within that framework.

This patch switches us over to a single `theme` configuration object
passed to the Admin instance.

This brings all of the configuration for a specific visual style into
one place, and also means that now separate Admin() instances can
contain all of their styling information in an isolated way.

This should also make it easier for end users to provide their own Admin
theme, as the theme is also exposed to all of the `render_template`
calls under a `theme` variable.
@samuelhwilliams
Copy link
Contributor Author

samuelhwilliams commented Jul 20, 2024

Do we think base_template should also be part of the theme? I feel like ... probably yes 🤔

Like this maybe: 09445e4

@samuelhwilliams samuelhwilliams merged commit c4f74a2 into pallets-eco:master Jul 20, 2024
8 checks passed
@samuelhwilliams samuelhwilliams deleted the template-mode-configuration branch July 22, 2024 08:56
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

Can't use multiple Admin instances with different Bootstrap themes (FLASK_ADMIN_SWATCH)
3 participants