Skip to content

Commit ecc2b93

Browse files
refactor(clerk-js): <Drawer /> animation timing/easing adjustments (#5369)
1 parent 7346d60 commit ecc2b93

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

.changeset/tough-nails-explain.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Adjust the `<Drawer />` enter/exit animations timing and easings.

packages/clerk-js/src/ui/elements/Drawer.tsx

+12-15
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,9 @@ const Overlay = React.forwardRef<HTMLDivElement>((_, ref) => {
164164
position: strategy,
165165
inset: 0,
166166
transitionProperty: 'opacity',
167-
transitionTimingFunction: transitionTiming.slowBezier,
168-
},
169-
duration: {
170-
open: transitionDurationValues.slower,
171-
close: transitionDurationValues.slow,
167+
transitionTimingFunction: transitionTiming.bezier,
172168
},
169+
duration: transitionDurationValues.drawer,
173170
});
174171

175172
if (!isMounted) return null;
@@ -202,19 +199,14 @@ const Content = React.forwardRef<HTMLDivElement, ContentProps>(({ children }, re
202199
const mergedRefs = useMergeRefs([ref, refs.setFloating]);
203200

204201
const { isMounted, styles: transitionStyles } = useTransitionStyles(context, {
205-
initial: { transform: 'translateX(100%)' },
206-
open: { transform: 'translateX(0)' },
207-
close: { transform: 'translateX(100%)' },
202+
initial: { transform: `translate3d(var(--transform-offset), 0, 0)` },
203+
open: { transform: 'translate3d(0, 0, 0)' },
204+
close: { transform: `translate3d(var(--transform-offset), 0, 0)` },
208205
common: {
209206
transitionProperty: 'transform',
210-
transitionTimingFunction: transitionTiming.slowBezier,
207+
transitionTimingFunction: transitionTiming.bezier,
211208
},
212-
duration: isMotionSafe
213-
? {
214-
open: transitionDurationValues.slower,
215-
close: transitionDurationValues.slow,
216-
}
217-
: 0,
209+
duration: isMotionSafe ? transitionDurationValues.drawer : 0,
218210
});
219211

220212
if (!isMounted) return null;
@@ -234,6 +226,11 @@ const Content = React.forwardRef<HTMLDivElement, ContentProps>(({ children }, re
234226
style={transitionStyles}
235227
direction='col'
236228
sx={t => ({
229+
// Apply the conditional right offset + the spread of the
230+
// box shadow to ensure it is fully offscreen before unmounting
231+
'--transform-offset':
232+
strategy === 'fixed' ? `calc(100% + ${t.space.$3} + ${t.space.$8x75})` : `calc(100% + ${t.space.$8x75})`,
233+
willChange: 'transform',
237234
position: strategy,
238235
insetBlock: strategy === 'fixed' ? t.space.$3 : 0,
239236
insetInlineEnd: strategy === 'fixed' ? t.space.$3 : 0,

packages/clerk-js/src/ui/foundations/sizes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const dynamicSpaceUnits = Object.freeze({
2323
'7x5': '1.875rem',
2424
'8': '2rem',
2525
'8x5': '2.125rem',
26+
'8x75': '2.1875rem',
2627
'9': '2.25rem',
2728
'10': '2.5rem',
2829
'12': '3rem',

packages/clerk-js/src/ui/foundations/transitions.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const transitionDurationValues = Object.freeze({
66
focusRing: 200,
77
controls: 100,
88
textField: 450,
9+
drawer: 500,
910
} as const);
1011

1112
const toMs = (value: number) => `${value}ms`;
@@ -24,6 +25,7 @@ const transitionProperty = Object.freeze({
2425
const transitionTiming = Object.freeze({
2526
common: 'ease',
2627
easeOut: 'ease-out',
28+
bezier: 'cubic-bezier(0.32, 0.72, 0, 1)',
2729
slowBezier: 'cubic-bezier(0.16, 1, 0.3, 1)',
2830
} as const);
2931

0 commit comments

Comments
 (0)