Skip to content

Commit 60d3468

Browse files
authored
Merge pull request #591 from City-of-Helsinki/UHF-12059
UHF-12059 Subtheme theme builder
2 parents 58078ab + e03422d commit 60d3468

17 files changed

Lines changed: 8204 additions & 16991 deletions

File tree

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
node_modules/**/*
2-
webpack.config.js
3-
webpack.svgToSprite.js
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23
1+
22

public/themes/custom/hdbt_subtheme/README.md

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,40 @@
44

55
HDBT Subtheme is a so called "starterkit" which you can start using by enabling it in `/admin/appearance`.
66

7-
Or if you don't accept the theme name, you can rename every `hdbt_subtheme` file with `your_theme_name` and renaming every `hdbt_subtheme_*` variable/reference with `your_theme_name_*`. And then enable it in `/admin/appearance`.
7+
HDBT Subtheme uses HDBT theme builder to compile the JS and SCSS files. Also, the SVG icons are combined in to a sprite.svg via the theme builder.
88

9-
Of course you have a choice to not use it at all by just deleting the whole folder.
10-
11-
HDBT Subtheme uses webpack module bundler to compile the JS and SCSS files. Also the SVG icons are combined in to a sprite.svg via webpack.
12-
13-
As the HDBT Subtheme is only distributed via the [HELfi Platform](https://github.com/City-of-Helsinki/drupal-helfi-platform), it doesn't have an upgrade path per se. In case there is a demand for upgradeability for existing projects then of course we will consider changing the theme to an upgradeable model.
9+
As the HDBT Subtheme is only distributed via the [HELfi Platform](https://github.com/City-of-Helsinki/drupal-helfi-platform),
10+
it doesn't have an upgrade path per se. In case there is a demand for upgrade-ability for existing projects then of
11+
course we will consider changing the theme to an upgradeable model.
1412

1513
## Requirements
1614

17-
HDBT Subtheme requires HDBT theme as a base theme and it should be installed in `/themes/custom/hdbt`.
15+
Do not rename the `hdbt_subtheme` as the Platform config 3.* assumes that the sub theme name is `hdbt_subtheme`.
16+
17+
HDBT Subtheme requires [hdbt theme](https://github.com/City-of-helsinki/drupal-hdbt) as a base theme, and it should be
18+
installed in `/themes/contrib/hdbt`.
1819

1920
Requirements for developing:
20-
- [NodeJS ( ^ 16.10 )](https://nodejs.org/en/)
21+
- [NodeJS](https://nodejs.org/en/)
2122
- [NPM](https://npmjs.com/)
2223
- optional [NVM](https://github.com/nvm-sh/nvm)
2324

2425
## Commands
2526

26-
| Command | Description |
27-
| ------------- | --------------------------------------------------------------------------------- |
28-
| nvm use | Uses correct Node version chosen for the subtheme compiler |
29-
| npm i | Install dependencies and link local packages. |
30-
| npm ci | Install a project with a clean slate. Use especially in travis like environments. |
31-
| npm run dev | Compile styles for development environment and watch file changes. |
32-
| npm run build | Build packages for production. Minify CSS/JS. Create icon sprite. |
27+
| Command | Make command | Description |
28+
|---------------|----------------------------|-----------------------------------------------------------------------------------|
29+
| nvm use | N/A | Uses correct Node version chosen for the subtheme compiler |
30+
| npm i | make install-hdbt-subtheme | Install dependencies and link local packages. |
31+
| npm ci | N/A | Install a project with a clean slate. Use especially in travis like environments. |
32+
| npm run dev | make watch-hdbt-subtheme | Compile styles for development environment and watch file changes. |
33+
| npm run build | make build-hdbt-subtheme | Build packages for production. Minify CSS/JS. Create icon sprite. |
34+
35+
Consistent Node version defined in `.nvmrc` should be used. For development, use either `nvm` to select the correct
36+
version or `make` commands that select the version automatically. Run `make` the commands from the table above in the
37+
project directory of your instance. For more information, see
38+
[build-assets.md](https://github.com/City-of-Helsinki/drupal-helfi-platform/blob/main/documentation/build-assets.md).
3339

34-
Setup the developing environment by running
40+
Set up the developing environment with `nvm` by running
3541

3642
nvm use
3743
npm i
@@ -40,6 +46,12 @@ Explanations for commands.
4046
- `nvm use` : Install and use the correct version of Node.
4147
- `npm i` : As stated above; Install dependencies and link local packages.
4248

49+
Related files.
50+
- `.nvmrc` : Defines the node version used to compile the theme.
51+
- `package.json and package-lock.json` : Defines the node modules for compiling the theme.
52+
- `theme-builder/` : The theme builder tools.
53+
- `theme-builder.mjs` : Configuration file for the theme builder tool that is used to build the theme.
54+
4355
Start SCSS/JS watcher by running
4456

4557
npm run dev
@@ -50,49 +62,28 @@ Build the minified versions of CSS/JS into dist with
5062

5163
## Structure for files and folders
5264

53-
```
54-
hdbt_subtheme
55-
│ README.md
56-
└───templates
57-
│ └───block
58-
│ └───content
59-
│ └───...
60-
└───src
61-
│ └───scss
62-
│ │ │ styles.scss
63-
│ │ └───base
64-
│ │ │ └───__index.scss
65-
│ │ │ └───_base.scss
66-
│ │ │ └───...
67-
│ │ └───components
68-
│ │ │ └───__index.scss
69-
│ │ │ └───...
70-
│ │ └───...
71-
│ └───js
72-
│ │ │ common.js
73-
└───dist
74-
└───css
75-
| styles.min.css
76-
└───js
77-
| bundle.min.js
78-
```
65+
The structure follows the same rules as in the hdbt-theme so you should read about more from the
66+
[hdbt documentation](https://github.com/City-of-helsinki/drupal-hdbt).
7967

8068
## How tos
8169

8270
### My javascript has unexpected errors when loading a page in Drupal.
8371

84-
If you have compiled the code with dev-flag (`nmp run dev`), then the sourcemaps expects the JS files to be found in correct places.
85-
This means that JS preprocessing (minifying) should be turned off. Just add the following lines to local.settings.php.
72+
If you have compiled the code with dev-flag (`nmp run dev`), then the sourcemaps expects the JS files to be found in
73+
correct places. This means that JS preprocessing (minifying) should be turned off. Just add the following lines to
74+
local.settings.php.
8675
```
8776
$config['system.performance']['css']['preprocess'] = 0;
8877
$config['system.performance']['js']['preprocess'] = 0;
8978
```
9079

9180
### I need to rebuild caches every time I build the css or change the twig files. How can I automate it?
9281

93-
You can create a `local.settings.php` and `local.services.yml` files to `/sites/default/` folder and paste the following contents in them.
82+
You can create a `local.settings.php` and `local.services.yml` files to `/sites/default/` folder and paste the following
83+
contents in them.
9484

95-
**_Keep in mind that using the Null Cache Backend is the primary culprit for caching issues. F.e. Something works in local environment, but not in production environment._**
85+
**_Keep in mind that using the Null Cache Backend is the primary culprit for caching issues. F.e. Something works in
86+
local environment, but not in production environment._**
9687

9788
local.services.yml:
9889
```
@@ -131,7 +122,8 @@ aggregation from Drupal. Go to /admin/config/development/performance and uncheck
131122
site caches and you should be able to continue with your work.
132123

133124
### How can I add custom translations?
134-
Add your UI translations to ``./translations/{fi/sv}.po`` files like it is explained in Translation in Drupal 8 documentation: https://www.drupal.org/docs/understanding-drupal/translation-in-drupal-8.
125+
Add your UI translations to `./translations/{fi/sv}.po` files like it is explained in Translation in Drupal
126+
documentation: https://www.drupal.org/docs/understanding-drupal/translation-in-drupal-8.
135127
These translations consists of:
136128

137129
PHP
@@ -166,6 +158,6 @@ msgstr[1] "Monikko"
166158

167159
To see these translation changes in an instance, run in container shell:
168160
```
169-
drush locale:check && drush locale:update
161+
drush locale:check && drush locale:update && drush cr
170162
```
171163
And then flush all caches from top left drupal admin menu under "Druplicon".

public/themes/custom/hdbt_subtheme/dist/css/styles.min.css

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)