Skip to content

Commit 8af599b

Browse files
committed
fixup! front: update stdcm simulation progress button design
1 parent e8e4f3f commit 8af599b

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const StdcmConfig = ({
7676
const scenarioID = useSelector(getScenarioID);
7777

7878
const pathfinding = useStaticPathfinding(infra);
79+
const formRef = useRef<HTMLDivElement>(null);
7980

8081
const [formErrors, setFormErrors] = useState<StdcmConfigErrors>();
8182

@@ -160,7 +161,7 @@ const StdcmConfig = ({
160161
<StdcmConsist disabled={disabled} />
161162
</div>
162163
<div className="stdcm__separator" />
163-
<div className="stdcm-simulation-itinerary">
164+
<div ref={formRef} className="stdcm-simulation-itinerary">
164165
<StdcmOrigin disabled={disabled} />
165166
<StdcmVias disabled={disabled} />
166167
<StdcmDestination disabled={disabled} />
@@ -201,6 +202,7 @@ const StdcmConfig = ({
201202
<StdcmLoader
202203
cancelStdcmRequest={cancelStdcmRequest}
203204
launchButtonRef={launchButtonRef}
205+
formRef={formRef}
204206
/>
205207
)}
206208
</div>

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

+10-8
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import { useTranslation } from 'react-i18next';
77
import type { LoaderStatus } from '../types';
88

99
const LOADER_HEIGHT = 176;
10-
const LOADER_BOTTOM_OFFSET = 32;
11-
const FORM_TOP_OFFSET = 120 + 68; // navbar + prev path heights
12-
const LAUNCH_BUTTON_HEIGHT = 40;
10+
const LOADER_OFFSET = 32;
1311

1412
type StdcmLoaderProps = {
1513
cancelStdcmRequest: () => void;
1614
launchButtonRef: RefObject<HTMLDivElement>;
15+
formRef: RefObject<HTMLDivElement>;
1716
};
1817

19-
const StdcmLoader = ({ cancelStdcmRequest, launchButtonRef }: StdcmLoaderProps) => {
18+
const StdcmLoader = ({ cancelStdcmRequest, launchButtonRef, formRef }: StdcmLoaderProps) => {
2019
const { t } = useTranslation('stdcm');
2120
const loaderRef = useRef<HTMLDivElement>(null);
2221

@@ -31,13 +30,13 @@ const StdcmLoader = ({ cancelStdcmRequest, launchButtonRef }: StdcmLoaderProps)
3130
useEffect(() => {
3231
// Depending on the scroll, change the position of the loader between fixed, sticky or absolute
3332
const handleScroll = () => {
34-
if (!loaderRef.current || !launchButtonRef.current) return;
33+
if (!loaderRef.current || !launchButtonRef.current || !formRef.current) return;
3534

3635
const { scrollY, innerHeight } = window;
3736

3837
const isLoaderFitting =
3938
innerHeight - launchButtonRef.current.getBoundingClientRect().top >
40-
LOADER_HEIGHT + LOADER_BOTTOM_OFFSET;
39+
LOADER_HEIGHT + LOADER_OFFSET;
4140

4241
// Loader doesn't fit between the bottom of the form and bottom of the viewport
4342
if (!isLoaderFitting) {
@@ -48,9 +47,12 @@ const StdcmLoader = ({ cancelStdcmRequest, launchButtonRef }: StdcmLoaderProps)
4847
return;
4948
}
5049

51-
const currentFormHeight = loaderRef.current.parentElement!.clientHeight;
50+
const currentFormHeight = formRef.current.clientHeight;
51+
const topFormPosition = formRef.current.getBoundingClientRect().top;
52+
const launchButtonHeight = launchButtonRef.current.clientHeight;
5253
const shouldLoaderStickTop =
53-
scrollY > currentFormHeight + FORM_TOP_OFFSET - LAUNCH_BUTTON_HEIGHT;
54+
scrollY >
55+
currentFormHeight + scrollY + topFormPosition - launchButtonHeight - LOADER_OFFSET;
5456

5557
// Loader reaches the top of the screen minus its top offset
5658
if (shouldLoaderStickTop) {

0 commit comments

Comments
 (0)