Project

General

Profile

Improvements #9115

Set the version in WBootstrapTheme C'tor

Added by Rathnadhar K V 19 days ago. Updated 6 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
09/28/2021
Due date:
% Done:

0%

Estimated time:
1.50 h

Description

Namaskara,

Currently I create a BootstrapTheme object and then set the them version as follows:

auto btheme_ptr = std::make_shared<Wt::WBootstrapTheme>();
btheme_ptr->setVersion (Wt::BootstrapVersion::V3);

this->setTheme(btheme_ptr);

can we make it more robust as :

this->setTheme(WT::BootstrapTheme,Wt::BootstrapVersion::V3,path_to_bootstrap_theme_css_dir);

further

this->setTheme(WT::WtTheme,Wt::WT3,path_to_wt_css_dir);

If I have to add my own theme then...

this->setTheme(WT::Other,Wt::Other,path_to_other_css_dir);

that way I can have clean interface to set the theme for the page/widget.

Its preferable to set the pass to css directory...so that we have the flexibility to define our own themes in self contained directory.

Regards
Rathnadhar K V

#1

Updated by Roel Standaert 19 days ago

  • Target version set to future

We were actually refactoring the Bootstrap theme to be split up in multiple classes, so WBootstrap2Theme, WBootstrap3Theme, WBootstrap4Theme, and WBootstrap5Theme, since they end up being dissimilar enough to warrant their own class.

The theme directory may be something we can take into consideration.

#2

Updated by Rathnadhar K V 6 days ago

Namaskara Roel,

That is wonderful.

May I suggest an improvement,

Have a common glue CSS class....WThemeContainer()....(name just a example, you can call it whatever you deem fit).

Now to this WThemeContainer class I add backend (s) ....WBootstrap2Theme ...WBootstrap5Theme....

Say I can add max of 8 backends.

int index = WThemeContainer(WBootStrap5Theme,responsive=true,path=path_to_css_file);

index 0 is fixed for Wt.css (fall back option) in case other css are not added.

Now WTheme class will have virtual member functions that is implemented by other CSS classes....

that way I can add any bootstrap similar theme easily ....

so in the application, only WThemeContainer is visible and based on index I get the css classes...

That way my WApplication is decoupled from back end theme....and I can easily add other frameworks' themes.

Regards
Rathnadhar KV

#3

Updated by Rathnadhar K V 6 days ago

Instead of index as int, you can even get a iterator to the theme within the container.

Also available in: Atom PDF