Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button tooltips #37

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions src/components/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
FaStepForward,
FaBackward,
FaStepBackward,
// FaInfoCircle,
FaRegCheckSquare,
} from "react-icons/fa";
import { BsInfoCircleFill } from "react-icons/bs";
import { SearchBar, SearchBarPresentation } from "./search-bar";
import { navigate } from "gatsby";

Expand Down Expand Up @@ -91,6 +94,7 @@ const Navbar = (props) => {
doc.write("</body></html>");
doc.close();
myWindow.focus(); // necessary for IE >= 10*/
myWindow.print();
};

const handleFontSize = (e, param) => {
Expand All @@ -105,12 +109,12 @@ const Navbar = (props) => {
fontSize.current -= 20;
}
}

const element = document.getElementById("print-section");
if (fontSize.current === 100) {
element.classList.add("print-section__font-size");
element.classList.add("print-section__font-size");
} else {
element.classList.remove("print-section__font-size");
element.classList.remove("print-section__font-size");
}
element.style.fontSize = `${fontSize.current}%`;
};
Expand All @@ -137,27 +141,31 @@ const Navbar = (props) => {
aria-label="Skip to first page"
className="navbar__button"
onClick={(e) => handleClick(e, "fast-backward")}
title="First"
>
<FaStepBackward />
</button>
<button
aria-label="Previous Page"
className="navbar__button"
onClick={(e) => handleClick(e, "backward")}
title="Previous"
>
<FaBackward />
</button>
<button
aria-label="Next Page"
className="navbar__button"
onClick={(e) => handleClick(e, "forward")}
title="Next"
>
<FaForward />
</button>
<button
aria-label="Skip to last page"
className="navbar__button"
onClick={(e) => handleClick(e, "fast-forward")}
title="Last"
>
<FaStepForward />
</button>
Expand All @@ -168,6 +176,7 @@ const Navbar = (props) => {
onClick={(e) => {
handleFontSize(e, "increase");
}}
title="Increase Font Size"
>
<FaFont />
<span
Expand All @@ -186,6 +195,7 @@ const Navbar = (props) => {
onClick={(e) => {
handleFontSize(e, "decrease");
}}
title="Decrease Font Size"
>
<FaFont />
<span
Expand All @@ -202,9 +212,39 @@ const Navbar = (props) => {
aria-label="Print Page"
className="navbar__button"
onClick={handlePrint}
title="Print"
>
<FaPrint />
</button>
<button
aria-label="Print Information"
className="navbar__button tooltip"
style={{
margin: "0px",
fontSize: "14px",
verticalAlign: "super",
paddingLeft: "3px",
}}
>
<BsInfoCircleFill />
<span class="tooltiptext" aria-hidden="true" role="tooltip">
<ul class="tooltiptext__list">
<li>
To print the current page, click the print &nbsp;
<FaPrint />
&nbsp; icon.
</li>
<li>
To print multiple pages, select the checkboxes &nbsp;
<FaRegCheckSquare />
&nbsp; in the left pane (or in the page menu below on mobile)
for the pages you want to print and click the print &nbsp;
<FaPrint />
&nbsp; icon.
</li>
</ul>
</span>
</button>
</div>
</div>
</nav>
Expand Down
1 change: 1 addition & 0 deletions src/components/search-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const SearchBarPresentation = (props) => {
type="submit"
className="navbar__button search"
style={{ color: "white" }}
title="Search"
>
<span className="sr-only">Search</span>
<img src={SearchIcon} style={{ color:"white", height:"1rem", width:"1rem", maxWidth:"initial" }} />
Expand Down
59 changes: 56 additions & 3 deletions src/styles/components/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
width: 50%;
}

@include media(lg) {
@include media(lg) {
width: initial;
margin-right: auto;
margin-left: auto;
Expand Down Expand Up @@ -53,6 +53,9 @@
.navbar__search-input {
border: solid 1px $brand-primary;
border-radius: 0;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
width: 100%;
height: 2rem;
padding: 8px;
Expand All @@ -69,11 +72,61 @@
.navbar__buttons {
padding: 0;

@include media(lg){
@include media(lg) {
padding-left: 20px;
}
}

.tooltip {
position: relative;
}

.tooltip .tooltiptext {
background: #fff;
color: #000;
box-shadow: 0 0 8px rgb(32 32 32 / 50%);
font-size: 0.875rem;
width: 50vw;
padding: 0.5rem;
position: absolute;
right: -3px;
top: 25px;
visibility: hidden;
text-align: left;
border-radius: 0;
z-index: 15;

@include media(sm) {
width: 50vw;
right: 0;
left: 22px;
top: 0px;
}

@include media(md) {
width: 30vw;
}

@include media(lg) {
width: 20vw;
}
}

.tooltip:hover .tooltiptext,
.tooltip:focus .tooltiptext {
visibility: visible;
}

.tooltiptext__list {
margin: 0;
padding: 0;
padding-left: 22px;

& li {
margin: 0;
}
}

.navbar__button {
font-size: 1.125em;
background-color: unset;
Expand All @@ -94,7 +147,7 @@
}
}

&:hover{
&:hover {
color: $navy;
}
}