From 16b5f1845c91b82cce50ffb37020d21741dd5602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6nig?= <50620424+KaiOnGitHub@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:51:43 +0200 Subject: [PATCH 1/5] Add support for dvh, svh, lvh. Close #412 --- src/Value/Size.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Value/Size.php b/src/Value/Size.php index 36a32381..36fc2114 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -17,7 +17,7 @@ class Size extends PrimitiveValue * * @var array */ - const ABSOLUTE_SIZE_UNITS = ['px', 'cm', 'mm', 'mozmm', 'in', 'pt', 'pc', 'vh', 'vw', 'vmin', 'vmax', 'rem']; + const ABSOLUTE_SIZE_UNITS = ['px', 'cm', 'mm', 'mozmm', 'in', 'pt', 'pc', 'vh', 'dvh', 'svh', 'lvh', 'vw', 'vmin', 'vmax', 'rem']; /** * @var array From bc058a4f114f2cb757181176ad8364320b6f6863 Mon Sep 17 00:00:00 2001 From: Kai Koenig Date: Wed, 2 Aug 2023 16:55:11 +0200 Subject: [PATCH 2/5] fix 120 char per line limit --- src/Value/Size.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Value/Size.php b/src/Value/Size.php index 36fc2114..fdface79 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -17,7 +17,9 @@ class Size extends PrimitiveValue * * @var array */ - const ABSOLUTE_SIZE_UNITS = ['px', 'cm', 'mm', 'mozmm', 'in', 'pt', 'pc', 'vh', 'dvh', 'svh', 'lvh', 'vw', 'vmin', 'vmax', 'rem']; + const ABSOLUTE_SIZE_UNITS = [ + 'px', 'cm', 'mm', 'mozmm', 'in', 'pt', 'pc', 'vh', 'dvh', 'svh', 'lvh', 'vw', 'vmin', 'vmax', 'rem' + ]; /** * @var array From 2d1b071fcf32a84eb8e354ab23f24691711f5c61 Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Sat, 17 Feb 2024 00:27:03 +0000 Subject: [PATCH 3/5] Add `TestCase` and changelog entry For now, the `TestCase` just tests that all the unit values are parsed. (Other tests can be added here, but are beyond the scope of this change.) --- CHANGELOG.md | 1 + tests/Value/SizeTest.php | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 tests/Value/SizeTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 74ca75e2..77ce3dfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Added +- Support `dvh`, `lvh` and `svh` length units (#415) - Add more tests (#449) ### Changed diff --git a/tests/Value/SizeTest.php b/tests/Value/SizeTest.php new file mode 100644 index 00000000..27facc78 --- /dev/null +++ b/tests/Value/SizeTest.php @@ -0,0 +1,51 @@ + + */ + public static function provideUnit(): array + { + $units = [ + 'px', 'pt', 'pc', + 'cm', 'mm', 'mozmm', 'in', + 'vh', 'dvh', 'svh', 'lvh', + 'vw', 'vmin', 'vmax', 'rem', + '%', 'em', 'ex', 'ch', 'fr', + 'deg', 'grad', 'rad', 's', 'ms', 'turn', 'Hz', 'kHz', + ]; + + return \array_combine( + $units, + \array_map( + function (string $unit): array { + return [$unit]; + }, + $units + ) + ); + } + + /** + * @test + * + * @dataProvider provideUnit + */ + public function parsesUnit(string $unit) + { + $subject = Size::parse(new ParserState('1' . $unit, Settings::create())); + + self::assertSame($unit, $subject->getUnit()); + } +} From 7e6ffdfdb37d48f30506132951979656bc041317 Mon Sep 17 00:00:00 2001 From: JakeQZ Date: Sat, 17 Feb 2024 13:12:04 +0000 Subject: [PATCH 4/5] Add `void` return type hint for `parsesUnit`. Co-authored-by: Oliver Klee --- tests/Value/SizeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Value/SizeTest.php b/tests/Value/SizeTest.php index 27facc78..3aecce05 100644 --- a/tests/Value/SizeTest.php +++ b/tests/Value/SizeTest.php @@ -42,7 +42,7 @@ function (string $unit): array { * * @dataProvider provideUnit */ - public function parsesUnit(string $unit) + public function parsesUnit(string $unit): void { $subject = Size::parse(new ParserState('1' . $unit, Settings::create())); From 04b92ea9031262b26194992d3060d709d8a71091 Mon Sep 17 00:00:00 2001 From: JakeQZ Date: Sat, 17 Feb 2024 13:14:39 +0000 Subject: [PATCH 5/5] Reword CHANGELOG entry. Co-authored-by: Oliver Klee --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77ce3dfd..60e1e140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Added -- Support `dvh`, `lvh` and `svh` length units (#415) +- Add support for the `dvh`, `lvh` and `svh` length units (#415) - Add more tests (#449) ### Changed