Skip to content

Commit 6f8d702

Browse files
committed
New: fontFeatureSettings.tnum
1 parent 38a1fa7 commit 6f8d702

6 files changed

Lines changed: 65 additions & 4 deletions

File tree

js/src/test/scala/com/thirdparty/defs/styles/StyleProps.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ trait StyleProps {
137137
protected def floatStyle(key: String): StyleProp[String] with s.Float =
138138
new StyleProp[String](key) with s.Float
139139

140+
protected def fontFeatureSettings(key: String): StyleProp[String] with s.FontFeatureSettings =
141+
new StyleProp[String](key) with s.FontFeatureSettings
142+
140143
protected def fontSizeStyle(key: String): StyleProp[String] with s.FontSize =
141144
new StyleProp[String](key) with s.FontSize
142145

@@ -1117,7 +1120,7 @@ trait StyleProps {
11171120
*
11181121
* [[https://developer.mozilla.org/en-US/docs/Web/CSS/font-feature-settings font-feature-settings @ MDN]]
11191122
*/
1120-
lazy val fontFeatureSettings: StyleProp[String] = stringStyle("font-feature-settings")
1123+
lazy val fontFeatureSettings: StyleProp[String] with s.FontFeatureSettings = fontFeatureSettings("font-feature-settings")
11211124

11221125

11231126
/**
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.thirdparty.defs.styles.traits
2+
3+
import com.thirdparty.keys.StyleProp
4+
import com.thirdparty.setters.StyleSetter
5+
6+
// #NOTE: GENERATED CODE
7+
// - This file is generated at compile time from the data in Scala DOM Types
8+
// - See `GeneratorSpec.scala` for code generation params
9+
// - Contribute to https://github.com/raquo/scala-dom-types to add missing tags / attrs / props / etc.
10+
11+
trait FontFeatureSettings extends Normal[String] { this: StyleProp[String] =>
12+
13+
/** Render fractions as literals (e.g. ½, ¾) */
14+
lazy val frac: StyleSetter[String, String] = this := "\"frac\""
15+
16+
/** Render tabular numerals: all digit characters will have the same width */
17+
lazy val tnum: StyleSetter[String, String] = this := "\"tnum\""
18+
19+
/** Render zero characters as slashed (Ø) */
20+
lazy val zero: StyleSetter[String, String] = this := "\"zero\""
21+
22+
}

shared/src/main/scala/com/raquo/domtypes/codegen/generators/TraitGenerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ abstract class TraitGenerator[Def](format: CodeFormatting) extends SourceGenerat
193193
if (values.isEmpty) {
194194
throw new Exception(s"No ${clue} found for implName `${implName}`")
195195
} else if (values.size > 1) {
196-
throw new Exception(s"Multiple different ${clue}-s found for the same implName: `${implName}` -> (${values.map(_.toString).mkString(", ")})")
196+
throw new Exception(s"Multiple different ${clue}-s found for the same implName: `${implName}` -> (${values.map(_.toString).mkString(", ")}). All of your StylePropDef-s with the same implName (${implName}) must have the exact same list of ${clue}.")
197197
} else {
198198
values.head
199199
}

shared/src/main/scala/com/raquo/domtypes/defs/styles/StyleDefs.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ object StyleDefs {
9292

9393
val floatStyle = "floatStyle"
9494

95+
val fontFeatureSettingsStyle = "fontFeatureSettings"
96+
9597
val fontSizeStyle = "fontSizeStyle"
9698

9799
val fontStyleStyle = "fontStyleStyle"
@@ -151,6 +153,8 @@ object StyleDefs {
151153

152154
val FlexPosition = "FlexPosition"
153155

156+
val FontFeatureSettings = "FontFeatureSettings"
157+
154158
val Line = "Line"
155159

156160
val LineWidth = "LineWidth" // #TODO Unused for now. It's kind of a useless trait.

shared/src/main/scala/com/raquo/domtypes/defs/styles/StylePropDefs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,9 +1511,9 @@ object StylePropDefs {
15111511
scalaName = "fontFeatureSettings",
15121512
domName = "font-feature-settings",
15131513
valueType = valueTypes.String,
1514-
valueTraits = Nil,
1514+
valueTraits = List(valueTraits.FontFeatureSettings),
15151515
valueUnits = Nil,
1516-
implName = implNames.stringStyle,
1516+
implName = implNames.fontFeatureSettingsStyle,
15171517
commentLines = List(
15181518
"The font-feature-settings CSS property allows control over advanced",
15191519
"typographic features in OpenType fonts.",

shared/src/main/scala/com/raquo/domtypes/defs/styles/StyleTraitDefs.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,38 @@ object StyleTraitDefs {
12601260
),
12611261
),
12621262

1263+
StyleTraitDef(
1264+
scalaName = valueTraits.FontFeatureSettings,
1265+
extendsTraits = List(valueTraits.Normal_),
1266+
extendsUnits = Nil,
1267+
keywordDefGroups = OneList(
1268+
StyleKeywordDef(
1269+
scalaName = "frac",
1270+
domName = "\"frac\"",
1271+
commentLines = List(
1272+
"Render fractions as literals (e.g. ½, ¾)"
1273+
),
1274+
docUrls = Nil,
1275+
),
1276+
StyleKeywordDef(
1277+
scalaName = "tnum",
1278+
domName = "\"tnum\"",
1279+
commentLines = List(
1280+
"Render tabular numerals: all digit characters will have the same width"
1281+
),
1282+
docUrls = Nil,
1283+
),
1284+
StyleKeywordDef(
1285+
scalaName = "zero",
1286+
domName = "\"zero\"",
1287+
commentLines = List(
1288+
"Render zero characters as slashed (Ø)"
1289+
),
1290+
docUrls = Nil,
1291+
),
1292+
),
1293+
),
1294+
12631295
StyleTraitDef(
12641296
scalaName = valueTraits.FontSize,
12651297
extendsTraits = Nil,

0 commit comments

Comments
 (0)