From 3972bb50ab8355fa02ba7ab162d40e024cf71d89 Mon Sep 17 00:00:00 2001 From: Roger Guasch <30463479+roguib@users.noreply.github.com> Date: Wed, 19 May 2021 08:14:11 +0200 Subject: [PATCH] Theme preview tile for OS themes (#3387) Co-authored-by: Opender Singh --- .../app/ui/components/settings/theme.tsx | 160 ++++++++++-------- .../app/ui/css/components/themes.less | 13 +- 2 files changed, 105 insertions(+), 68 deletions(-) diff --git a/packages/insomnia-app/app/ui/components/settings/theme.tsx b/packages/insomnia-app/app/ui/components/settings/theme.tsx index 48ba917240..842a3d0f1b 100644 --- a/packages/insomnia-app/app/ui/components/settings/theme.tsx +++ b/packages/insomnia-app/app/ui/components/settings/theme.tsx @@ -37,6 +37,63 @@ class Theme extends PureComponent { }); } + renderThemePreview(themeName: string) { + return ( + /* @ts-expect-error -- TSCONVERSION */ + + {/* + A WORD TO THE WISE: If you, dear traveler from the future, are here + for the purpose of theming things due to changes in the app structure, + please remember to add `--sub` to your classes or else the selected class' + theme variables will apply to all theme previews. Search your codebase + for `--sub` to see more. + */} + + {/* @ts-expect-error -- TSCONVERSION */} + + {/* App Header */} + + + + + {/* Panes */} + + {/* Response Area */} + + + {/* URL Bars */} + + + + {/* Sidebar */} + + + + + {/* Lines */} + + + + + + {/* Color Squares */} + + + + + + + + + ); + } + renderTheme(theme: ThemeType) { const { handleChangeTheme, activeTheme, autoDetectColorScheme } = this.props; const isActive = activeTheme === theme.theme.name; @@ -53,54 +110,7 @@ class Theme extends PureComponent { disabled={disabled} onClick={() => handleChangeTheme(theme.theme.name, 'default')} className={isActive ? 'active' : ''}> - {/* @ts-expect-error -- TSCONVERSION */} - - {/* - A WORD TO THE WISE: If you, dear traveler from the future, are here for the purpose of theming things due to changes in the app structure, please remember to add `--sub` to your classes or else the selected class' theme variables will apply to all theme previews. Search your codebase for `--sub` to see more. - */} - - {/* @ts-expect-error -- TSCONVERSION */} - - {/* App Header */} - - - - - {/* Panes */} - - {/* Response Area */} - - - {/* URL Bars */} - - - - {/* Sidebar */} - - - - - {/* Lines */} - - - - - - {/* Color Squares */} - - - - - - - - + {this.renderThemePreview(theme.theme.name)} ); @@ -133,26 +143,42 @@ class Theme extends PureComponent { } renderThemeSelect(scheme: 'light' | 'dark') { - const { activeLightTheme, activeDarkTheme, handleChangeTheme } = this.props; + const { + activeLightTheme, + activeDarkTheme, + handleChangeTheme, + autoDetectColorScheme, + } = this.props; const { themes } = this.state; - const activeColorTheme = scheme === 'light' ? activeLightTheme : activeDarkTheme; + const activeColorTheme = + scheme === 'light' ? activeLightTheme : activeDarkTheme; return ( -
- +
+
+ +
+
+
+ +
+
); } @@ -161,7 +187,7 @@ class Theme extends PureComponent { const { autoDetectColorScheme, handleAutoDetectColorSchemeChange } = this.props; return ( <> -
{this.renderThemeRows()}
+
{this.renderThemeRows()}