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

Colour handling improvements #8702

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Colour handling improvements #8702

wants to merge 12 commits into from

Conversation

Jermolene
Copy link
Member

@Jermolene Jermolene commented Oct 25, 2024

Introduction

We get persistent of feedback that the visual aesthetic of TiddlyWiki is old fashioned and dull. It's fair criticism: the default look and feel was intended to be muted so that the users content took centre stage but has ended up flat and lifeless.

The goal of this PR is to allow end users to easily devise their own colour schemes that match their tastes and work harmoniously together. This will be accomplished with a new user interface that is presented in the empty "GettingStarted" tiddler, and in the control panel. The UI would have sliders and switches for the user to express their taste: colourful vs. muted, dark vs. light, saturated vs. unsaturated.

Underneath those controls would be displayed a grid of 9 random palettes generated to match the parameters. The user can choose one of them and either select it, or choose to use it as the basis to generate further variants.

This PR is highly, dangerously experimental. It may well not be merged in this form, but cherry picked into further PRs.

Dynamic Palette Entries

A key idea is being able to set a palette entry to a base colour with modifications, such as lightening, darkening, or increasing saturation. This allows us to define a small number of hard coded colours, with the others being dynamically generated. This approach is inline with the colour system in Android for example. Thus we need a colour manipulation library that we can use for calculating variants of colours. Only color.js met all my requirements (chiefly being able to work with P3 colours and the OKLCH colour space).

Wikify Operator

To resolve the difficulties that we explored in a recent thread on Talk, I have had to include an implementation of a wikify operator. I regard this as quite controversial because while it unlocks some important capabilities, it also invites users to adopt patterns that can be dangerous.

It is also, as expected, inherently slow. Right now this PR slows the style sheet refresh down by a factor of 2 or 3. If we can't resolve this performance regression we will have to explore alternative approaches.

Colour Palette Preview

Something I've wanted for a long time is to improve the colour palette chooser to include a preview. It is not finished yet, but has turned out to be quite easy and very effective:

image

Progress

  • Added wikify operator with tests
  • Integrated color.js
  • Replace existing core CSS colour parser with the equivalent functionality from color.js
  • Convert colour macro to a function
  • Darken and lighten filter operators with tests
  • Enhanced colour palette preview
  • Extended wikitext test runner to be able to unpack plugins

The replacement library from https://colorjs.io/ is much, much larger but I think we can develop a custom build that uses treeshaking to whittle the code down to the bits that we need. @linonetwo does that sound feasible?

I intend the explore further improvements but I wanted to start by establishing a library that can do modern P3 and OKLCH colour calculations.
Really just syntactic sugar for the wikify widget
Using the new wikify operator.

Currently has a bug whereby redirected colours (like "tiddler-background") do not work. Direct colours like "background" do work.

Note the hacks needed to makeFakeWidgetWithVariables work
Copy link

Confirmed: Jermolene has already signed the Contributor License Agreement (see contributing.md)

@@ -2853,19 +2867,22 @@ a.tc-tiddlylink.tc-plugin-info:hover > .tc-plugin-info-chunk .tc-plugin-info-sta
color: <<colour foreground>>;
}

.tc-chosen > .tc-tiddlylink:before {
Copy link
Member

Choose a reason for hiding this comment

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

IMO we need to keep these configuration for backwards compatibility. We can add a "deprecated" comment, but plugin authors may use these styles.

I'll need to make some more tests, with the palette-manager edition.

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.

3 participants