Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add "on primary" color

Chocobozzz6ecd9823cfbe
diff --git a/client/src/app/+admin/config/pages/admin-config-customization.component.ts b/client/src/app/+admin/config/pages/admin-config-customization.component.ts
index ff8f5dc566..db27b6cb8e 100644
--- a/client/src/app/+admin/config/pages/admin-config-customization.component.ts
+++ b/client/src/app/+admin/config/pages/admin-config-customization.component.ts
@@ -56,6 +56,7 @@ type Form = {
customization: FormGroup<{
primaryColor: FormControl<string>
+ onPrimaryColor: FormControl<string>
foregroundColor: FormControl<string>
backgroundColor: FormControl<string>
backgroundSecondaryColor: FormControl<string>
@@ -129,6 +130,7 @@ export class AdminConfigCustomizationComponent implements OnInit, OnDestroy, Can
{ label: string, description?: string, type: FieldType, items?: SelectOptionsItem[] }
> = {
primaryColor: { label: $localize`Primary color`, type: 'color' },
+ onPrimaryColor: { label: $localize`On primary color`, type: 'color' },
foregroundColor: { label: $localize`Foreground color`, type: 'color' },
backgroundColor: { label: $localize`Background color`, type: 'color' },
backgroundSecondaryColor: {
@@ -193,6 +195,8 @@ export class AdminConfigCustomizationComponent implements OnInit, OnDestroy, Can
ngOnDestroy () {
if (this.customConfigSub) this.customConfigSub.unsubscribe()
+
+ this.themeService.updateColorPalette(this.customConfig.theme)
}
canDeactivate () {
@@ -271,6 +275,7 @@ export class AdminConfigCustomizationComponent implements OnInit, OnDestroy, Can
default: null,
customization: {
primaryColor: HEX_COLOR_CODE_VALIDATOR,
+ onPrimaryColor: HEX_COLOR_CODE_VALIDATOR,
foregroundColor: HEX_COLOR_CODE_VALIDATOR,
backgroundColor: HEX_COLOR_CODE_VALIDATOR,
backgroundSecondaryColor: HEX_COLOR_CODE_VALIDATOR,
diff --git a/client/src/root-helpers/theme-manager.ts b/client/src/root-helpers/theme-manager.ts
index 613bba04c9..69ca0dea48 100644
--- a/client/src/root-helpers/theme-manager.ts
+++ b/client/src/root-helpers/theme-manager.ts
@@ -18,6 +18,7 @@ export class ThemeManager {
private readonly configCSSVariableMap: ConfigCSSVariableMap = {
primaryColor: '--primary',
+ onPrimaryColor: '--on-primary',
foregroundColor: '--fg',
backgroundColor: '--bg',
backgroundSecondaryColor: '--bg-secondary',
diff --git a/config/default.yaml b/config/default.yaml
index 4d1a0961ff..5a95c32b97 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -1049,6 +1049,7 @@ theme:
# If you need more advanced customizations, install or develop a dedicated theme: https://docs.joinpeertube.org/contribute/plugins
customization:
primary_color: null # Hex color. Example: '#FF8F37'
+ on_primary_color: null # Hex color
foreground_color: null # Hex color
background_color: null # Hex color
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 18ceae8377..f45b868896 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -1059,6 +1059,7 @@ theme:
# If you need more advanced customizations, install or develop a dedicated theme: https://docs.joinpeertube.org/contribute/plugins
customization:
primary_color: null # Hex color. Example: '#FF8F37'
+ on_primary_color: null # Hex color
foreground_color: null # Hex color
background_color: null # Hex color
diff --git a/packages/models/src/server/custom-config.model.ts b/packages/models/src/server/custom-config.model.ts
index 1d46966413..5232a33569 100644
--- a/packages/models/src/server/custom-config.model.ts
+++ b/packages/models/src/server/custom-config.model.ts
@@ -64,6 +64,7 @@ export interface CustomConfig {
customization: {
primaryColor: string
+ onPrimaryColor: string
foregroundColor: string
backgroundColor: string
backgroundSecondaryColor: string
diff --git a/packages/models/src/server/emailer.model.ts b/packages/models/src/server/emailer.model.ts
index 1541d060ae..2ba8967d22 100644
--- a/packages/models/src/server/emailer.model.ts
+++ b/packages/models/src/server/emailer.model.ts
@@ -36,6 +36,7 @@ interface SendEmailDefaultLocalsOptions {
fg: string
bg: string
+ onPrimary: string
primary: string
language: string
logoUrl: string
diff --git a/packages/models/src/server/server-config.model.ts b/packages/models/src/server/server-config.model.ts
index 76dbbdb5b3..bbac0c69be 100644
--- a/packages/models/src/server/server-config.model.ts
+++ b/packages/models/src/server/server-config.model.ts
@@ -186,6 +186,7 @@ export interface ServerConfig {
customization: {
primaryColor: string
+ onPrimaryColor: string
foregroundColor: string
backgroundColor: string
backgroundSecondaryColor: string
diff --git a/packages/tests/src/api/server/config.ts b/packages/tests/src/api/server/config.ts
index 13d9a1fd25..276fb57424 100644
--- a/packages/tests/src/api/server/config.ts
+++ b/packages/tests/src/api/server/config.ts
@@ -213,6 +213,7 @@ function buildNewCustomConfig (server: PeerTubeServer): CustomConfig {
default: 'default',
customization: {
primaryColor: '#001',
+ onPrimaryColor: '#042',
foregroundColor: '#002',
backgroundColor: '#003',
backgroundSecondaryColor: '#004',
diff --git a/server/core/assets/email-templates/partials/button.hbs b/server/core/assets/email-templates/partials/button.hbs
index 177a1ab46c..1f2b862fa3 100644
--- a/server/core/assets/email-templates/partials/button.hbs
+++ b/server/core/assets/email-templates/partials/button.hbs
@@ -1,7 +1,7 @@
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" style="margin: auto;">
<tr>
- <td style="border-radius: 4px; background: {{primary}};">
- <a class="no-color" href="{{actionUrl}}" style="background: {{primary}}; font-family: sans-serif; font-size: 15px; line-height: 15px; text-decoration: none; padding: 13px 17px; display: block; border-radius: 4px; font-weight: bold;">{{actionText}}</a>
+ <td style="border-radius: 4px; background: {{primary}}; color: {{onPrimary}};">
+ <a class="no-color" href="{{actionUrl}}" style="background: {{primary}}; color: {{onPrimary}}; font-family: sans-serif; font-size: 15px; line-height: 15px; text-decoration: none; padding: 13px 17px; display: block; border-radius: 4px; font-weight: bold;">{{actionText}}</a>
</td>
</tr>
</table>
diff --git a/server/core/controllers/api/config.ts b/server/core/controllers/api/config.ts
index 0d8df44514..dd67a96f95 100644
--- a/server/core/controllers/api/config.ts
+++ b/server/core/controllers/api/config.ts
@@ -342,6 +342,7 @@ function customConfig (): CustomConfig {
customization: {
primaryColor: CONFIG.THEME.CUSTOMIZATION.PRIMARY_COLOR,
+ onPrimaryColor: CONFIG.THEME.CUSTOMIZATION.ON_PRIMARY_COLOR,
foregroundColor: CONFIG.THEME.CUSTOMIZATION.FOREGROUND_COLOR,
backgroundColor: CONFIG.THEME.CUSTOMIZATION.BACKGROUND_COLOR,
backgroundSecondaryColor: CONFIG.THEME.CUSTOMIZATION.BACKGROUND_SECONDARY_COLOR,
diff --git a/server/core/initializers/config.ts b/server/core/initializers/config.ts
index 3fa3ecc501..eb12ce5662 100644
--- a/server/core/initializers/config.ts
+++ b/server/core/initializers/config.ts
@@ -1059,6 +1059,9 @@ const CONFIG = {
get PRIMARY_COLOR () {
return config.get<string>('theme.customization.primary_color')
},
+ get ON_PRIMARY_COLOR () {
+ return config.get<string>('theme.customization.on_primary_color')
+ },
get FOREGROUND_COLOR () {
return config.get<string>('theme.customization.foreground_color')
},
diff --git a/server/core/lib/emailer.ts b/server/core/lib/emailer.ts
index c4cf5ba3b2..4ca872cfec 100644
--- a/server/core/lib/emailer.ts
+++ b/server/core/lib/emailer.ts
@@ -400,6 +400,7 @@ export class Emailer {
fg: CONFIG.THEME.CUSTOMIZATION.FOREGROUND_COLOR || '#000',
bg: CONFIG.THEME.CUSTOMIZATION.BACKGROUND_COLOR || '#fff',
primary: CONFIG.THEME.CUSTOMIZATION.PRIMARY_COLOR || '#FF8F37',
+ onPrimary: CONFIG.THEME.CUSTOMIZATION.ON_PRIMARY_COLOR || '#000',
language: to.language,
logoUrl: ServerConfigManager.Instance.getLogoUrl(await getServerActor(), 192)
}
diff --git a/server/core/lib/server-config-manager.ts b/server/core/lib/server-config-manager.ts
index 745b21db5e..0dddb1eee7 100644
--- a/server/core/lib/server-config-manager.ts
+++ b/server/core/lib/server-config-manager.ts
@@ -187,6 +187,7 @@ class ServerConfigManager {
default: defaultTheme,
customization: {
primaryColor: CONFIG.THEME.CUSTOMIZATION.PRIMARY_COLOR,
+ onPrimaryColor: CONFIG.THEME.CUSTOMIZATION.ON_PRIMARY_COLOR,
foregroundColor: CONFIG.THEME.CUSTOMIZATION.FOREGROUND_COLOR,
backgroundColor: CONFIG.THEME.CUSTOMIZATION.BACKGROUND_COLOR,
backgroundSecondaryColor: CONFIG.THEME.CUSTOMIZATION.BACKGROUND_SECONDARY_COLOR,