Skip to content

Commit cc23c8f

Browse files
Switched Zoom in/out button from +/- to Font Awesome icons (#1574)
1 parent 87ce823 commit cc23c8f

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### ✨ New features/enhancements
88

9+
- Updated the Zoom In/Zoom Out buttons on the graph page to Awesome Icons from +/-
10+
911
### 🐛 Bug fixes
1012

1113
### 🔧 Internal changes

js/components/graph/Graph.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import InfoBox from "./InfoBox"
1111
import GraphDropdown from "./GraphDropdown"
1212
import Sidebar from "./Sidebar"
1313
import { parseAnd } from "../../util/util.js"
14+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
15+
import {
16+
faMagnifyingGlassMinus,
17+
faMagnifyingGlassPlus,
18+
} from "@fortawesome/free-solid-svg-icons"
1419

1520
const ZOOM_INCREMENT = 0.01
1621
const KEYBOARD_PANNING_INCREMENT = 10
@@ -1659,17 +1664,19 @@ export class Graph extends React.Component {
16591664
<div className="graph-button-group">
16601665
<div className="button-group">
16611666
<Button
1662-
text="+"
16631667
mouseDown={() => this.zoomViewbox(ZOOM_ENUM.ZOOM_IN)}
16641668
onMouseEnter={this.buttonMouseEnter}
16651669
onMouseLeave={this.buttonMouseLeave}
1666-
/>
1670+
>
1671+
<FontAwesomeIcon icon={faMagnifyingGlassPlus} id="zoom-icon" />
1672+
</Button>
16671673
<Button
1668-
text="&ndash;"
16691674
mouseDown={() => this.zoomViewbox(ZOOM_ENUM.ZOOM_OUT)}
16701675
onMouseEnter={this.buttonMouseEnter}
16711676
onMouseLeave={this.buttonMouseLeave}
1672-
/>
1677+
>
1678+
<FontAwesomeIcon icon={faMagnifyingGlassMinus} id="zoom-icon" />
1679+
</Button>
16731680
</div>
16741681
<div className="button-group">
16751682
<Button
@@ -1692,6 +1699,7 @@ export class Graph extends React.Component {
16921699
<svg
16931700
xmlns="http://www.w3.org/2000/svg"
16941701
xmlnsXlink="http://www.w3.org/1999/xlink"
1702+
id="main-graph"
16951703
{...svgAttrs}
16961704
version="1.1"
16971705
{...svgMouseEvents}

js/components/graph/__tests__/Graph.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("Graph Navigation", () => {
88
it("Should pan right when the right arrow key is pressed", async () => {
99
const user = userEvent.setup()
1010
await TestGraph.build()
11-
const svg = document.querySelector("svg")
11+
const svg = document.querySelector("#main-graph")
1212
const initialX = parseInt(svg.getAttribute("viewBox").split(" ")[0])
1313
await user.keyboard("{ArrowRight}")
1414
const newX = parseInt(svg.getAttribute("viewBox").split(" ")[0])
@@ -19,7 +19,7 @@ describe("Graph Navigation", () => {
1919
it("Should pan left when the left arrow key is pressed", async () => {
2020
const user = userEvent.setup()
2121
await TestGraph.build()
22-
const svg = document.querySelector("svg")
22+
const svg = document.querySelector("#main-graph")
2323
const initialX = parseInt(svg.getAttribute("viewBox").split(" ")[0])
2424
await user.keyboard("{ArrowLeft}")
2525
const newX = parseInt(svg.getAttribute("viewBox").split(" ")[0])
@@ -30,7 +30,7 @@ describe("Graph Navigation", () => {
3030
it("Should pan down when the down arrow key is pressed", async () => {
3131
const user = userEvent.setup()
3232
await TestGraph.build()
33-
const svg = document.querySelector("svg")
33+
const svg = document.querySelector("#main-graph")
3434
const initialY = parseInt(svg.getAttribute("viewBox").split(" ")[1])
3535
await user.keyboard("{ArrowDown}")
3636
const newY = parseInt(svg.getAttribute("viewBox").split(" ")[1])
@@ -41,7 +41,7 @@ describe("Graph Navigation", () => {
4141
it("Should pan up when the up arrow key is pressed", async () => {
4242
const user = userEvent.setup()
4343
await TestGraph.build()
44-
const svg = document.querySelector("svg")
44+
const svg = document.querySelector("#main-graph")
4545
const initialY = parseInt(svg.getAttribute("viewBox").split(" ")[1])
4646
await user.keyboard("{ArrowUp}")
4747
const newY = parseInt(svg.getAttribute("viewBox").split(" ")[1])
@@ -52,7 +52,7 @@ describe("Graph Navigation", () => {
5252
it("Should zoom in when the user presses the + key", async () => {
5353
const user = userEvent.setup()
5454
await TestGraph.build()
55-
const svg = document.querySelector("svg")
55+
const svg = document.querySelector("#main-graph")
5656
const initialDims = svg
5757
.getAttribute("viewBox")
5858
.split(" ")
@@ -73,7 +73,7 @@ describe("Graph Navigation", () => {
7373
it("Should zoom out when the user presses the - key", async () => {
7474
const user = userEvent.setup()
7575
await TestGraph.build()
76-
const svg = document.querySelector("svg")
76+
const svg = document.querySelector("#main-graph")
7777
const initialDims = svg
7878
.getAttribute("viewBox")
7979
.split(" ")
@@ -94,7 +94,7 @@ describe("Graph Navigation", () => {
9494
it("Should pan when the user clicks and drags", async () => {
9595
const user = userEvent.setup()
9696
await TestGraph.build()
97-
const svg = document.querySelector("svg")
97+
const svg = document.querySelector("#main-graph")
9898
const initialX = parseInt(svg.getAttribute("viewBox").split(" ")[0])
9999
const initialY = parseInt(svg.getAttribute("viewBox").split(" ")[1])
100100

@@ -115,7 +115,7 @@ describe("Graph Navigation", () => {
115115

116116
it("Should zoom in when the mouse wheel is scrolled down", async () => {
117117
const graph = await TestGraph.build()
118-
const svg = document.querySelector("svg")
118+
const svg = document.querySelector("#main-graph")
119119
const initialDims = svg
120120
.getAttribute("viewBox")
121121
.split(" ")
@@ -135,7 +135,7 @@ describe("Graph Navigation", () => {
135135

136136
it("Should zoom out when the mouse wheel is scrolled up", async () => {
137137
const graph = await TestGraph.build()
138-
const svg = document.querySelector("svg")
138+
const svg = document.querySelector("#main-graph")
139139
const initialDims = svg
140140
.getAttribute("viewBox")
141141
.split(" ")

style/app.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,16 @@ ol {
262262
color: #dedae5;
263263
}
264264

265+
#zoom-icon {
266+
width: 1.1rem;
267+
height: 1.1rem;
268+
padding-right: 0.2rem;
269+
}
270+
271+
#zoom-icon path {
272+
fill: #7a6a96;
273+
}
274+
265275
#map-sidebar {
266276
overflow-y: auto;
267277
padding: 0;

0 commit comments

Comments
 (0)