Add color and palette APIs for Grantlee
ClosedPublic

Authored by vkrause on Aug 30 2019, 3:22 PM.

Details

Summary

This aims at enabling us to do the entire CSS styling via Grantlee, by
providing access to palette colors, by offering color operations and by
allowing to convert colors to CSS compatible strings.

Most of this is fairly straightforward, the ugly one is the colorMix
operator. I didn't find a way to do a two argument filter with both
arguments referencing variables. Therefore it's done as a tag, which means
chaining it to filters requires assigning it to a variable first. And while
color mixing isn't used in the current messagelib CSS generation, it's
heavily used in the Breeze style code (which is what I'm trying to follow
for the itinerary plug-in at least).

This isn't complete, there's more color operations in use in styling
(such as desaturate or tint), and this still misses KColorScheme access.
All that should be doable in a very similar fashion though, as needed.
Using FilterExpression for the two inputs of the colorMix operator might
also be an interesting future extension.

This works with the last Grantlee release, on Grantlee master it fails
without https://github.com/steveire/grantlee/pull/56.

Diff Detail

Repository
R77 PIM: Grantlee Theme
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
vkrause created this revision.Aug 30 2019, 3:22 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptAug 30 2019, 3:22 PM
vkrause requested review of this revision.Aug 30 2019, 3:22 PM
dvratil accepted this revision.Aug 30 2019, 9:57 PM
dvratil added a subscriber: dvratil.

Nice! Good idea!

This revision is now accepted and ready to land.Aug 30 2019, 9:57 PM
vkrause updated this revision to Diff 65257.Sep 2 2019, 4:25 PM

API updates based on feedback from Steve:

  • name -> hexRgb, rbga -> cssRgba
  • support color literals as filter input
vkrause updated this revision to Diff 65259.Sep 2 2019, 4:38 PM

Allow assigning results of the color mixing operations to a variable, which enables chaining it to filters. Based on feedback from Steve.

vkrause edited the summary of this revision. (Show Details)Sep 2 2019, 4:39 PM
This revision was automatically updated to reflect the committed changes.