-
Notifications
You must be signed in to change notification settings - Fork 388
Expand file tree
/
Copy pathWBootstrap5Theme.h
More file actions
88 lines (78 loc) · 3.29 KB
/
WBootstrap5Theme.h
File metadata and controls
88 lines (78 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2020 Emweb bv, Herent, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WT_WBOOTSTRAP5_THEME_H
#define WT_WBOOTSTRAP5_THEME_H
#include <Wt/WTheme.h>
namespace Wt {
/*! \class WBootstrap5Theme Wt/WBootstrap5Theme.h Wt/WBootstrap5Theme.h
* \brief Theme based on the Bootstrap 5 CSS framework.
*
* This theme implements support for building a %Wt web application
* that uses Bootstrap 5 as a theme for its (layout and) styling.
*
* Using this theme, various widgets provided by the library are
* rendered using markup that is compatible with Bootstrap 5.
* The bootstrap theme is also extended with a proper
* (compatible) styling of widgets for which bootstrap does not
* provide styling (table views, tree views, sliders, etc...).
*
* By default, the theme will use CSS and JavaScript resources that are shipped
* together with the %Wt distribution, but you can replace the CSS with
* custom-built CSS by reimplementing styleSheets().
*
* Although this theme styles individual widgets correctly, for your web application's
* layout you are recommended to use WTemplate in conjunction with Bootstrap's CSS classes.
* For this we refer to Bootstrap's documentation at https://getbootstrap.com.
*
* ## Customizing the theme
*
* Custom Sass files can be used to make your own derived theme.
*
* \sa https://getbootstrap.com/docs/5.2/customize/sass/
*
* If %Wt is installed into `PREFIX` (and the CMake option `INSTALL_THEMES` is set to `ON`), then you can find the
* source files in `PREFIX/share/Wt/themes/bootstrap/5`.
*
* Apart from the variables that Bootstrap defines, %Wt also provides
* variables, defined in `wt/_variables.scss`. All of %Wt's variables
* start with a `wt-` prefix.
*
* Refer to the example in `examples/custom-bs-theme` for more information.
*
* \sa WApplication::setTheme()
*/
class WT_API WBootstrap5Theme : public WTheme {
public:
/*! \brief Constructor.
*/
WBootstrap5Theme();
~WBootstrap5Theme() override;
void init(WApplication *app) const override;
std::string name() const override;
std::string resourcesUrl() const override;
std::vector<WLinkedCssStyleSheet> styleSheets() const override;
void apply(WWidget *widget, DomElement &element, int elementRole) const override;
std::string disabledClass() const override;
std::string activeClass() const override;
std::string utilityCssClass(int utilityCssClassRole) const override;
bool canStyleAnchorAsButton() const override;
void loadValidationStyling(WApplication* app) const override;
void applyValidationStyle(WWidget *widget,
const Wt::WValidator::Result &validation,
WFlags<ValidationStyleFlag> flags) const override;
bool canBorderBoxElement(const DomElement &element) const override;
Side panelCollapseIconSide() const override;
protected:
void applyFunctionalStyling(WWidget *widget, WWidget *child, int widgetRole) const override;
void applyOptionalStyling(WWidget *widget, WWidget *child, int widgetRole) const override;
private:
static std::string classBtn(const WWidget *widget);
static bool hasButtonStyleClass(const WWidget *widget);
static bool hasNavbarExpandClass(const WNavigationBar *widget);
};
}
#endif // WT_WBOOTSTRAP5_THEME_H