Skip to content

Commit 2622b4e

Browse files
committed
syntax and media queries
1 parent 1e727ec commit 2622b4e

File tree

15 files changed

+1436
-1415
lines changed

15 files changed

+1436
-1415
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
.backToTop {
2-
position: fixed;
3-
right: 10px;
4-
bottom: 60px;
5-
height: 30px;
6-
font-size: 3rem;
7-
z-index: 999;
2+
position: fixed;
3+
right: 10px;
4+
bottom: 60px;
5+
height: 30px;
6+
font-size: 3rem;
7+
z-index: 999;
88
}
99

1010
.backToTop button {
11-
outline: none;
12-
border: none;
13-
cursor: pointer;
14-
background: none;
15-
padding: 20px;
11+
outline: none;
12+
border: none;
13+
cursor: pointer;
14+
background: none;
15+
padding: 20px;
1616
}
1717

1818
@media screen and (max-width: 800px) {
19-
.backToTop {
20-
right: -10px;
21-
bottom: 50px;
22-
font-size: 2.75rem;
23-
}
19+
.backToTop {
20+
right: -10px;
21+
bottom: 50px;
22+
font-size: 2.75rem;
23+
}
2424
}

src/components/BackToTop/BackToTop.js

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,47 @@ import { ThemeContext } from '../../contexts/ThemeContext';
66
import './BackToTop.css';
77

88
function BackToTop() {
9-
const [visible, setVisible] = useState(false);
10-
11-
const { theme } = useContext(ThemeContext);
12-
13-
const toggleVisible = () => {
14-
const scrolled = document.documentElement.scrollTop;
15-
if (scrolled > 300) {
16-
setVisible(true);
17-
} else if (scrolled <= 300) {
18-
setVisible(false);
19-
}
20-
};
21-
22-
const scrollToTop = () => {
23-
window.scrollTo({
24-
top: 0,
25-
behavior: 'smooth',
26-
});
27-
};
28-
29-
window.addEventListener('scroll', toggleVisible);
30-
31-
const useStyles = makeStyles(() => ({
32-
icon: {
33-
fontSize: '3rem',
34-
color: theme.tertiary,
35-
},
36-
}));
37-
38-
const classes = useStyles();
39-
40-
return (
41-
<div
42-
style={{ display: visible ? 'inline' : 'none' }}
43-
className='backToTop'
44-
>
45-
<button onClick={scrollToTop} aria-label='Back to top'>
46-
<IoIosArrowDropupCircle className={classes.icon} />
47-
</button>
48-
</div>
49-
);
9+
const [visible, setVisible] = useState(false);
10+
11+
const { theme } = useContext(ThemeContext);
12+
13+
const toggleVisible = () => {
14+
const scrolled = document.documentElement.scrollTop;
15+
if (scrolled > 300) {
16+
setVisible(true);
17+
} else if (scrolled <= 300) {
18+
setVisible(false);
19+
}
20+
};
21+
22+
const scrollToTop = () => {
23+
window.scrollTo({
24+
top: 0,
25+
behavior: 'smooth',
26+
});
27+
};
28+
29+
window.addEventListener('scroll', toggleVisible);
30+
31+
const useStyles = makeStyles(() => ({
32+
icon: {
33+
fontSize: '3rem',
34+
color: theme.tertiary,
35+
},
36+
}));
37+
38+
const classes = useStyles();
39+
40+
return (
41+
<div
42+
style={{ display: visible ? 'inline' : 'none' }}
43+
className='backToTop'
44+
>
45+
<button onClick={scrollToTop} aria-label='Back to top'>
46+
<IoIosArrowDropupCircle className={classes.icon} />
47+
</button>
48+
</div>
49+
);
5050
}
5151

5252
export default BackToTop;

0 commit comments

Comments
 (0)