From c05bfdf71fa1716dc67e4c6ff87fef248b71bd61 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 5 Nov 2024 14:37:09 +0000 Subject: [PATCH] Theme: Add `debug` theme behind `extraThemes` toggle (#95838) add debug theme --- .../grafana-data/src/themes/createShape.ts | 2 +- packages/grafana-data/src/themes/registry.ts | 80 +++++++++++-------- pkg/services/preference/themes.go | 3 +- 3 files changed, 48 insertions(+), 37 deletions(-) diff --git a/packages/grafana-data/src/themes/createShape.ts b/packages/grafana-data/src/themes/createShape.ts index 881633523f4..8e6497639a7 100644 --- a/packages/grafana-data/src/themes/createShape.ts +++ b/packages/grafana-data/src/themes/createShape.ts @@ -22,7 +22,7 @@ export function createShape(options: ThemeShapeInput): ThemeShape { const baseBorderRadius = options.borderRadius ?? 2; const radius = { - default: '2px', + default: `${baseBorderRadius}px`, pill: '9999px', circle: '100%', }; diff --git a/packages/grafana-data/src/themes/registry.ts b/packages/grafana-data/src/themes/registry.ts index 85e9e399153..c6066d22075 100644 --- a/packages/grafana-data/src/themes/registry.ts +++ b/packages/grafana-data/src/themes/registry.ts @@ -1,5 +1,6 @@ import { Registry, RegistryItem } from '../utils/Registry'; +import { createColors } from './createColors'; import { createTheme } from './createTheme'; import { GrafanaTheme2 } from './types'; @@ -35,8 +36,7 @@ const themeRegistry = new Registry(() => { { id: 'system', name: 'System preference', build: getSystemPreferenceTheme }, { id: 'dark', name: 'Dark', build: () => createTheme({ colors: { mode: 'dark' } }) }, { id: 'light', name: 'Light', build: () => createTheme({ colors: { mode: 'light' } }) }, - { id: 'blue-night', name: 'Blue night', build: createBlueNight, isExtra: true }, - { id: 'midnight', name: 'Midnight', build: createMidnight, isExtra: true }, + { id: 'debug', name: 'Debug', build: createDebug, isExtra: true }, ]; }); @@ -47,47 +47,59 @@ function getSystemPreferenceTheme() { } /** - * Just a temporary placeholder for a possible new theme + * a very ugly theme that is useful for debugging and checking if the theme is applied correctly + * borders are red, + * backgrounds are blue, + * text is yellow, + * and grafana loves you <3 + * (also corners are rounded, action states (hover, focus, selected) are purple) */ -function createMidnight(): GrafanaTheme2 { - const whiteBase = '204, 204, 220'; +function createDebug(): GrafanaTheme2 { + const baseDarkColors = createColors({ + mode: 'dark', + }); return createTheme({ - name: 'Midnight', + name: 'Debug', colors: { mode: 'dark', background: { - canvas: '#000000', - primary: '#000000', - secondary: '#181818', + canvas: '#000033', + primary: '#000044', + secondary: '#000055', + }, + text: { + primary: '#bbbb00', + secondary: '#888800', + disabled: '#444400', + link: '#dddd00', + maxContrast: '#ffff00', }, border: { - weak: `rgba(${whiteBase}, 0.17)`, - medium: `rgba(${whiteBase}, 0.25)`, - strong: `rgba(${whiteBase}, 0.35)`, - }, - }, - }); -} - -/** - * Just a temporary placeholder for a possible new theme - */ -function createBlueNight(): GrafanaTheme2 { - return createTheme({ - name: 'Blue night', - colors: { - mode: 'dark', - background: { - canvas: '#15161d', - primary: '#15161d', - secondary: '#1d1f2e', - }, - border: { - weak: `#2e304f`, - medium: `#2e304f`, - strong: `#2e304f`, + weak: '#ff000044', + medium: '#ff000088', + strong: '#ff0000ff', }, + primary: { + ...baseDarkColors.primary, + border: '#ff000088', + text: '#cccc00', + contrastText: '#ffff00', + }, + secondary: { + ...baseDarkColors.secondary, + border: '#ff000088', + text: '#cccc00', + contrastText: '#ffff00', + }, + action: { + hover: '#9900dd', + focus: '#6600aa', + selected: '#440088', + }, + }, + shape: { + borderRadius: 8, }, }); } diff --git a/pkg/services/preference/themes.go b/pkg/services/preference/themes.go index 9ed9ba84bfc..f1332d33f0b 100644 --- a/pkg/services/preference/themes.go +++ b/pkg/services/preference/themes.go @@ -10,8 +10,7 @@ var themes = []ThemeDTO{ {ID: "light", Type: "light"}, {ID: "dark", Type: "dark"}, {ID: "system", Type: "dark"}, - {ID: "midnight", Type: "dark", IsExtra: true}, - {ID: "blue-night", Type: "dark", IsExtra: true}, + {ID: "debug", Type: "dark", IsExtra: true}, } func GetThemeByID(id string) *ThemeDTO {