element-hq / compound-design-tokens

Compound design tokens

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues with Android tokens output

jmartinesp opened this issue · comments

I found some issues while taking a look at the design tokens generated for Android:

Package declaration

You don't need a closing ; character after the package declaration.

Missing imports

You'll also need these missing imports:

import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight

TextStyles

The current TextStyles declarations have a few issues:

  1. It needs a comma after each parameter.
  2. lineHeight and fontWeight should use sp instead of dp.
  3. fontFamily expects a FontFamily object. If we're using plain "Roboto" we should use Family.Default instead (it'll use the system font, in this case, Roboto). If we want to use a monospace, cursive or sans serif variant there are Family.Monospace, Family.Cursive and Family.SansSerif. If we want to use a custom font we'll need to figure out how to create custom FontFamilyobjects.
  4. Also, it would be great to add some indentation to the parameter lines.

The result should look something like:

val fontBodyMdRegular = TextStyle(
    fontFamily = FontFamily.Default,
    fontWeight = FontWeight.W400,
    lineHeight = 20.sp,
    fontSize = 14.sp,
    letterSpacing = 0.017857.em,
)

Size multipliers

I've seen that some sizes have: val space0_5X = 4.dp * 0.5. The {number}.dp expression generates a Dp object containing a Float value. In Kotlin, 1 can be used to multiply a Float, but 0.5 can't (it's recognised as a Double instead). To make these multipliers work with any number, instead of * 0.5 or * 2, it should be * 0.5f and * 2f, i.e:

val space1_5X = 4.dp * 1.5f
val space20X = 4.dp * 20f