fix(import): apply the sRGB transfer function to srgb-linear colours and keep alpha - #702
Merged
Merged
Conversation
…and keep alpha A DTCG colour given as components was scaled straight to 0-255, so an srgb-linear colour came out too dark (a linear 0.5 grey became #808080 instead of #bcbcbc), and its alpha was never read, so a translucent colour imported opaque. Linear components now go through the sRGB transfer function, and an alpha below 1 is kept as the fourth pair of an 8-digit hex, also on the hex fallback. Opaque colours stay 6-digit. Fixes #695
Contributor
Quality Report — ConductionNL/thematiq @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-manifest | ✅ | ||||
| test-l10n | ✅ | ||||
| format | ✅ | ||||
| composer | ✅ | ✅ 107/107 | |||
| npm | ✅ | ✅ 2/2 | |||
| app:check-code | ⏭️ | ||||
| info.xml | ✅ | ||||
| REUSE | ✅ | ||||
| lockfile sync | ✅ | ||||
| PHPUnit | ✅ | ||||
| Newman | ✅ | ||||
| Playwright | ⏭️ deferred: E2E runs locally and on the promotion path only. This pull request targets development, so the suite is asked once per promotion into beta and main rather than once per push per open pull request. Run it on any branch from the Actions tab, or locally with npx playwright test. |
||||
| Hydra gates | ✅ |
Quality workflow — 2026-09-28 15:18 UTC
Download the full PDF report from the workflow artifacts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Importing a W3C design tokens file gave the wrong colour for an
srgb-linearcolour and for any colour withalpha.The defect
DesignTokensMapper::serializeColorObject()sentsrgbandsrgb-linearcomponents to the same converter, which scaled each component by 255 without the sRGB transfer function and wrote three channels only. A linear 0.5 grey became#808080instead of about#bcbcbc, andalphawas never read, so a translucent colour imported opaque. Nothing was reported.The tests that were red
In
tests/Unit/Service/DesignTokensMapperTest.php:testSrgbLinearAppliesTransferFunction,testSrgbLinearNearBlackUsesTheLinearSegment,testAlphaKeptAsEightDigitHex,testSrgbLinearWithAlphaandtestAlphaIsAddedToTheHexFallback.testOpaqueColourStaysSixDigitHexguards existing sets.The fix
srgb-linearcomponents go through the CSS Color 4 sRGB transfer function before scaling, including its linear segment near black.alphabelow 1 is kept as the fourth pair of an 8-digit hex, on the components path and on the 6-digithexfallback. An opaque colour stays a 6-digit hex, so existing imports do not change.The other colour spaces and the out-of-gamut reasons in
authoring-dtcg-exporttask 2.2 are not part of this change. The contrast audit and the dark palette do not read 8-digit hex yet; that is #696.Verified
composer check:strict: exit 0 (itstest:allskips in a bare clone, so PHPUnit ran separately).lib/privateon the autoloader: 861 tests, the same 11 errors and 7 failures as on development (missing Symfony and server classes outside a Nextcloud tree).npm run lint,format,test:l10n,check:l10n-js,check:manifest,test:unit: all exit 0.--scope-to-diff: exit 0.Fixes #695