mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Button pour monter en haut de la page d'éditeur de quiz
This commit is contained in:
parent
a7e65d4095
commit
d18c2c502a
1 changed files with 45 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
// EditorQuiz.tsx
|
// EditorQuiz.tsx
|
||||||
import React, { useState, useEffect, useRef } from 'react';
|
import React, { useState, useEffect, useRef, CSSProperties } from 'react';
|
||||||
import { useParams, useNavigate } from 'react-router-dom';
|
import { useParams, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { FolderType } from '../../../Types/FolderType';
|
import { FolderType } from '../../../Types/FolderType';
|
||||||
|
|
@ -40,6 +40,26 @@ const QuizForm: React.FC = () => {
|
||||||
};
|
};
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
|
const [showScrollButton, setShowScrollButton] = useState(false);
|
||||||
|
|
||||||
|
const scrollToTop = () => {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleScroll = () => {
|
||||||
|
if (window.scrollY > 300) {
|
||||||
|
setShowScrollButton(true);
|
||||||
|
} else {
|
||||||
|
setShowScrollButton(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('scroll', handleScroll);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('scroll', handleScroll);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
|
|
@ -292,8 +312,32 @@ const QuizForm: React.FC = () => {
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{showScrollButton && (
|
||||||
|
<Button
|
||||||
|
onClick={scrollToTop}
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={scrollToTopButtonStyle}
|
||||||
|
title="Scroll to top"
|
||||||
|
>
|
||||||
|
↑
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const scrollToTopButtonStyle: CSSProperties = {
|
||||||
|
position: 'fixed',
|
||||||
|
bottom: '40px',
|
||||||
|
right: '50px',
|
||||||
|
padding: '10px',
|
||||||
|
fontSize: '16px',
|
||||||
|
color: 'white',
|
||||||
|
backgroundColor: '#5271ff',
|
||||||
|
border: 'none',
|
||||||
|
cursor: 'pointer',
|
||||||
|
zIndex: 1000,
|
||||||
|
};
|
||||||
|
|
||||||
export default QuizForm;
|
export default QuizForm;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue