Skip to content

feat(color-modes): Add configuration option for printing color mode#1267

Merged
hasparus merged 2 commits into
system-ui:masterfrom
lachlanjc:print
Nov 18, 2020
Merged

feat(color-modes): Add configuration option for printing color mode#1267
hasparus merged 2 commits into
system-ui:masterfrom
lachlanjc:print

Conversation

@lachlanjc

Copy link
Copy Markdown
Member

Closes #1144, adding a configuration option printColorModeName for setting a color mode to be used in @media (print) (so users don’t print out in dark mode). By using the media query & custom properties, there’s no client-side JavaScript event listeners, so it should work even on a static-exported site.

PR includes updated TypeScript type, documentation, & two tests.

@lachlanjc

Copy link
Copy Markdown
Member Author

Looks like the failing tests are unrelated to the changes & have been failing since at least #1249 :/

@hasparus

Copy link
Copy Markdown
Member

Brilliant

@hasparus
hasparus merged commit a9c8e5b into system-ui:master Nov 18, 2020
@hasparus

Copy link
Copy Markdown
Member

Looks like the failing tests are unrelated to the changes & have been failing since at least #1249 :/

Yup, it seems we broke it while fixing the docs build, I'll handle it.

printColorModeName === initialColorModeName
? colors
: modes[printColorModeName]
styles['@media (print)'] = objectToVars('colors', mode)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lachlanjc shouldn't this be @media print? (without parens) I just noticed it doesn't work on Brave/Linux.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, you're totally right. I always forget about that since it's the only media query I use without parentheses

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.

Request for configuration option for color mode on printing

2 participants