Skip to content

Commit 36b27f0

Browse files
authored
TransactionsScreen tweaks (#847)
- Improve animations - Remove development related code
1 parent 5415a12 commit 36b27f0

File tree

1 file changed

+46
-43
lines changed

1 file changed

+46
-43
lines changed

Diff for: frontend/app/src/screens/TransactionsScreen/TransactionsScreen.tsx

+46-43
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,27 @@ export function TransactionsScreen() {
3737
} = useTransactionFlow();
3838

3939
const isLastStep = flow?.steps && currentStepIndex === flow.steps.length - 1;
40+
const isSuccess = isLastStep && step?.status === "confirmed";
4041

41-
const successMessageTransition = useTransition(isLastStep && step?.status === "confirmed", {
42-
from: { height: 0, opacity: 0, transform: "scale(0.9)" },
43-
enter: { height: 56, opacity: 1, transform: "scale(1)" },
44-
leave: { height: 0, opacity: 0, transform: "scale(1)" },
45-
config: boxTransitionConfig,
42+
const successMessageTransition = useTransition(isSuccess, {
43+
from: {
44+
opacity: 0,
45+
transform: "translateY(24px)",
46+
},
47+
enter: {
48+
opacity: 1,
49+
transform: "translateY(0px)",
50+
delay: 500,
51+
},
52+
leave: {
53+
opacity: 0,
54+
immediate: true,
55+
},
56+
config: {
57+
mass: 1,
58+
tension: 2000,
59+
friction: 120,
60+
},
4661
});
4762

4863
const errorBoxTransition = useTransition(step?.error, {
@@ -144,24 +159,28 @@ export function TransactionsScreen() {
144159
paddingBottom: 32,
145160
})}
146161
>
147-
{successMessageTransition((style, show) => (
148-
show && (
149-
<a.div
150-
style={style}
151-
className={css({
152-
display: "flex",
153-
alignItems: "center",
154-
justifyContent: "center",
155-
height: 56,
156-
whiteSpace: "nowrap",
157-
textAlign: "center",
158-
color: "positive",
159-
})}
160-
>
161-
{flow.request.successMessage}
162-
</a.div>
163-
)
164-
))}
162+
<div
163+
className={css({
164+
display: "flex",
165+
alignItems: "center",
166+
justifyContent: "center",
167+
height: 56,
168+
whiteSpace: "nowrap",
169+
textAlign: "center",
170+
color: "positive",
171+
})}
172+
style={{
173+
marginBottom: flow.steps.length === 1 ? -24 : 0,
174+
}}
175+
>
176+
{successMessageTransition((style, show) => (
177+
show && (
178+
<a.div style={style}>
179+
{flow.request.successMessage}
180+
</a.div>
181+
)
182+
))}
183+
</div>
165184

166185
<FlowSteps
167186
currentStep={currentStepIndex}
@@ -422,18 +441,17 @@ function StepDisc({
422441
mode: StepDiscMode;
423442
secondary: string;
424443
}) {
425-
const [forcedMode, setForcedMode] = useState<StepDiscMode>(mode);
426444
const [showLabel, setShowLabel] = useState(false);
427445

428446
const modeTransition = useTransition(mode, {
429447
initial: { transform: "scale(1)" },
430-
from: { transform: "scale(1.4)" },
448+
from: { transform: "scale(0.5)" },
431449
enter: { transform: "scale(1)" },
432-
leave: { immediate: true },
450+
leave: { opacity: 0, immediate: true },
433451
config: {
434452
mass: 1,
435-
tension: 2000,
436-
friction: 180,
453+
tension: 2400,
454+
friction: 120,
437455
},
438456
});
439457

@@ -451,21 +469,6 @@ function StepDisc({
451469
return (
452470
<div
453471
title={label}
454-
onClick={() => {
455-
const forcedStatuses: StepDiscMode[] = [
456-
"upcoming",
457-
"ready",
458-
"loading",
459-
"success",
460-
"error",
461-
];
462-
const forcedStatus = forcedStatuses[
463-
(forcedStatuses.indexOf(forcedMode) + 1) % forcedStatuses.length
464-
];
465-
if (forcedStatus) {
466-
setForcedMode(forcedStatus);
467-
}
468-
}}
469472
onMouseEnter={() => setShowLabel(true)}
470473
onMouseLeave={() => setShowLabel(false)}
471474
className={css({

0 commit comments

Comments
 (0)