Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| LightDark | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * CSS Color 5 §5 — `light-dark(<color>, <color>)`. Selects |
| 9 | * `light` when the user agent's preferred color scheme is light |
| 10 | * (or when no `color-scheme` is declared), `dark` otherwise. |
| 11 | * |
| 12 | * color: light-dark(black, white); |
| 13 | * background: light-dark(#fff, #111); |
| 14 | * |
| 15 | * The renderer picks one side at paint time based on the active |
| 16 | * scheme — both branches are preserved here so re-rendering for |
| 17 | * a different scheme is a value-level switch rather than a |
| 18 | * re-cascade. |
| 19 | */ |
| 20 | final readonly class LightDark extends Value |
| 21 | { |
| 22 | public function __construct( |
| 23 | public Value $light, |
| 24 | public Value $dark, |
| 25 | ) {} |
| 26 | |
| 27 | public function toCss(): string |
| 28 | { |
| 29 | return 'light-dark(' . $this->light->toCss() . ', ' . $this->dark->toCss() . ')'; |
| 30 | } |
| 31 | } |