Skip to content

Commit 91a9449

Browse files
committed
Keep scroll-to-top styling inline with designs
1 parent d230739 commit 91a9449

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

src/app/components/site/ScrollToTop.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useCallback, useEffect } from "react";
22
import classNames from "classnames";
3+
import { siteSpecific } from "../../services";
4+
import { Button } from "reactstrap";
35

46
export const ScrollToTop = ({mainContent}: {mainContent: React.MutableRefObject<HTMLElement | null>}) => {
57
const [sticky, setSticky] = React.useState(false);
@@ -15,10 +17,24 @@ export const ScrollToTop = ({mainContent}: {mainContent: React.MutableRefObject<
1517
};
1618
}, [isSticky]);
1719

18-
return <button
19-
onClick={() => mainContent.current?.scrollIntoView({behavior: 'smooth'})}
20-
className={classNames("scroll-btn d-print-none", {"is-sticky": sticky})}
21-
>
22-
<img src="/assets/common/icons/chevron-up.svg" alt="Scroll to top of page"/>
23-
</button>;
24-
};
20+
return siteSpecific(
21+
<Button
22+
color="keyline"
23+
className={classNames("scroll-btn d-print-none p-2", {"is-sticky": sticky})}
24+
onClick={() => mainContent.current?.scrollIntoView({behavior: 'smooth'})}
25+
tabIndex={sticky ? 0 : -1}
26+
aria-label="Scroll to top of page"
27+
data-bs-theme="neutral"
28+
>
29+
<i className="icon icon-chevron-up"/>
30+
</Button>,
31+
32+
<button
33+
onClick={() => mainContent.current?.scrollIntoView({behavior: 'smooth'})}
34+
className={classNames("scroll-btn d-print-none", {"is-sticky": sticky})}
35+
tabIndex={sticky ? 0 : -1}
36+
>
37+
<img src="/assets/common/icons/chevron-up.svg" alt="Scroll to top of page"/>
38+
</button>
39+
);
40+
};

src/scss/common/scroll-button.scss

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
1-
.scroll-btn {
1+
button.btn.scroll-btn {
22
position: fixed;
3-
display: none; // If not in use hide
3+
opacity: 0;
44
height: 45px;
55
width: 45px;
66
justify-content: center;
77
align-items: center;
88
bottom: 10px;
99
right: 10px;
1010
box-shadow: 2px 2px 10px 0 #0004;
11-
background-color: #fff !important;
11+
background-color: #fff;
1212
border-radius: 50%;
1313
transition: opacity 0.1s linear;
1414
z-index: 101;
15-
img {
15+
16+
&.is-sticky {
17+
opacity: 1;
18+
display: flex;
19+
// TODO: animate opacity on destruction
20+
}
21+
22+
> img {
1623
margin-top: -4px;
1724
height: 80%;
1825
width: 80%;
1926
}
20-
}
2127

22-
.is-sticky {
23-
display: flex;
28+
> i {
29+
mask-size: 20px;
30+
}
2431
}

src/scss/phy/header.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ header {
191191
.accordion-body {
192192
background: $color-neutral-50;
193193
padding-top: 1rem;
194+
padding-bottom: 1rem;
194195

195196
> a:hover {
196197
background: $color-neutral-100;

src/scss/phy/icons.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@
115115
@include svg-icon('/assets/phy/icons/redesign/chevron-down.svg', 16px, 16px);
116116
}
117117

118+
.icon-chevron-up {
119+
@include svg-icon('/assets/phy/icons/redesign/chevron-down.svg', 16px, 16px);
120+
transform: rotate(180deg);
121+
}
122+
118123
.icon-question-pack {
119124
@include svg-icon-layered(
120125
'/assets/phy/icons/redesign/question-pack-fg.svg',

0 commit comments

Comments
 (0)