doc/pages/01.administrate/07.specific_use_cases/04.theming/theming.md

74 lines
2.5 KiB
Markdown
Raw Normal View History

2020-11-11 11:47:10 +01:00
---
title: Customize the appearance of the user portal
template: docs
taxonomy:
category: docs
routes:
default: '/theming'
2020-11-11 11:47:10 +01:00
---
2019-03-19 17:42:32 +01:00
## Using a theme
Since YunoHost 3.5, you can change the theme of the user portal - though for now it requires tweaking via the command line.
2020-09-14 11:23:05 +02:00
You can list the available themes with:
2019-03-19 17:42:32 +01:00
```bash
$ ls /usr/share/ssowat/portal/assets/themes/
```
2020-09-14 11:23:05 +02:00
Then you can use `nano /etc/ssowat/conf.json.persistent` to enable the theme you choose like this:
2019-03-19 17:42:32 +01:00
```json
{
"theme": "light",
...other lines...
}
```
2021-02-07 03:53:10 +01:00
!!! You might need to force the refresh of your browser's cache for the theme to fully propagate. You can do so with Ctrl+Shift+R on Firefox.
2019-03-19 17:42:32 +01:00
## Adding someone else's theme
You may add themes created by other people by downloading and extracting the corresponding files in a new folder `the_theme_name` in `/usr/share/ssowat/portal/assets/themes/`.
2021-02-07 03:46:29 +01:00
! **Beware** that adding third-party themes from random strangers on the internet **is a security risk**. It is equivalent to running someone's else code on your machine, which can be used for malicious purpose such as stealing credentials!
2019-03-19 17:42:32 +01:00
2021-08-03 02:51:26 +02:00
There are a handful of themes listed [on Github](https://github.com/yunohost-themes).
2019-03-19 17:42:32 +01:00
## Creating your own theme
2020-09-14 11:23:05 +02:00
You can create your own theme by copying the existing theme of your choice. For instance starting from the light theme:
2019-03-19 17:42:32 +01:00
```bash
cp -r /usr/share/ssowat/portal/assets/themes/{light,your_own_theme}
```
2020-09-14 11:23:05 +02:00
Then, edit the files the CSS and JS files in `/usr/share/ssowat/portal/assets/themes/your_own_theme` according to what you want to do:
2019-03-19 17:42:32 +01:00
2020-09-14 11:23:05 +02:00
- `custom_portal.css` can be used to add custom CSS rules to the user portal;
- `custom_overlay.css` can be used to customize the small YunoHost button overlay, displayed on apps page which includes it;
2019-03-19 17:42:32 +01:00
- `custom_portal.js` can be used to add custom JS code to be ran both on the user portal or when injecting the small YunoHost button / overlay.
You can also add your own images and assets which can then be used by the CSS and JS files.
!!! Share your custom theme with the community! https://github.com/yunohost-themes
2019-03-19 17:42:32 +01:00
### Example : customizing the logo
2020-09-14 11:23:05 +02:00
You may create your own theme simply to change the "branding" of the YunoHost user portal and replace the YunoHost logo with you own!
2019-03-19 17:42:32 +01:00
2020-09-14 11:23:05 +02:00
To do so, upload your logo to `/usr/share/ssowat/portal/assets/themes/your_own_theme/`, and use the following CSS rules:
2019-03-19 17:42:32 +01:00
```css
/* Inside custom_portal.css */
#ynh-logo {
background-image: url("./your_logo.png");
}
/* Inside custom_overlay.css */
#ynh-overlay-switch {
background-image: url("./your_logo.png");
}
```