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

add a "colors off" button to code sections #2100

Closed
wants to merge 1 commit into from

Conversation

timo
Copy link
Contributor

@timo timo commented Jun 15, 2018

for people who can't stand syntax highlighting
for any reason.

It will remember the choice in sessionStorage, just like
debug mode, and will remove colors on page load if the
setting was turned on. Restoring colors is also possible
by just clicking the button again.

It'd be nice if someone with battle-tested JS knowledge could check if there's something wrong with the code, for example for older browsers.

for people who can't stand syntax highlighting
for any reason.

It will remember the choice in sessionStorage, just like
debug mode, and will remove colors on page load if the
setting was turned on. Restoring colors is also possible
by just clicking the button again.
@timo
Copy link
Contributor Author

timo commented Jun 15, 2018

Also, the button could be styled to fit in better, both in terms of looks and positioning.

@zoffixznet
Copy link
Contributor

zoffixznet commented Jun 15, 2018

FWIW, we have jQuery on the site, so stuff like

        const buttonDiv = document.createElement("DIV");
        const button    = document.createElement("BUTTON");
        const text      = document.createTextNode("colors " + colorsAre);
        buttonDiv.style.float = "right";
        button.appendChild(text);
        buttonDiv.appendChild(button);
        editor.insertAdjacentElement("afterBegin", buttonDiv);

Can be written simply as

$(editor).prepend( 
  $('<div><button>colors ' + colorsAre + '</button></div>')
    .css({'float': 'right'})
);

Or even sans-div:

$(editor).prepend( $('<button/>').text('colors ' + colorsAre).css({'float': 'right'}) );

@AlexDaniel
Copy link
Member

AlexDaniel commented Jun 15, 2018

I'm 👎 on this. I don't think syntax highlighting can hurt, and those who religiously (or maybe even if for a good reason) can't stand it are much better off with a userscript that will unhighlight code blocks on all web pages (not just docs.perl6.org).

@zoffixznet
Copy link
Contributor

people who can't stand syntax highlighting

Is there really a large number of users who'd find this feature useful? Feels like featuritis to me and those who are strongly bothered by the colors can add a single line of CSS to their user sheet.

@rafaelschipiura
Copy link
Contributor

I think it's useful because it increases contrast by removing the colors and that's an important accessibility feature.

@AlexDaniel
Copy link
Member

There were problems with contrast in the past (#1084), please file a ticket if that is still an issue.

But accessibility is not an argument for a toggle like this. Firefox has a built-in “reader mode” which does that already:

screenshot of a reader mode

It's fully a thing for user agents and we shouldn't be inventing our own.

@JJ
Copy link
Contributor

JJ commented Jun 16, 2018

If this was an issue, I would probably be against. But it's a pull request, so he's bothered enough to put some work into it. So I'm not in principle against, but I have a couple of issues

  • First, it should really be tested for different browsers. We don't do that in Travis, so it's better if that's done in advance.
  • I would also like to see a sample of how it displays, i. e., it's not confusing, it's not hiding part of the code, things like that. I mean, how usable is it.

On the other hand, come to think of it, a PR that does not really solve any issue is not such a good idea. I'm kind of with @AlexDaniel here. Let's not invent our own stuff. We can add some instructions somewhere if people really want to turn colors off, but that would be it (and whoever is annoyed by colors probably knows how to do it already...)

@zoffixznet
Copy link
Contributor

So... what's the verdict? ping @timo

@AlexDaniel
Copy link
Member

So... what's the verdict? ping @timo

I think we can close this. Maybe it'd make sense to have a short section somewhere titled “how to read these docs” and there we can explain how this can be done locally, but I'm not sure if it's worth it. Also, if current syntax highlighting is too colorful or has too low contrast, then we can tweak it (please open an issue or a PR).

@AlexDaniel AlexDaniel closed this Jun 30, 2018
@zoffixznet zoffixznet deleted the toggle-able-syntax-highlighting branch June 30, 2018 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants