Skip to content

Commit 122b233

Browse files
authored
Merge pull request plone#1516 from plone/classic-ui-theming-barceloneta
Barceloneta based Classic UI theme
2 parents 0e850d6 + 63b3660 commit 122b233

File tree

1 file changed

+312
-32
lines changed

1 file changed

+312
-32
lines changed

docs/classic-ui/theming/barceloneta.md

Lines changed: 312 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,59 +11,339 @@ myst:
1111

1212
# Classic UI theming based on Barceloneta
1313

14-
```{todo}
15-
This page is only an outline and needs a lot of work.
16-
See https://github.com/plone/documentation/issues/1286
17-
```
14+
This chapter describes how to create a custom theme for Plone Classic UI based on Barceloneta.
15+
Barceloneta is the default enabled theme for Plone Classic UI.
16+
17+
18+
(classic-ui-theming-barceloneta-pre-requisites-label)=
19+
20+
## Pre-requisites
21+
22+
To create an add-on package with a Plone Classic UI theme, you need to install the following pre-requisites.
23+
24+
- [Node.js (16/18)](https://nodejs.org/en)
25+
- [Python (>=3.8)](https://www.python.org/)
26+
- [plonecli](https://pypi.org/project/plonecli/)
1827

19-
- Use of SCSS
20-
- Colors, fonts, and sizes via variables is changeable
21-
- Properties for shadows, rounded corners, gradients.
22-
- `plonetheme.barceloneta` npm package for includes
23-
- `bobtemplates.plone` template
24-
- Theming is based on Twitter Bootstrap 5
25-
- We use Bootstrap markup in templates
26-
- We use Bootstrap components wherever possible
27-
- Most of the look and feel can be changed via Bootstrap's variables
28-
- Hint: order is important in SCSS
28+
Read more about how to install pre-requisites in {doc}`/install/install-from-packages`.
2929

3030

31-
(classic-ui-theming-barceloneta-theme-package-label)=
31+
(classic-ui-theming-barceloneta-create-a-classic-ui-theme-add-on-package-label)=
32+
33+
## Create a Classic UI theme add-on package
34+
35+
To create a Classic UI theme add-on, begin with the following command.
36+
37+
```shell
38+
plonecli create addon plonetheme.themebasedonbarceloneta
39+
```
40+
41+
Then change the working directory into the package you just created, and add the basic theme structure with the following commands.
3242

33-
## Theme package
43+
```shell
44+
cd plonetheme.themebasedonbarceloneta
45+
plonecli add theme_barceloneta
46+
```
3447

35-
- Generated theme package can be uploaded as a .zip file.
48+
Give your theme a name, and optionally commit the changes.
49+
After that, the theming structure is set up and ready for customization.
50+
You can create a Plone Site and install your theme add-on in the controlpanel.
3651

3752

3853
(classic-ui-theming-barceloneta-theme-structure-label)=
3954

4055
## Theme structure
4156

42-
### `base.scss`
57+
All the theming relevant files are now located inside `src/plonetheme/themebasedonbarceloneta/theme/`:
58+
59+
```text
60+
./src/plonetheme/themebasedonbarceloneta/theme/
61+
├── barceloneta-apple-touch-icon-114x114-precomposed.png
62+
├── barceloneta-apple-touch-icon-144x144-precomposed.png
63+
├── barceloneta-apple-touch-icon-57x57-precomposed.png
64+
├── barceloneta-apple-touch-icon-72x72-precomposed.png
65+
├── barceloneta-apple-touch-icon-precomposed.png
66+
├── barceloneta-apple-touch-icon.png
67+
├── barceloneta-favicon.ico
68+
├── index.html
69+
├── manifest.cfg
70+
├── package.json
71+
├── preview.png
72+
├── rules.xml
73+
├── scss
74+
│ ├── _custom.scss
75+
│ ├── _maps.scss
76+
│ ├── _variables.scss
77+
│ └── theme.scss
78+
├── styles
79+
│ ├── theme.css
80+
│ └── theme.min.css
81+
└── tinymce-templates
82+
├── README.rst
83+
├── card-group.html
84+
└── list.html
85+
```
86+
87+
`index.html`
88+
: Basic HTML structure for the site layout.
89+
90+
`manifest.cfg`
91+
: Basic theme configuration for the backend.
92+
93+
`package.json`
94+
: npm package configuration which defines all requirements for theming with barceloneta.
95+
96+
`rules.xml`
97+
: Diazo rules which translate the `index.html` and fills it with content from the backend.
98+
99+
`scss/_custom.scss`
100+
: Custom SCSS rules for your theme.
101+
102+
`scss/_maps.scss`
103+
: Override Bootstrap mapping variables here.
104+
105+
`scss/_variables.scss`
106+
: Override Bootstrap and/or Barceloneta variables here.
107+
108+
`scss/theme.scss`
109+
: Base theme file which follows "Option B" of customizing Bootstrap imports to enable custom variable and map injections.
110+
Note that the order of these imports is mandatory to ensure overriding the defaults.
111+
See https://getbootstrap.com/docs/5.3/customize/sass/#importing.
112+
113+
`styles/theme.css[.min]`
114+
: Compiled CSS styles.
115+
116+
`tinymce-templates/*.html`
117+
: HTML snippets for the TinyMCE `template` plugin.
118+
119+
120+
(classic-ui-theming-barceloneta-compiling-theme-resources-label)=
121+
122+
## Compiling theme resources
123+
124+
To compile the SCSS code, you have to install the required dependencies with `npm`.
125+
Then run the package script `build` inside the `theme/` folder:
126+
127+
```shell
128+
npm install
129+
npm run build
130+
```
131+
132+
During theme development, you can run:
133+
134+
```shell
135+
npm run watch
136+
```
137+
138+
This compiles the SCSS resources on the fly when you change something inside the `scss/` folder.
139+
You can preview your changes when you reload your browser.
140+
141+
142+
(classic-ui-theming-barceloneta-customize-components-label)=
143+
144+
## Customize Bootstrap and Barceloneta components
145+
146+
The base `scss/theme.scss` file provides all imports of the dependent Bootstrap and Barceloneta resources to build the default Classic UI theme.
147+
As a convenience `bobtemplates.plone` has created three files to customize variables, maps, and custom SCSS code.
148+
149+
```text
150+
scss/_custom.scss
151+
scss/_maps.scss
152+
scss/_variables.scss
153+
```
154+
155+
156+
(classic-ui-theming-barceloneta-scss-and-root-variables-label)=
157+
158+
### SCSS and root variables
159+
160+
To set a custom font, you define the font variables in `scss/_variables.scss`:
161+
162+
```scss
163+
$font-family-sans-serif: Tahoma, Calimati, Geneva, sans-serif;
164+
$font-family-serif: Georgia, Norasi, serif;
165+
```
166+
167+
This will override the default values from Barceloneta.
168+
169+
170+
### SCSS and properties
171+
172+
The following example shows how to disable rounded corners for borders.
173+
174+
```scss
175+
$enabled-rounded: false;
176+
```
177+
178+
A complete list of all properties see {ref}`classic-ui-theming-barceloneta-default-variables-and-properties-label`.
179+
180+
181+
(classic-ui-theming-barceloneta-maps-label)=
182+
183+
### Maps
184+
185+
Maps are key/value pairs to make CSS generation easier.
186+
As an example, the following example shows the workflow colors map:
187+
188+
```scss
189+
$state-colors: (
190+
"draft": $state-draft-color,
191+
"pending": $state-pending-color,
192+
"private": $state-private-color,
193+
"internal": $state-internal-color,
194+
"internally-published": $state-internally-published-color,
195+
) !default;
196+
```
197+
198+
If you have a custom workflow state, you can add your state color to the default map in `scss/_maps.scss` as shown below.
199+
200+
```scss
201+
$custom-state-colors: (
202+
"my-custom-state-id": "#ff0000"
203+
);
204+
205+
// Merge the maps
206+
$state-colors: map-merge($state-colors, $custom-colors);
207+
```
208+
209+
(classic-ui-theming-barceloneta-custom-css-code-label)=
210+
211+
### Custom CSS code
212+
213+
Inside the file `theme/_custom.scss` you can write all your custom CSS/Sass code to adapt the theme to your needs.
214+
Feel free to add more files inside the `scss/` folder to make your code more readable.
215+
Don't forget to import your custom files in `scss/theme.scss`.
43216

44-
- Basics required for backend
45217

46-
### `barceloneta.scss`
218+
(classic-ui-theming-barceloneta-default-variables-and-properties-label)=
47219

48-
- Barceloneta theme basics
220+
## Default variables and properties
49221

222+
The following variables and properties are defined in Bootstrap and customized by Barceloneta.
50223

51-
## npm package
224+
### Component variables
52225

53-
- npm package with files required for Plone
54-
- dependencies required by theme to compile
226+
```scss
227+
// Barceloneta settings
55228

229+
$primary: $plone-link-color!default;
230+
$light: $plone-light-color!default;
231+
$dark: $plone-dark-color!default;
56232

57-
## Bootstrap components
233+
$spacer: 1rem!default; // not changed but needed to calc other definitions
58234

59-
- Default components are extended with some custom components, such as a select or dropdown menu.
60-
- We use Boostrap variables in these cases.
61235

236+
// Grid columns
237+
// Set the number of columns and specify the width of the gutters.
62238

63-
## Add-ons and templates
239+
// $grid-columns: 12 !default;
240+
// $grid-gutter-width: 1.5rem !default;
241+
// $grid-row-columns: 6 !default;
64242

65-
Make life easy with...
243+
$grid-main-breakpoint: lg!default;
244+
$nav-main-breakpoint: $grid-main-breakpoint!default;
66245

67-
- use Bootstrap markup
68-
- use Bootstrap components
69-
- use Bootstrap variables
246+
$navbar-barceloneta-background: $primary!default;
247+
248+
$navbar-padding-y: 0 !default;
249+
$navbar-padding-x: 0 !default;
250+
$navbar-nav-link-padding-y: $spacer * .75 !default;
251+
$navbar-nav-link-padding-x: $spacer !default;
252+
253+
$navbar-light-color: rgba($black, .55) !default;
254+
$navbar-light-active-color: rgba($black, .7) !default;
255+
$navbar-light-active-background: rgba($black, .2) !default;
256+
$navbar-light-hover-color: rgba($black, .9) !default;
257+
$navbar-light-hover-background: rgba($black, .3) !default;
258+
259+
$navbar-dark-color: rgba($white, 1) !default;
260+
$navbar-dark-active-color: rgba($white, 1) !default;
261+
$navbar-dark-active-background: rgba($white, .2) !default;
262+
$navbar-dark-hover-color: rgba($white, 1) !default;
263+
$navbar-dark-hover-background: rgba($white, .3) !default;
264+
265+
$navbar-barceloneta-color: rgba($white, 1) !default;
266+
$navbar-barceloneta-active-color: rgba($white, 1) !default;
267+
$navbar-barceloneta-active-background: rgba($black, .2) !default;
268+
$navbar-barceloneta-hover-color: rgba($white, 1) !default;
269+
$navbar-barceloneta-hover-background: rgba($black, .3) !default;
270+
271+
272+
$plone-portlet-navtree-maxlevel: 5!default;
273+
274+
275+
// Typography
276+
// While Plone Logo uses the DIN Font, we use Roboto, which was designed for Android and so mobile optimized
277+
// A free DIN variant is available here (TTF only): https://www.1001fonts.com/alte-din-1451-mittelschrift-font.html
278+
$font-family-sans-serif: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif!default;
279+
$font-family-condensed: "Roboto Condensed", "Arial Narrow", sans-serif!default; //just on toolbar
280+
$font-family-serif: Georgia, "Times New Roman", Times, serif!default;
281+
// $font-family-base: var(--bs-font-sans-serif) !default;
282+
// $font-family-code: var(--bs-font-monospace) !default;
283+
284+
// Include Roboto as webfont
285+
$enable-roboto-webfont: true !default;
286+
287+
// $font-size-base: 1rem !default; // Assumes the browser default, typically `16px`
288+
// $font-size-sm: $font-size-base * .875 !default;
289+
// $font-size-lg: $font-size-base * 1.25 !default;
290+
291+
$font-weight-lighter: lighter !default;
292+
$font-weight-light: 300 !default;
293+
$font-weight-normal: 400 !default;
294+
$font-weight-semibold: 600 !default;
295+
$font-weight-bold: 700 !default;
296+
$font-weight-bolder: bolder !default;
297+
298+
// $font-weight-base: $font-weight-normal !default;
299+
300+
// $line-height-base: 1.5 !default;
301+
// $line-height-sm: 1.25 !default;
302+
// $line-height-lg: 2 !default;
303+
304+
// $h1-font-size: $font-size-base * 2.5 !default;
305+
// $h2-font-size: $font-size-base * 2 !default;
306+
// $h3-font-size: $font-size-base * 1.75 !default;
307+
// $h4-font-size: $font-size-base * 1.5 !default;
308+
// $h5-font-size: $font-size-base * 1.25 !default;
309+
// $h6-font-size: $font-size-base !default;
310+
311+
// $headings-margin-bottom: $spacer * .5 !default;
312+
// $headings-font-family: null !default;
313+
// $headings-font-style: null !default;
314+
$headings-font-weight: $font-weight-normal !default;
315+
// $headings-line-height: 1.2 !default;
316+
// $headings-color: null !default;
317+
318+
// Breadcrumbs
319+
$breadcrumb-margin-bottom: 2rem !default;
320+
$breadcrumb-bg: var(--bs-secondary-bg) !default;
321+
$breadcrumb-padding-y: $spacer * 0.5 !default;
322+
$breadcrumb-padding-x: $spacer * 1 !default;
323+
324+
325+
// Footer
326+
$footer-bg: $gray-900 !default;
327+
$footer-color: $gray-300 !default;
328+
```
329+
330+
### Properties
331+
332+
```scss
333+
$enable-caret: true !default;
334+
$enable-rounded: true !default;
335+
$enable-shadows: false !default;
336+
$enable-gradients: false !default;
337+
$enable-transitions: true !default;
338+
$enable-reduced-motion: true !default;
339+
$enable-smooth-scroll: true !default;
340+
$enable-grid-classes: true !default;
341+
$enable-container-classes: true !default;
342+
$enable-cssgrid: false !default;
343+
$enable-button-pointers: true !default;
344+
$enable-rfs: true !default;
345+
$enable-validation-icons: true !default;
346+
$enable-negative-margins: true !default;
347+
$enable-deprecation-messages: true !default;
348+
$enable-important-utilities: false !default;
349+
```

0 commit comments

Comments
 (0)