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

Update code example colours to improve contrast and readability #338

Merged
merged 3 commits into from
Oct 27, 2016

Conversation

edwardhorsford
Copy link
Contributor

@edwardhorsford edwardhorsford commented Oct 26, 2016

What problem does the pull request solve?

This PR adjusts the colours used in example code blocks so that they are each 4.5:1 or greater contrast against the background. This will improve the readability for those who struggle with low contrast.

Demo page with highlighting on many languages. username: syntax password: highlighting

What does it do?

  • Adjust colours used for code elements to contrast compliant colours, using GOV.UK palette where possible (or tints thereof).
  • Prioritises distinctive colours so that different elements can be distinguished.
  • Makes the background lighter and adds a grey border to code examples. This matches other example styles used by elements, and helps distinguish the block now that the background is lighter.
  • Lines of code wrap rather than overflowing.
  • Adjusts which colours are used for different languages to make highlighting more consistent across other languages (other languages not used by elements).

How has this been tested?

  • Has been tested on Chrome 54 and Safari 10 on Mac OS X 10.11.6.
  • Primarily tested with: HTML, SCSS, Javascript.
  • Some testing with: Apache, Bash, C++, Dockerfile, ERB, Handlebars, Java, JSON, Markdown, Nginx, Perl, PHP, Puppet, Python, Ruby, Scala, SQL, Yaml

Screenshots (if appropriate):

HTML Before:
screen shot 2016-10-26 at 17 06 46

HTML After:
screen shot 2016-10-26 at 17 06 55

CSS / SCSS isn't currently used in any examples on Elements, but likely will in future GOV.UK Frontend work.

CSS Before:
screen shot 2016-10-26 at 17 04 38

CSS After:
screen shot 2016-10-26 at 17 52 41

What type of change is it?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Put an x in all the boxes that apply

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

Not done

Highlighting for markdown snippets isn't great - I don't think we have any current cases where it's needed, so haven't done anything to adjust it specifically yet.

word-spacing: normal;
word-break: normal;
// Wrap lines of code rather than overflowing
white-space: pre-wrap; /* css-3 */
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use scss comments consistently please?

// rather than /* so these don't wind up in the compiled css.

@gemmaleigh
Copy link
Contributor

Thanks for all your work on this @edwardhorsford!

- Use variables where they are defined by the govuk_frontend_toolkit
- Use Sass comments
- Each selector in a comma sequence should be on its own single line
@robinwhittleton robinwhittleton merged commit e9743a7 into master Oct 27, 2016
@robinwhittleton robinwhittleton deleted the update_prism_colours branch October 27, 2016 15:26
@smlombardi
Copy link

Any chance you could provide this as a .thTheme file?

@edwardhorsford
Copy link
Contributor Author

@smlombardi Sorry, we don't have it as a theme. The colours used are available in this PR though.

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.

5 participants