Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect: Adjust to the light theme #27080

Merged
merged 10 commits into from Jun 5, 2023
Merged

Conversation

gzdunek
Copy link
Contributor

@gzdunek gzdunek commented May 29, 2023

Contributes to #27079
e https://github.com/gravitational/teleport.e/pull/1522

Our theme was used incorrectly in some places. This led to some visual issues when applied the light theme. This PR fixes that.
The PR also adds our own terminal theme, which we have worked on with @roraback (it will be reused by the WebUI, fyi @rudream). I think this the most important part of the PR, I have tested the terminal in various cases and I think the colors look good, but I would like to hear other's voices.

To test the changes, please manually replace theme.colors in theme.ts with the values from the light theme (also please remember about changing the theme name to light - it is hardcoded in some places, unfortunately).

Patch
diff --git a/web/packages/teleterm/src/ui/ThemeProvider/theme.ts b/web/packages/teleterm/src/ui/ThemeProvider/theme.ts
index 4a89876af2..91337a3716 100644
--- a/web/packages/teleterm/src/ui/ThemeProvider/theme.ts
+++ b/web/packages/teleterm/src/ui/ThemeProvider/theme.ts
@@ -17,13 +17,13 @@ limitations under the License.
 import { fonts } from 'design/theme/fonts';
 import typography, { fontSizes, fontWeights } from 'design/theme/typography';
 import { sharedStyles } from 'design/theme/sharedStyles';
