-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Problem Statement
Rainbow Sprinkles currently doesn't accept style objects as values when defining dynamicProperties.
This could be useful when using complex CSS properties like transform, which lets you rotate, scale, skew, or translate an element.
The only way at the moment to rotate or translate an element with Rainbow Sprinkles is to define the transform property with dynamic values as follows:
const properties = defineProperties({
dynamicProperties: {
transform: true,
},
});
const rainbowSprinkles(properties);Which forces you to dynamically construct the full transformation value, when only the length value could be provided
rainbowSprinkles({
transform: `translateX(${length})`
});This also means you have to manually handle in JS things like rtl direction, while this could be automated 😞
rainbowSprinkles({
transform: `translateX(calc(${length} * ${transformDirection}))`
});Proposed Solution
As with regular Sprinkles properties, it would be great if the values could be entire style objects. This would make for even more powerful classes.
const properties = defineProperties({
dynamicProperties: {
translateX: {
transform: `translateX(${true})`, // true being the placeholder for the dynamic value
selectors: {
'[dir="rtl"] &': {
transform: `translateX(${calc.negate(true)})`,
}
}
},
}
});Which would automatically produce the following classes
.rainbowSprinkles_translateX__16s97g72c {
transform: translateX(var(--translateX__16s97g728));
}
[dir="rtl"] .rainbowSprinkles_translateX__16s97g72c {
transform: translateX(calc(var(--translateX__16s97g728)) * -1)),
}