-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
feat: add combined styles and inbuilt syntax highlighting themes in the REPL #2341
Conversation
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
@Snehil-Shah How did you access accessibility compliance? |
@kgryte I should have clarified, just visually looking at, if it's clearly visible or not. If there's a way to assess accessibility, let me know.. |
I suppose one comment regarding the styles is that, for themes such as solarized and monokai, in IDEs, this also sets the application background. For example, in SublimeText, if you set monokai, the IDE background is not fully black. For solarized, there is a similar background adjustment. Here, it's just the tokens. |
Yes, one should use color contrast checkers, such as https://webaim.org/resources/contrastchecker/. |
@kgryte Yes, but tmk there isn't a way to do that in terminal environments, so I just tried to match the token colors through visual judgement for monokai and solarized themes.. |
Ideally, themes have full AAA compliance, but this may not always be possible, especially if a theme has many colors. In which case, some colors having AA compliance is okay. |
@kgryte As mentioned in the OP, that's the problem, generic ANSI color names don't have a fixed hex code attached AFAIK, so it depends on the terminal emulator on how they are rendering these colors. On my terminals, the current themes look fine.. but not sure if that's true for other emulators. |
Re: background. Yeah, you are correct. Seems no real portable way to do this (e.g., https://unix.stackexchange.com/questions/474502/how-to-set-the-background-color-of-the-linux-console-screen). Up to a user to cycle through themes to determine which looks "best". On that note, maybe we should add commands for easily cycling through themes: |
After playing around with it locally, seems like we need to figure out the terminal color story more broadly in order to craft accessible themes. The limited ANSI color palette doesn't provide enough range. Apart from some of our |
Another command that may be nice for seeing how themes render is to provide something similar to how our |
The sample content would not have to be commands which run. Instead, could be something along the lines of
where the return value is a template which gets filled in with ANSI escape codes. Meaning, instead of actually executing code, the return value is syntax highlighted, as would be the case if entered as commands. var tmpl = [
'{{BEGIN_COMMENT}}// This is a comment...{{END_COMMENT}}',
'{{BEGIN_IDENTIFIER}}var{{END_IDENTIFER}} {{START_VARIABLE}}x{{END_VARIABLE}} = {{BEGIN_LITERAL}}1{{END_LITERAL}};'
// ...
];
// ...
log( repl, render( tmpl, theme ) );
// ... |
|
My suggestion for |
|
Something to that effect. E.g., https://github.com/chalk/chalk/tree/main, https://github.com/termstandard/colors, https://github.com/chalk/supports-color. If a terminal supports additional colors, we should take advantage of this for better theming. This was discussed previously in a prior PR. Ref: #2254 (comment) |
Also, keyboard shortcuts are only a partial solution and will not be guaranteed to be enabled by a user. A command is a lower primitive. A shortcut would ultimately call the command. |
@kgryte hex colors would require terminal color detection, so we can downsample the provided hex colors to 16 ANSI colors if the terminal doesn't support 256 colors. I think we can reserve this to a future PR after we move colors to a standalone package and have a package for terminal color detection. What do you think? Regarding the commands, should I include them in this PR itself? |
Yes, I think all the above for future discussion and PRs. If you wouldn't mind creating issues for those tasks, that would be great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from my question, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me as well.
Let's land it!
…he REPL PR-URL: stdlib-js#2341 --------- Signed-off-by: Snehil Shah <snehilshah.989@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
…he REPL PR-URL: stdlib-js#2341 --------- Signed-off-by: Snehil Shah <snehilshah.989@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Description
This pull request:
bold brightBlue
,italic magenta
are now supported.Related Issues
This pull request:
Questions
One of the challenges is finding out how accessible these themes are across different terminal emulators. How these ANSI colors are rendered depends on the terminal application. In my system, all of the terminal applications render all ANSI colors according to accessibility standards. So it was difficult for me to judge which color is suitable for dark/light backgrounds. If most modern emulators do this then this might be a win for us.
It would be great if you could try out the themes on your terminals and suggest changes that make the themes more accessible.
Other
No.
Checklist
@stdlib-js/reviewers