Motion time, duration and delay tokens #7669
-
Problemtransition: transform var(--p-duration-200) var(--p-easing-ease) var(--p-duration-50); Today we don't have a token for Documentation on polaris.shopify.com and in VSCode Autocomplete for these values is important. The future solution should be clear to our users that they are linked/unlinked and why we made this decision. We also should make it clear what our users should be thinking about when setting duration and delay values. Whatever our choice it's a reversible decision. It is much easier to consolidate two seperate tokens then split one into two... but it is possible. Proposed approachestransition: transform var(--p-duration-200) var(--p-easing-ease) var(--p-delay-50); New delay token: Seperate transition: transform var(--p-time-200) var(--p-easing-ease) var(--p-time-50); Single time token: Have a single token for |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 14 replies
-
Both seems pretty low risk, but I personally favour distinct token group, like so: transition: transform var(--p-duration-200) var(--p-easing-ease) var(--p-delay-50); transition-duration: var(--p-duration-200);
transition-delay: var(--p-delay-50); Assumptions:
|
Beta Was this translation helpful? Give feedback.
-
Agreed, both approaches are low risk and could be adjusted in the future. I lean towards having a single transition: transform var(--p-time-200) var(--p-ease) var(--p-time-50); because of the following assumptions:
In relation to the last two points, if we had token names that were not value-based, then I'd say having separate tokens could make sense (ex:
Mapping each property to the same token would help utilize the same autocomplete or migration logic and reduce the need to distinguish between delay and duration: simple parsing of shorthand notations, |
Beta Was this translation helpful? Give feedback.
-
Yeah I would also separate the two. I think it is easier to understand what is happening when reading code and allows us more future control. To @samrose3 point:
I think this is something worth looking at for all these tokens. I am usually a fan of this type of naming because it is so much more human and approachable. I also think we make it more difficult because we use numbers in numerous ways:
This makes it even more difficult to know if |
Beta Was this translation helpful? Give feedback.
-
Zooming out. We might over index on this particular problem, but it might expose a higher level need; General guiding principles for all tokens that capture their priorities, constraints, accepted tradeoffs, etc. Having those could both make questions like these easy to agree on and unify the approach to all tokens. Ideal if those priorities were based on real use cases and dev X insight. |
Beta Was this translation helpful? Give feedback.
-
🌶️ Hot takeDon't use tokens at all. Completely remove the current ReasoningDuration / delay isn't semantic on its own
In general, my preference is semantic tokens which convey meaning beyond the absolute value. However, durations and delays on their own have very little meaning (or rather; they're only one small part of the meaning): they must be viewed in context of what property is being transitioned, how much is it being transitioned by, what is it transitioning in contrast to, etc. Semantic tokens like Delay can be relative to durationThere are instances where transitions/animations are stacked (eg; sliding in dot points one after another). When this happens, the delay is relative to the previous animation's duration. In this case, the meaning of a hypothetical The big benefit of semantic tokens is the freedom for us to change the underlaying value without breaking changes across usages of the system. However, in the stacked animations case where there's a Why not just use Eg; if the code looked like this everywhere else: transition: left var(--p-duration-fast) var(--p-delay-slow); But an unwitting developer (or automated migration / lint rule) comes across this: transition: left var(--p-duration-fast) var(--p-duration-slow); It might appear as a mistake, and the second Duration & delay are order-dependentThe CSS spec says when using the transition: left 100ms ease 16ms;
transition: 100ms 16ms ease left;
animation: ease 100ms 16ms left;
animation: reverse 100ms both paused slidein left 16ms, 100ms paused right 16ms ease; Given this restriction, it's always clear which value is duration and which value is delay for a human (who knows that rule, I initially did not), possibly negating the need for a differentiating token. Time is only used for transition/animation(I'm about 90% sure that...) The Real world cases are variedHave a look at the all the uses of duration and delay which do not match one of our existing Alternative ProposalsDo nothingLeave the hard coded Lean on patterns and documentationInstead of codifying these values, lean on documentation and patterns to inform and educate the design/dev/ux folks who are adding transition/animations to their work. Similar to Google's RAIL model. Then let them make their own decisions on timing from there. Components for common animationsSolve for the whole picture of a transition/animation by providing components which bake in a set of standard animations in full control of the property, duration, delay, easing, etc. Making these animation components composable with other components (eg; For the avoidance of doubt: I am not suggesting we add animation props to specific components: // This
<Animate animation="appear">
<Card>hello</Card>
</Animate>
// NOT this
<Card animation="appear>hello</Card> Given the above concerns, the ROI on using tokens might not be worth it for such a subset of usecases. |
Beta Was this translation helpful? Give feedback.
Zooming out. We might over index on this particular problem, but it might expose a higher level need; General guiding principles for all tokens that capture their priorities, constraints, accepted tradeoffs, etc. Having those could both make questions like these easy to agree on and unify the approach to all tokens. Ideal if those priorities were based on real use cases and dev X insight.