Skip to content

Commit 803027e

Browse files
committed
fixup! front: update stdcm simulation progress button design
1 parent a8bfcca commit 803027e

File tree

5 files changed

+21
-28
lines changed

5 files changed

+21
-28
lines changed

front/src/applications/stdcm/components/StdcmForm/StdcmConfig.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const StdcmConfig = ({
9090
const { top } = launchButtonRef.current.getBoundingClientRect();
9191
const windowHeight = window.innerHeight;
9292
setLoaderStatus({
93-
status: windowHeight - top - 32 > LOADER_HEIGHT ? 'absolute' : 'sticky',
93+
status: windowHeight - top - 32 > LOADER_HEIGHT ? 'absolute' : 'fixedBottom',
9494
firstLaunch: true,
9595
});
9696
}
@@ -197,7 +197,7 @@ const StdcmConfig = ({
197197
<Button
198198
data-testid="launch-simulation-button"
199199
className={cx({
200-
'fade-out': isPending || !showBtnToLaunchSimulation,
200+
'fade-out': !showBtnToLaunchSimulation,
201201
})}
202202
label={t('simulation.getSimulation')}
203203
onClick={startSimulation}

front/src/applications/stdcm/components/StdcmLoader.tsx

+15-16
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,32 @@ const StdcmLoader = ({
3838
innerHeight - launchButtonRef.current.getBoundingClientRect().top >
3939
LOADER_HEIGHT + LOADER_BOTTOM_OFFSET;
4040

41-
if (launchButtonRef.current && isLoaderFitting) {
41+
// Loader doesn't fit between the bottom of the form and bottom of the viewport
42+
if (!isLoaderFitting) {
4243
setLoaderStatus({
4344
firstLaunch: false,
44-
status: 'absolute',
45-
});
46-
} else {
47-
setLoaderStatus({
48-
firstLaunch: false,
49-
status: 'sticky',
45+
status: 'fixedBottom',
5046
});
47+
return;
5148
}
5249

5350
const currentFormHeight = loaderRef.current.parentElement!.clientHeight;
5451
const shouldLoaderStickTop =
5552
scrollY > currentFormHeight + FORM_TOP_OFFSET - LAUNCH_BUTTON_HEIGHT;
5653

54+
// Loader reaches the top of the screen minus its top offset
5755
if (shouldLoaderStickTop) {
5856
setLoaderStatus({
5957
firstLaunch: false,
60-
status: 'fixed',
61-
});
62-
} else if (loaderStatus.status === 'fixed') {
63-
setLoaderStatus({
64-
firstLaunch: false,
65-
status: 'absolute',
58+
status: 'fixedTop',
6659
});
60+
return;
6761
}
62+
63+
setLoaderStatus({
64+
firstLaunch: false,
65+
status: 'absolute',
66+
});
6867
};
6968

7069
window.addEventListener('scroll', handleScroll);
@@ -77,11 +76,11 @@ const StdcmLoader = ({
7776
<div
7877
ref={loaderRef}
7978
className={cx(`stdcm-loader`, {
80-
fixed: loaderStatus.status === 'fixed',
79+
'fixed-top': loaderStatus.status === 'fixedTop',
8180
absolute: loaderStatus.status === 'absolute',
8281
'with-fade-in-animation': loaderStatus.status === 'absolute' && loaderStatus.firstLaunch,
83-
sticky: loaderStatus.status === 'sticky',
84-
'with-slide-animation': loaderStatus.status === 'sticky' && loaderStatus.firstLaunch,
82+
'fixed-bottom': loaderStatus.status === 'fixedBottom',
83+
'with-slide-animation': loaderStatus.status === 'fixedBottom' && loaderStatus.firstLaunch,
8584
})}
8685
>
8786
<div className="stdcm-loader__wrapper">

front/src/applications/stdcm/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,6 @@ export type StdcmLinkedPathResult = {
202202
export type ExtremityPathStepType = 'origin' | 'destination';
203203

204204
export type LoaderStatus = {
205-
status: 'fixed' | 'sticky' | 'absolute';
205+
status: 'fixedBottom' | 'fixedTop' | 'absolute';
206206
firstLaunch: boolean;
207207
};

front/src/applications/stdcm/views/StdcmView.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import useStdcmEnvironment, { NO_CONFIG_FOUND_MSG } from '../hooks/useStdcmEnv';
1818
import useStdcmForm from '../hooks/useStdcmForm';
1919
import type { StdcmSimulation } from '../types';
2020

21-
const LAUNCH_BUTTON_FADEOUT_DURATION = 500;
22-
2321
const StdcmView = () => {
2422
// TODO : refacto. state useStdcm. Maybe we can merge some state together in order to reduce the number of refresh
2523
const currentSimulationInputs = useStdcmForm();
@@ -93,9 +91,7 @@ const StdcmView = () => {
9391

9492
useEffect(() => {
9593
if (isPending && !isDebugMode) {
96-
setTimeout(() => {
97-
setShowBtnToLaunchSimulation(false);
98-
}, LAUNCH_BUTTON_FADEOUT_DURATION);
94+
setShowBtnToLaunchSimulation(false);
9995
}
10096
}, [isPending]);
10197

front/src/styles/scss/applications/stdcm/_loader.scss

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
0 16px 30px -5px rgba(0, 0, 0, 0.16),
1010
0 3px 5px -2px rgba(0, 0, 0, 0.1);
1111

12-
&.sticky {
12+
&.fixed-bottom {
1313
position: fixed;
1414
bottom: 32px;
1515
top: unset;
@@ -28,7 +28,7 @@
2828
}
2929
}
3030

31-
&.fixed {
31+
&.fixed-top {
3232
position: fixed;
3333
top: 32px;
3434
bottom: unset;
@@ -45,8 +45,6 @@
4545

4646
@keyframes slideUp {
4747
0% {
48-
// Le translate ne doit se passer que si la popup ne rentre pas dans l'espace restant
49-
// La map ne doit jamais bouger quand le formulaire grandit ou retrécit ?
5048
transform: translateY(100%);
5149
opacity: 0;
5250
}

0 commit comments

Comments
 (0)