From 7b8afd901b39f9a9b263153a4ac108e81b025571 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Mon, 12 Jul 2021 19:35:53 +0200 Subject: [PATCH] Basic support for letter-spacing in CSS API --- .../compose/web/css/properties/font.kt | 9 +++++++++ .../src/jsTest/kotlin/css/CSSFontTests.kt | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/font.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/font.kt index 4b1a43dc3b..5dc0d725de 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/font.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/font.kt @@ -41,4 +41,13 @@ fun StyleBuilder.lineHeight(value: CSSNumeric) { // https://developer.mozilla.org/en-US/docs/Web/CSS/font fun StyleBuilder.font(value: String) { property("font", value) +} + +// https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing +fun StyleBuilder.letterSpacing(value: String) { + property("letter-spacing", value) +} + +fun StyleBuilder.letterSpacing(value: CSSNumeric) { + property("letter-spacing", value) } \ No newline at end of file diff --git a/web/core/src/jsTest/kotlin/css/CSSFontTests.kt b/web/core/src/jsTest/kotlin/css/CSSFontTests.kt index c96bdc89e5..78534b041b 100644 --- a/web/core/src/jsTest/kotlin/css/CSSFontTests.kt +++ b/web/core/src/jsTest/kotlin/css/CSSFontTests.kt @@ -104,6 +104,25 @@ class CSSFontTests { assertEquals("2em", (root.children[1] as HTMLElement).style.lineHeight) } + @Test + fun letterSpacing() = runTest { + composition { + Div({ + style { + letterSpacing("normal") + } + }) + Div({ + style { + letterSpacing(2.em) + } + }) + } + + assertEquals("normal", (root.children[0] as HTMLElement).style.letterSpacing) + assertEquals("2em", (root.children[1] as HTMLElement).style.letterSpacing) + } + @Test fun fontFamily() = runTest { composition {