You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ghimpu Lucian Eduard edited this page Nov 21, 2022
·
4 revisions
Extensions
designsystem-utilities provides various extensions and utilities functions as helpers. Usually the utilities functions are attached to the Companion object of a certain type.
Color
fromHex
ℹ️ This an utility method in Color.Companion
Convert a hex value string to a Color
If the conversion fails, fallbackColor will be returned
If hexValue is null, fallbackColor will be returned
If fallbackColor is not provided, Color.White will be returned
// valid valuesval white =Color.fromHex("#ffffff")
val anotherWhite =Color.fromHex("#FFFFFFFF")
// exceptionval exception =Color.fromHex("ffffff")
ifUnspecified
Chain colors values until a color != Color.Unspecified is found.
val color = someColor.ifUnspecified(anotherColor).ifUnspecified(someOthercolor)