hfhbd
11/21/2021, 10:56 AMenum
or an interface
with inline functions and unsafeCast
to reduce binary size?turansky
11/21/2021, 11:14 AMhfhbd
11/21/2021, 11:22 AMpublic enum class Color(private val value: String) {
Primary("primary"),
Secondary("secondary"),
Success("success"),
Info("info"),
Warning("warning"),
Danger("danger"),
Light("light"),
Dark("dark")
}
Alternative:
public interface Color {
public companion object Theme {
public inline val Primary: Color get() = Color("primary")
public inline val Secondary: Color get() = Color("secondary")
public inline val Success: Color get() = Color("success")
public inline val Danger: Color get() = Color("danger")
public inline val Warning: Color get() = Color("warning")
public inline val Info: Color get() = Color("info")
public inline val Light: Color get() = Color("light")
public inline val Dark: Color get() = Color("dark")
}
}
public inline fun Color.background(): Color = Color("bg-${unsafeCast<String>()}")
public inline fun Color(value: String): Color = value.unsafeCast<Color>()
the second approach was provided by Oleksandr: https://github.com/JetBrains/compose-jb/pull/859#issuecomment-875737202
but does this really result in smaller code? It's definition is uncommon and not so handy.turansky
11/21/2021, 11:51 AMhfhbd
11/21/2021, 11:54 AMturansky
11/21/2021, 11:55 AMAutoComplete
?hfhbd
11/21/2021, 11:59 AMhfhbd
11/21/2021, 12:01 PMkotlin wrapper
includes some docs from react
. Are all packages without react
in its name safe to use without react? I dont want to include react only for useful! types 🙂turansky
11/21/2021, 12:06 PMcsstype
- common libraryturansky
11/21/2021, 12:07 PMAutoComplete
and all other enums, which emulate string unions are also commonturansky
11/21/2021, 12:07 PMcsstype
can be used as dependency of Composeturansky
11/21/2021, 12:08 PMturansky
11/21/2021, 12:08 PMhfhbd
11/21/2021, 1:00 PMankushg
11/21/2021, 5:51 PMexternal enum class
as a Typescript enum
instead of a Union type?turansky
11/21/2021, 7:23 PM