aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/appearance
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-05-12 18:48:40 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-12 18:48:40 +0200
commit2a2f6fe945b87f50c95a31efb7c47c664e58a8bf (patch)
treef38165789e3a68b83a91b6882d75885c47579371 /src/features/appearance
parentUpdated the documentation (#1394) (diff)
downloadferdium-app-2a2f6fe945b87f50c95a31efb7c47c664e58a8bf.tar.gz
ferdium-app-2a2f6fe945b87f50c95a31efb7c47c664e58a8bf.tar.zst
ferdium-app-2a2f6fe945b87f50c95a31efb7c47c664e58a8bf.zip
Fix some appearance issues (#1398)
* Fix property spelling in Sidebar component * Fix typo in todos partition name * Use the FerdiDev setting.json in dev mode The app.setPath calls are still a mess and need to be fixed, but this at least allows me to experiment locally. * Make @meetfranz/theme follow the accent color We inject the value of the accent color into the themes, so the buttons show the appropriate color. This allows removing some existing css hacks. In order to do this, the themes had to be turned into functions that take the brand color (accent color) as an argument instead of hard-coding it. The css-based accent color for legacy components is left unchanged. * Remove superfluous scrollbars While overflow: scroll doesn't look ugly on macs, because the system hides scrollbars by default (except on hower), on Linux and Windows, the disabled scrollbars appearing by default look ugly. We set overflow-y: auto instead to display a scrollbar only when needed. * Simplify theme generation in @meetfranz/themes * Remove default accent color code duplication * Apply accent color to styles not in themeInfo.json Some colors are darkened/lightened versions of the primary brand color, so they are not caught by build-theme-info. We create these styles with `color` manually. * Inset shadow on sidebar This creates a more flat look that projecting a shadow over the service, and avoid compositing a shadow over the webview. * Apply accent color to vertical style tab bar * Workspace drawer styling in vertical mode * Fix sidebar layout In vertical mode, the top of the service was clipped by the sidebar Also removes unnecessary whitespace in sidebar * Fix 1px wide line on right when todos are hidden * Fix window menu When building the menu bar, the File / app menu is added later, so we must be careful about indexing the menu bar. * Update locale files * Report the default accent color accurately * Fix inverted button with dark theme * Fix crash with invalid accent color Fall back to the default accent color instead * Darker secondary buttons in dark mode * Vertical workspace drawer style outside debug mode In order to reliably apply the style, we need to add a class name to the drawer manually, as component names only appear in class names in debug mode.
Diffstat (limited to 'src/features/appearance')
-rw-r--r--src/features/appearance/index.js80
1 files changed, 56 insertions, 24 deletions
diff --git a/src/features/appearance/index.js b/src/features/appearance/index.js
index 039ef7711..3bd6a6575 100644
--- a/src/features/appearance/index.js
+++ b/src/features/appearance/index.js
@@ -1,18 +1,10 @@
1import color from 'color';
1import { reaction } from 'mobx'; 2import { reaction } from 'mobx';
2import themeInfo from '../../assets/themeInfo.json'; 3import themeInfo from '../../assets/themeInfo.json';
3import { DEFAULT_APP_SETTINGS, iconSizeBias } from '../../config'; 4import { DEFAULT_APP_SETTINGS, iconSizeBias } from '../../config';
4 5
5const STYLE_ELEMENT_ID = 'custom-appearance-style'; 6const STYLE_ELEMENT_ID = 'custom-appearance-style';
6 7
7// Additional styles needed to make accent colors work properly
8// "[ACCENT]" will be replaced with the accent color
9const ACCENT_ADDITIONAL_STYLES = `
10.franz-form__button {
11 background: inherit !important;
12 border: 2px solid [ACCENT] !important;
13}
14`;
15
16function createStyleElement() { 8function createStyleElement() {
17 const styles = document.createElement('style'); 9 const styles = document.createElement('style');
18 styles.id = STYLE_ELEMENT_ID; 10 styles.id = STYLE_ELEMENT_ID;
@@ -26,18 +18,53 @@ function setAppearance(style) {
26 styleElement.innerHTML = style; 18 styleElement.innerHTML = style;
27} 19}
28 20
29function generateAccentStyle(color) { 21function generateAccentStyle(accentColorStr) {
30 let style = ''; 22 let style = '';
31 23
32 Object.keys(themeInfo).forEach((property) => { 24 Object.keys(themeInfo).forEach((property) => {
33 style += ` 25 style += `
34 ${themeInfo[property]} { 26 ${themeInfo[property]} {
35 ${property}: ${color}; 27 ${property}: ${accentColorStr};
36 } 28 }
37 `; 29 `;
38 }); 30 });
39 31
40 style += ACCENT_ADDITIONAL_STYLES.replace(/\[ACCENT\]/g, color); 32 let accentColor = color(DEFAULT_APP_SETTINGS.accentColor);
33 try {
34 accentColor = color(accentColorStr);
35 } catch (e) {
36 // Ignore invalid accent color.
37 }
38 const darkerColorStr = accentColor.darken(0.05).hex();
39 style += `
40 a.button:hover, button.button:hover {
41 background: ${accentColor.darken(0.1).hex()};
42 }
43
44 .franz-form__button:hover,
45 .franz-form__button.franz-form__button--inverted:hover,
46 .settings .settings__close:hover,
47 .theme__dark .franz-form__button:hover,
48 .theme__dark .franz-form__button.franz-form__button--inverted:hover,
49 .theme__dark .settings .settings__close:hover {
50 background: ${darkerColorStr};
51 }
52
53 .franz-form__button:active,
54 .theme__dark .franz-form__button:active {
55 background: ${darkerColorStr};
56 }
57
58 .theme__dark .franz-form__button.franz-form__button--inverted,
59 .franz-form__button.franz-form__button--inverted {
60 background: none;
61 border-color: ${accentColorStr};
62 }
63
64 .tab-item.is-active {
65 background: ${accentColor.lighten(0.35).hex()};
66 }
67 `;
41 68
42 return style; 69 return style;
43} 70}
@@ -60,7 +87,7 @@ function generateServiceRibbonWidthStyle(widthStr, iconSizeStr, vertical) {
60 } 87 }
61 ` : ` 88 ` : `
62 .sidebar { 89 .sidebar {
63 width: ${width - 1}px !important; 90 width: ${width - 2}px !important;
64 } 91 }
65 .tab-item { 92 .tab-item {
66 width: ${width - 2}px !important; 93 width: ${width - 2}px !important;
@@ -102,22 +129,27 @@ function generateVerticalStyle(widthStr, alwaysShowWorkspaces) {
102 document.head.appendChild(link); 129 document.head.appendChild(link);
103 } 130 }
104 const width = Number(widthStr); 131 const width = Number(widthStr);
132 const sidebarWidthStr = `${width - 4}px`;
105 133
106 return ` 134 return `
107 .app_service { 135 .sidebar {
108 top: ${width}px !important; 136 height: ${sidebarWidthStr} !important;
137 ${alwaysShowWorkspaces ? `
138 width: calc(100% - 300px) !important;
139 ` : ''}
109 } 140 }
110 .darwin .sidebar { 141
111 height: ${width + 19}px !important; 142 .sidebar .sidebar__button {
143 width: ${width}px;
112 } 144 }
113 .darwin .sidebar .sidebar__button--workspaces.is-active { 145
114 height: ${width - 20}px !important; 146 .app .app__content {
147 padding-top: ${sidebarWidthStr} !important;
115 } 148 }
116 ${alwaysShowWorkspaces ? ` 149
117 .sidebar { 150 .workspaces-drawer {
118 width: calc(100% - 300px) !important; 151 maring-top: -${sidebarWidthStr} !important;
119 } 152 }
120 ` : ''}
121 `; 153 `;
122} 154}
123 155
@@ -145,7 +177,7 @@ function generateStyle(settings) {
145 alwaysShowWorkspaces, 177 alwaysShowWorkspaces,
146 } = settings; 178 } = settings;
147 179
148 if (accentColor !== DEFAULT_APP_SETTINGS.accentColor) { 180 if (accentColor.toLowerCase() !== DEFAULT_APP_SETTINGS.accentColor.toLowerCase()) {
149 style += generateAccentStyle(accentColor); 181 style += generateAccentStyle(accentColor);
150 } 182 }
151 if (serviceRibbonWidth !== DEFAULT_APP_SETTINGS.serviceRibbonWidth 183 if (serviceRibbonWidth !== DEFAULT_APP_SETTINGS.serviceRibbonWidth