-import { darkTheme } from 'design/theme';
+import { lightTheme } from 'design/theme';
 
 const sansSerif = 'system-ui';
 
 const theme = {
-  name: 'dark',
-  colors: darkTheme.colors,
+  name: 'light',
+  colors: lightTheme.colors,
   typography,
   font: sansSerif,
   fonts: {
@@ -32,8 +32,8 @@ const theme = {
   },
   fontWeights,
   fontSizes,
-  space: darkTheme.space,
-  borders: darkTheme.borders,
+  space: lightTheme.space,
+  borders: lightTheme.borders,
   radii: [0, 2, 4, 8, 16, 9999, '100%'],
   regular: fontWeights.regular,
   bold: fontWeights.bold,

An app setting and the logic that will switch between the themes will be added in another PR.

image image

Btw, I think we should work more on that shadow below the tabs, IMO it was okay on the dark theme, but on the light it looks worse :( I have some ideas, I will send PR after a discussion with the design team.

@gzdunek gzdunek force-pushed the gzdunek/light-theme-adjustments branch from 1708ed5 to a07d55c Compare May 29, 2023 17:23
Copy link
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! 👍

I'm looking forward to the tab bar changes!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input text in file upload path is invisible.

file upload

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this.
I also changed "Drag your files here" border to match the input's border.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the active tab could have a little more contrast. It's rather hard to immediately spot which tab is active on my old full HD monitor.

I think it's sort of related to what you said about the shadow. We could either experiment with the contrast or add another indicator of an active tab.

active tab

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I wanted to solve these two things at once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not relevant to the PR, but on full HD the colors on smaller fonts seem to blur a little bit. This is less visible on the dark theme. Compare the Refresh button in the top right and the table headers.

I don't think it's necessarily the fault of the colors, those fonts could be just bigger.

Light Dark
light theme dark theme

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if this is related to: https://www.electronjs.org/docs/latest/faq#the-font-looks-blurry-what-is-this-and-what-can-i-do
I have not changed the browser window background color, so it still dark. Would like to test it when you have some time with light bg? (I don't have FHD display 😞)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the browser window background is already light since it uses theme.colors.levels.sunken. theme in this context is the light theme since I replaced it whole in the theme provider.

@ravicious
Copy link
Member

I didn't even look at the code, I'll do so tomorrow.

@ravicious ravicious self-requested a review May 30, 2023 15:01
Copy link
Contributor

@avatus avatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find anything else that @ravicious hadn't already pointed out. Looks fine to me

@roraback
Copy link

Not a blocker for merging, but for the tabs, the active tab should ideally merge with the rest of the window like they are part of the same page, sunken slightly below the other tabs. This may be tricky to pull off elegantly in HTML, but if nothing else we could fake it with some clever overlapping of elements to hide the shadow below the active tab and inset shadows to make it look like the tab has shadow falling on it, too.

Copy link
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks fine other than the one hardcoded color.

@@ -50,7 +50,8 @@ export function CliCommand({ cliCommand, onRun, isLoading }: CliCommandProps) {
>
<Flex
mr="2"
color={shouldDisplayIsLoading ? 'text.slightlyMuted' : 'text.main'}
// always use light colors
color={shouldDisplayIsLoading ? 'rgba(255, 255, 255, 0.72)' : 'light'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the hardcoded color? It won't play nice with custom themes that we eventually want to add.

Not sure what are some of the ways we can solve this, perhaps we could manipulate the opacity instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the color modification function to manually add some transparency to the light color.

@ravicious
Copy link
Member

msgcat --color=test output

stable dark theme new dark theme light theme
stable1 new dark 1 light1
stable2 new dark 2 light2

It looks like the new dark theme has rather row contrast between different text colors and the background colors compared to the current stable version.

@gzdunek
Copy link
Contributor Author

gzdunek commented May 31, 2023

The reason for that low contrast between different colors when colored background is used is the option minimumContrastRatio: 4.5 set in xterm. Without it, some of the combinations wouldn't be legible.
When you try that command in vscode you will get almost the same result, because it sets that option to 4.5 as well.

I'm not a heavy terminal user, but tbh I have not seen combinations like green on blue in a real use. Usually, when some background color is set, the foreground is black or white. But even if such combination is used, it seems to me that the readability of the text is more important than its color, right?

The only thing that I don't understand is black color in Colors (background) mixed with attributes: section (cell B2). Why the text doesn't have more contrast? It should have because of that option 🤔

@ravicious
Copy link
Member

I see, in that case only the black and white backgrounds seem out of place. Is it maybe because xterm doesn't recognize the default color of the background properly? So when minimumContrastRatio kicks in, it compares the color against a wrong background, that's why the light theme uses gray for a white background.

Also, do you know why VSCode supports hue & saturation and we don't?

@ravicious
Copy link
Member

Not a blocker for merging, but for the tabs, the active tab should ideally merge with the rest of the window like they are part of the same page, sunken slightly below the other tabs. This may be tricky to pull off elegantly in HTML, but if nothing else we could fake it with some clever overlapping of elements to hide the shadow below the active tab and inset shadows to make it look like the tab has shadow falling on it, too.

I suggested this back when we were adding that shadow to the top bar (#24883 (comment)) after Grzegorz pointed out the problem with the new colors (#24883 (comment)).

Grzegorz tried to make it work back then but it still required a few touch ups and IIRC we didn't have that much time back then to focus on the details.

image(1)

@gzdunek
Copy link
Contributor Author

gzdunek commented Jun 1, 2023

Yeah, it looks like xterm incorrectly calculates final color when semitransparent background is used. I prepared a comparison of how different combinations look like together. By alpha colors I mean that black, brightBlack, white and brightWhite have an alpha channel. no-alpha colors were prepared by using lighten function:

brightWhite: lighten('#0C143D', 0.89),
white: lighten('#0C143D', 0.78),
brightBlack: lighten('#0C143D', 0.61),
black: lighten('#0C143D', 0.46),
alpha colors, no min contrast alpha colors & min contrast 4.5 no-alpha colors & min contrast=4.5
stable1 new dark 1 light1
stable2 new dark 2 light2

Looks like the third options is the most legible one, I only miss the colors on a black background (cell C1) - they all look the same, it looks better in B1 :/

Also, do you know why VSCode supports hue & saturation and we don't?

Yes, I've just discovered it.
We have to change terminal name from name: 'xterm-color', to name: 'xterm-256color'. We can also set 'COLORTERM': 'truecolor' env var:
image
I think it requires testing on Windows, vscode doesn't use it there https://github.com/microsoft/vscode/blob/bfcb70bd09d53c99e9cfcf1e5072e8c165595628/src/vs/platform/terminal/node/terminalProcess.ts#L154

@ravicious
Copy link
Member

I agree that the third column looks best. I think we could go with this for now and leave the hue & saturation stuff for later.

The colors on black background would probably look better if it was actually black and not grey but that's up to Kenny I guess. 😏

@gzdunek
Copy link
Contributor Author

gzdunek commented Jun 2, 2023

Right, the colors look good when black is #000.

A summary for @roraback:

  • We have to covert colors with an alpha channel to be non-transparent. It turned out that minimumContrastRatio sometimes doesn't work well with transparency. We have utility functions in code (lighten, darken) that can do it for us, so that's easy.
    I will use different "base" color for WebUI and Connect as they have different terminal background in the dark theme. For example:
Connect:
brightBlack: lighten('#0C143D', 0.61)

WebUI:
brightBlack: lighten('#010B1C', 0.61)
  • Color "black" should be "black" as Rafał wrote (vscode also uses this value). But please remember, it is fully black only when used as a background (when used as a foreground, the color is modified by minimumContrastRatio):
image

image

@roraback
Copy link

roraback commented Jun 2, 2023

Codifying Slack DM discussion: although Connect and the Web UI currently have different CLI background colors, I'd like these to be the same going forward; ideally Connect and the web UI will only differ when there's a functional reason for them to do so. In the design system in Figma, I set up all of the contrast ratios to work with the darkest blue background: #0c143d and the darkest off-white background, #e6e9ea. It is not a blocker for this PR, though—the web UI and Connect already have different background colors for the terminal theme, so it isn't a regression.

@gzdunek gzdunek added this pull request to the merge queue Jun 5, 2023
Merged via the queue into master with commit ed2bb4b Jun 5, 2023
20 checks passed
@gzdunek gzdunek deleted the gzdunek/light-theme-adjustments branch June 5, 2023 13:19
@public-teleport-github-review-bot

@gzdunek See the table below for backport results.

Branch Result
branch/v13 Create PR

gzdunek added a commit that referenced this pull request Jun 26, 2023
* Adjust Connect to light theme

* Remove `clusters/*` element

* Add terminal colors

* Remove warning about using `false` as `color`

* Add custom styling for `Toggle`

* Fix light theme for file transfer, use the same border color for the drop area as for the input

* Do not hardcode color in `CliCommand`

* Use #000 as black

* Convert rgba colors to be non-opaque

* Fix two slightly incorrect colors

(cherry picked from commit 1220470)
github-merge-queue bot pushed a commit that referenced this pull request Jun 28, 2023
* Connect: Adjust to the light theme (#27080)

* Adjust Connect to light theme

* Remove `clusters/*` element

* Add terminal colors

* Remove warning about using `false` as `color`

* Add custom styling for `Toggle`

* Fix light theme for file transfer, use the same border color for the drop area as for the input

* Do not hardcode color in `CliCommand`

* Use #000 as black

* Convert rgba colors to be non-opaque

* Fix two slightly incorrect colors

(cherry picked from commit 1220470)

* Connect: Add theme configuration (#27788)

* Add a config item for the theme and adjust Electron's `nativeTheme` based on that

* Listen to theme changes and update the app accordingly

* React to theme changes in teleterm stories

* Rename channel

* Return boolean from handlers

* Do not mock the whole app context in storybook

* Fix linting issue

* Fix typo

(cherry picked from commit 95e6482)

* Connect: Make tabs shadows look better (#27931)

* Add bottom shadow for inactive tabs and inset for the active one

* Add shadow for new tab item by using common styling

* Adjust `KeyboardShortcutsPanel` to the light theme

* Center Servers/Databases/Kubes navbar vertically between tabs and table by using the same margin values (8px)

* Set title on the element that is dragged

(cherry picked from commit 1220470)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants