aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Victor B <39555268+victorbnl@users.noreply.github.com>2023-01-19 02:37:18 +0100
committerLibravatar GitHub <noreply@github.com>2023-01-19 01:37:18 +0000
commitdb137f5db3bb908df6fa6bec2e35ac8d61b8c70a (patch)
tree60247bcd2708e43e370e46a78cad2c521755e259
parent6.2.4-nightly.9 [skip ci] (diff)
downloadferdium-app-db137f5db3bb908df6fa6bec2e35ac8d61b8c70a.tar.gz
ferdium-app-db137f5db3bb908df6fa6bec2e35ac8d61b8c70a.tar.zst
ferdium-app-db137f5db3bb908df6fa6bec2e35ac8d61b8c70a.zip
Add custom CSS support (#868)
Co-authored-by: André Oliveira <oliveira.andrerodrigues95@gmail.com> Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
-rw-r--r--README.md13
-rw-r--r--src/features/appearance/index.ts9
2 files changed, 22 insertions, 0 deletions
diff --git a/README.md b/README.md
index 8d98f9dcd..692f90943 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@
28 - [Screenshots](#screenshots) 28 - [Screenshots](#screenshots)
29 - [Download](#download) 29 - [Download](#download)
30 - [Migrating from Ferdi](#migrating-from-ferdi) 30 - [Migrating from Ferdi](#migrating-from-ferdi)
31 - [Styling](#styling)
31 - [Contributing](#contributing) 32 - [Contributing](#contributing)
32 - [Contributors ✨](#contributors-) 33 - [Contributors ✨](#contributors-)
33 34
@@ -63,6 +64,18 @@ _Find answers to frequently asked questions on [ferdium.org/faq](https://ferdium
63 64
64If you are a pre-existing user of Ferdi, and are thinking of switching to Ferdium, you might want to run [the following scripts](./scripts/migration) to migrate your existing Ferdi profile such that Ferdium can pick up the configurations. (.ps1 for PowerShell/Windows users and .sh for UNIX (Linux and MacOS users). For a more detailed explanation, please see [MIGRATION.md](MIGRATION.md) 65If you are a pre-existing user of Ferdi, and are thinking of switching to Ferdium, you might want to run [the following scripts](./scripts/migration) to migrate your existing Ferdi profile such that Ferdium can pick up the configurations. (.ps1 for PowerShell/Windows users and .sh for UNIX (Linux and MacOS users). For a more detailed explanation, please see [MIGRATION.md](MIGRATION.md)
65 66
67## Styling
68
69You can style Ferdium's UI with the `USER_DATA/Ferdium/config/custom.css` file.
70
71> **Note**
72>
73> `USER_DATA`'s location depends on your platform:
74>
75> - **Windows**: `%APPDATA%`
76> - **Linux**: `$XDG_CONFIG_HOME` or `~/.config/`
77> - **MacOS**: `~/Library/Application Support`
78
66## Contributing 79## Contributing
67 80
68Please read the [contributing guidelines](CONTRIBUTING.md) to setup your development machine and proceed. 81Please read the [contributing guidelines](CONTRIBUTING.md) to setup your development machine and proceed.
diff --git a/src/features/appearance/index.ts b/src/features/appearance/index.ts
index b3cbd3347..9c9f3e175 100644
--- a/src/features/appearance/index.ts
+++ b/src/features/appearance/index.ts
@@ -2,6 +2,7 @@ import color from 'color';
2import { reaction } from 'mobx'; 2import { reaction } from 'mobx';
3import TopBarProgress from 'react-topbar-progress-indicator'; 3import TopBarProgress from 'react-topbar-progress-indicator';
4 4
5import { pathExistsSync, readFileSync } from 'fs-extra';
5import { isWindows, isLinux } from '../../environment'; 6import { isWindows, isLinux } from '../../environment';
6import { 7import {
7 DEFAULT_APP_SETTINGS, 8 DEFAULT_APP_SETTINGS,
@@ -10,6 +11,7 @@ import {
10 SIDEBAR_SERVICES_LOCATION_CENTER, 11 SIDEBAR_SERVICES_LOCATION_CENTER,
11 SIDEBAR_SERVICES_LOCATION_BOTTOMRIGHT, 12 SIDEBAR_SERVICES_LOCATION_BOTTOMRIGHT,
12} from '../../config'; 13} from '../../config';
14import { userDataPath } from '../../environment-remote';
13 15
14const STYLE_ELEMENT_ID = 'custom-appearance-style'; 16const STYLE_ELEMENT_ID = 'custom-appearance-style';
15 17
@@ -34,6 +36,11 @@ function darkenAbsolute(originalColor, absoluteChange) {
34 return originalColor.lightness(originalLightness - absoluteChange); 36 return originalColor.lightness(originalLightness - absoluteChange);
35} 37}
36 38
39function generateUserCustomCSS() {
40 const path = userDataPath('config', 'custom.css');
41 return pathExistsSync(path) ? readFileSync(path).toString() : '';
42}
43
37function generateAccentStyle(accentColorStr) { 44function generateAccentStyle(accentColorStr) {
38 let accentColor; 45 let accentColor;
39 try { 46 try {
@@ -421,6 +428,8 @@ function generateStyle(settings, app) {
421 style += generateOpenWorkspaceStyle(); 428 style += generateOpenWorkspaceStyle();
422 } 429 }
423 430
431 style += generateUserCustomCSS();
432
424 return style; 433 return style;
425} 434}
426 435