Skip to content

Theming improvements#163

Merged
JayPanoz merged 17 commits into
developfrom
theming-improvements
Jan 9, 2025
Merged

Theming improvements#163
JayPanoz merged 17 commits into
developfrom
theming-improvements

Conversation

@JayPanoz
Copy link
Copy Markdown
Collaborator

@JayPanoz JayPanoz commented Dec 17, 2024

Exposing these modifications early so that people have time to check and review while I stress-test them in Readium Playground.

Please check if the PR fulfills these requirements:

(Add x between brackets to check.)

  • I’ve read contributing guidelines
  • I’m making this pull request against the develop branch
  • I’ve updated from the develop branch before proposing this pull request
  • I’ve tested the changes for bug fixes and/or features
  • I’ve documented new code

What kind of change does this PR introduce? (Bug fix, feature, docs update, other)

This resolves #159 and closes #160.

To recap:

  • it enforces link (normal and visited) and ::selection (background and text) if they are set on :root using their --RS__-prefixed dedicated custom properties/variables;
  • it exposes image filters as user settings with presets so that they can be reusable at consumers’ discretion, and no longer scoped to their reading mode (sepia or night);
  • it modifies the custom colors submodule (user setting) and will only filter text color for links – previously it filtered headings and preformatted text.

What is the current behaviour? (You can also link to an open issue here)

Currently you have to build upon sepia or night mode, and override all their colors if you want to benefit from their specific features.

The motivation is to make it easier for developers to build custom theme w/o having to rely on ReadiumCSS’ modes and introduce an extra layer of abstraction/cascade.

What is the new behaviour?

When set, ReadiumCSS will apply the styles, no matter the current reading mode (day, sepia, night).

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Not that I am aware of. Older preset flags have been kept in the new imageFilters submodule to avoid breaking changes so value readium-invert-on for instance, should continue to work if your app has been implementing the invert filter for images in night mode. The differences are:

  • you no longer need to apply night mode to apply the filter;
  • you can now also set a percentage (in order to match your background-color).

Does not apply to enforcing colors in the theming submodule as this change should be considered a fix.

Other information:

If you are dealing with Japanese books containing gaiji, you’ll need to handle that manually when applying a dark theme since it can’t be automated from CSS. It will still work in night mode though, so no need to add it if you are using this reading mode through --USER__appearance: readium-night-on.

For theming and filters + remove smartphone viewport since we don’t need to test MQ/breakpoints anymore.
There are way too many occurrences where a colored heading may become illegible because it doesn’t offer enough contrast with the background-color, so let’s only protect pre and not try to be too smart.
@JayPanoz JayPanoz marked this pull request as ready for review January 9, 2025 08:39
@JayPanoz
Copy link
Copy Markdown
Collaborator Author

JayPanoz commented Jan 9, 2025

This has been successfully deployed on Readium Playground and has significant improvements that should make life easier for implementers.

Here’s the closed PR if you want to take a look and see how you can benefit from these changes.

@JayPanoz JayPanoz merged commit 7e341c2 into develop Jan 9, 2025
@JayPanoz JayPanoz deleted the theming-improvements branch January 9, 2025 08:49
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.

Blending, darkening, and inverting settings should be global There is nothing to enforce link colors when using a custom theme

1 participant