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

Highlights use hardcoded rather than theme-responsive colors #195

Closed
krassowski opened this issue Feb 12, 2020 · 8 comments · Fixed by #230 or #231
Closed

Highlights use hardcoded rather than theme-responsive colors #195

krassowski opened this issue Feb 12, 2020 · 8 comments · Fixed by #230 or #231

Comments

@krassowski
Copy link
Member

Description

Screenshot from 2020-02-12 03-38-07

Reproduce

  1. Open an R document (notebook or editor)
  2. Click on a variable
  3. Switch theme to dark
  4. See unreadable text

Expected behavior

Should see the adaptive colour of highlights.

@bollwyvl
Copy link
Collaborator

Yeah, I had noticed that, but didn't want to say anything 😊 , as we have so many other things in the fire.

To exacerbate the issue, the Lab dark/light theme doesn't implicitly impact the codemirror theme, and they can easily conflict (e.g. in a source, change editor theme).

Anyhoo: while it would be fun to do some perceptual analysis stuff, we should probably just hand-build (and screenshot test) against all of the built-in editor themes against (I guess) the most complicated language (I don't know which one uses the most token types).

.cm-s-abcdef {
  --jp-lsp-cm-text-background-color: #123456;
  /* ... */
}
/* ... */
.cm-s-zenburn { 
  /* ... */
  --jp-lsp-cm-text-background-color: #abcdef;
}

.cm-lsp-highlight-Text { background-color: var(--jp-lsp-cm-text-background-color); }
/* ... */

Longer term: I've done a fair amount of stuff in this space with jupyterlab-fonts, and while I definitely do not suggest bringing that in, there might be some useful stuff. For example, if we did have the jss opinion, it might play well with the to-be configuration system, as it can be mostly schema-constrained.

@krassowski
Copy link
Member Author

Good point about editor themes being different from the lab themes. I will proceed with a minimal effort solution to fix the bug first and set the editor-specific enhancements for later. But while at it, I will tackle another related issue:

I think that the "fuzzy" highlight which is affected uses blur. It was a nice idea initially (fuzzy - see what I did there?), but I suspect that it causes some lags and slows down the interface (it may also be the sheer number of highlights, though I guess that the blur also adds to the delay). In addition, I do not think that the blur serves its purpose - it looks, well... blurry and it does not really help in the distinction between exact and fuzzy matches.

Instead, I will experiment with a very thin and subtle outline for non-fuzzy matches and no outline (without blur) for fuzzy matches.

I am talking about this:
https://github.com/krassowski/jupyterlab-lsp/blob/f75be86b12c1f408f6d20a637493cb306ca50602/packages/jupyterlab-lsp/style/index.css#L45

@krassowski
Copy link
Member Author

For editor-theme specific styling, I would just hijack an existing class. Nort sure about the CSS preprocessor machinery available in lab, but slight darkening of the line highlight colour (or lightening it in dark themes) would probably work fine.

Then if it wont work for everybody, we could just allow users to override it in settings.

@krassowski krassowski added the good first issue Good for newcomers label Feb 13, 2020
@krassowski
Copy link
Member Author

Actually, this is an easy one I will mark it as a good first issue (available till Sunday).

@bollwyvl
Copy link
Collaborator

bollwyvl commented Feb 13, 2020 via email

@bollwyvl
Copy link
Collaborator

@bollwyvl
Copy link
Collaborator

and here's where the (unchangeable) notebook/console theme get realized:
https://github.com/jupyterlab/jupyterlab/blob/ec5fd3c4d83989b42f77e16caf70558ca4728bbe/packages/codemirror/style/base.css#L145-L222

cm-s-jupyter is really just a special case of cm-s-* (albeit a little different, because it does use variables already), and so I'm still of a mind that hitting them all in one go is the right play, with an eye towards eventual upstreaming.

@bollwyvl
Copy link
Collaborator

bollwyvl commented Feb 14, 2020

Gah, but it's just .cm-s-jupyter, not light and dark. Bu there is a body-level selector:

/* someday, these would live in each theme's variables.css, 
   so we should probably split them already, and just load both
*/
body[data-jp-theme-light="false"] .cm-s-jupyter {
  --jp-editor-mirror-lsp-text-background-color: #123456;
}
body[data-jp-theme-light="true"] .cm-s-jupyter {
   --jp-editor-mirror-lsp-text-background-color: #abcdef;
}
/* it's likely safe to hard-code these, especially if they are overrideable */
.cm-s-abcdef {
   --jp-editor-mirror-lsp-text-background-color: #123456;
  /* ... */
}
/* ... */
.cm-s-zenburn { 
  /* ... */
   --jp-editor-mirror-lsp-text-background-color: #abcdef;
}
/* so this is the final, actual highlight.css */
@import 'variables/cm-themes.css';
@import 'variables/jupyterlab-light.css';
@import 'variables/jupyterlab-dark.css';

.cm-lsp-highlight-Text { 
  background-color: var( --jp-editor-mirror-lsp-text-background-color); 
}
/* ... */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants