Skip to content

Commit 5a0d818

Browse files
authored
Merge pull request #463 from sronveaux/remove-roboto-add-vuetify-custom-style-loading
Add possibility to customize Vuetify SASS variables and correctly define default font family
2 parents e0fec9d + 746380c commit 5a0d818

File tree

10 files changed

+69
-26
lines changed

10 files changed

+69
-26
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$custom-font-family: Avenir, Helvetica, Arial, sans-serif;
2+
3+
@use 'vuetify/settings' with (
4+
$body-font-family: $custom-font-family,
5+
$heading-font-family: $custom-font-family
6+
);

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Reusable Components](reusable-components.md)
1111
- [Language Packs](language-packs.md)
1212
- [Custom Icons](custom-icons.md)
13+
- [Vuetify SASS Variables](vuetify-sass-variables.md)
1314
- [QGIS2Wegue](qgis_plugin.md)
1415

1516

docs/vuetify-sass-variables.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Vuetify SASS variables
2+
3+
For more advanced use-cases, Wegue allows to completely customize its look and feel by overriding the `SASS` variables used by Vuetify. These overrides must be done via the `app/styles/vuetify-settings.scss` file.
4+
5+
An extensive list of Vuetify configurable global `SASS` variables can be found [here](https://vuetifyjs.com/en/api/globals/).
6+
To this list, you can also add the variables defined specifically for each component. These are listed in the `API` section of the official Vuetify documentation, at the bottom of each page dedicated to components. If you have a clear idea of the parameter you want to override, you can search the complete list of variables from the combobox located [here](https://vuetifyjs.com/en/features/sass-variables/#variable-api)
7+
8+
## Examples
9+
10+
Below are two examples of customisation, one very simple and the other requiring a few additional steps.
11+
12+
For example, it is possible to modify the border radius of component windows by changing the variable `$card-border-radius`. This can be done very easily by modifying your `app/styles/vuetify-settings.scss` file as follows:
13+
14+
```css
15+
$custom-font-family: Avenir, Helvetica, Arial, sans-serif;
16+
17+
@use 'vuetify/settings' with (
18+
$body-font-family: $custom-font-family,
19+
$heading-font-family: $custom-font-family,
20+
$card-border-radius: 16px
21+
);
22+
```
23+
24+
As a more complicated example, it is possible to change the font used in Wegue. To do this, you will need to install a package containing this font and include it somewhere in your code.
25+
To find open-source fonts packaged in the expected format and easy to use, you can visit [fontsource.org](https://fontsource.org/). This site contains a [generic guide](https://fontsource.org/docs/getting-started/install) explaining how to include a font bundled by them, and these explanations are clearly adapted on each font-specific page.
26+
27+
If you wanted to use the [Space Grotesk](https://fontsource.org/fonts/space-grotesk) font, you can follow [their dedicated install page](https://fontsource.org/fonts/space-grotesk/install).
28+
29+
First, you must install the font by installing its NPM package:
30+
31+
```sh
32+
npm i --save @fontsource-variable/space-grotesk
33+
```
34+
35+
You must then import this font somewhere in your code, for example in the `app/WguAppTemplate.vue` file by adding this line:
36+
37+
```js
38+
import '@fontsource-variable/space-grotesk';
39+
```
40+
41+
And finally, you must modify the Vuetify `SASS` variables by modifying your `app/styles/vuetify-settings.scss` file as follows:
42+
43+
```css
44+
$custom-font-family: 'Space Grotesk Variable', sans-serif;
45+
46+
@use 'vuetify/settings' with (
47+
$body-font-family: $custom-font-family,
48+
$heading-font-family: $custom-font-family
49+
);
50+
```

docs/wegue-configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ To simplify the theming configuration, if the "themes" property isn't configured
109109
Note that there is a clear asymmetry in the "light" and "dark" theme configuration. In the "light" theme, the primary color is mandatory and all the
110110
others are derived from that. In the "dark" theme, the predominant color must be a shade of black (to comply with the [material design specification](https://material.io/design/color/dark-theme.html)), so the primary color is locked to `#272727`. Therefore, in this case the colors are derived from the second predominant color.
111111

112+
#### Advanced theme customization
113+
114+
If changing the color theme is not enough, Wegue allows you to customize the entire look and feel of Vuetify by redefining its internally used SASS variables. Details about this functionality and some examples can be found on [this dedicated page](vuetify-sass-variables?id=vuetify-sass-variables).
115+
112116
#### Tips on creating a color theme
113117

114118
In this section we offer a couple of tips on choosing colors for Wegue while meeting the [material design principles](https://material.io/design/color/the-color-system.html#color-usage-and-palettes) (hierarchy/legibility/expressiveness).

package-lock.json

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"init:app": "node util/init-app.js"
2323
},
2424
"dependencies": {
25-
"@fontsource/roboto": "^5.2.8",
2625
"@material-design-icons/font": "0.14.15",
2726
"@mdi/font": "7.4.47",
2827
"@vue/compat": "^3.5.22",

src/main.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@ import { md } from 'vuetify/iconsets/md';
44
import { aliases as defaultAliases, mdi } from 'vuetify/iconsets/mdi';
55
import 'vuetify/styles';
66
import { createI18nInstance } from './locales/wgu-i18n';
7-
import '@fontsource/roboto/100.css';
8-
import '@fontsource/roboto/300.css';
9-
import '@fontsource/roboto/400.css';
10-
import '@fontsource/roboto/500.css';
11-
import '@fontsource/roboto/700.css';
12-
import '@fontsource/roboto/900.css';
13-
import '@fontsource/roboto/100-italic.css';
14-
import '@fontsource/roboto/300-italic.css';
15-
import '@fontsource/roboto/400-italic.css';
16-
import '@fontsource/roboto/500-italic.css';
17-
import '@fontsource/roboto/700-italic.css';
18-
import '@fontsource/roboto/900-italic.css';
197
import '@mdi/font/css/materialdesignicons.css';
208
import '@material-design-icons/font';
219
import 'ol/ol.css';

src/styles/wegue.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ html {
55
}
66

77
.wgu-app {
8-
font-family: Avenir, Helvetica, Arial, sans-serif;
98
position: relative;
109
width: 100%;
1110
}

upgrade-notes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ This means components are still written using the `Options API` for example.
1010
To be compatible with all the required dependencies, minimal `node` version was raised to `v20.19.0` while minimal `npm` version was also raised to `v10.8.2`.
1111

1212
Changes that were applied on the files present in the [app-starter](https://github.com/wegue-oss/wegue/commits/master/app-starter) directory should also be applied to your custom files present in the `app` directory.
13-
Pay particular attention to these two points:
13+
Pay particular attention to these three points:
1414

1515
- The `app/static` directory should be renamed `app/public/static`
1616
- The `app/static/css` directory should be renamed `app/styles`
17+
- A file named `app/styles/vuetify-settings.scss` must be present. The default minimal file can be found in the [`app-starter/styles` directory](https://github.com/wegue-oss/wegue/tree/master/app-starter/styles).
18+
For more details about its usage, please refer to the [Wegue documentation](https://wegue-oss.github.io/wegue/#/vuetify-sass-variables?id=vuetify-sass-variables).
1719

1820
### Vite
1921

vite.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export default defineConfig(({ mode }) => {
3838
}),
3939
// Remove Vue DevTools plugin when building for unit tests.
4040
...(process.env.NODE_ENV === 'test' ? [] : [vueDevTools()]),
41-
Vuetify(),
41+
Vuetify({
42+
styles: {
43+
configFile: 'app/styles/vuetify-settings.scss'
44+
}
45+
}),
4246
eslintPlugin({
4347
// Lint src and app directories.
4448
shouldLint: (path) => path.match(/\/(src|app)\/[^?]*\.(vue|svelte|m?[jt]sx?)$/)

0 commit comments

Comments
 (0)