Skip to content

Commit b5442dc

Browse files
committed
icon tools on sidebar
1 parent 9abdc71 commit b5442dc

File tree

5 files changed

+57
-18
lines changed

5 files changed

+57
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"react-hotkeys": "^2.0.0",
1919
"react-json-view": "^1.19.1",
2020
"react-markdown": "^4.0.6",
21-
"react-material-workspace-layout": "^0.1.6",
21+
"react-material-workspace-layout": "^0.1.8",
2222
"react-monaco-editor": "^0.25.1",
2323
"react-remove-scroll": "^2.0.4",
2424
"react-select": "^3.0.8",

src/MainLayout/icon-dictionary.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
// @flow
22

3-
export const iconDictionary = {}
3+
import React from "react"
4+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
5+
import {
6+
faArrowsAlt,
7+
faMousePointer,
8+
faExpandArrowsAlt,
9+
faGripLines,
10+
faTag,
11+
faPaintBrush,
12+
faCrosshairs,
13+
faDrawPolygon,
14+
faVectorSquare,
15+
faHandPaper,
16+
faSearch,
17+
faMask,
18+
} from "@fortawesome/free-solid-svg-icons"
19+
20+
export const iconDictionary = {
21+
select: () => <FontAwesomeIcon size="xs" fixedWidth icon={faMousePointer} />,
22+
pan: () => <FontAwesomeIcon size="xs" fixedWidth icon={faHandPaper} />,
23+
zoom: () => <FontAwesomeIcon size="xs" fixedWidth icon={faSearch} />,
24+
"show-tags": () => <FontAwesomeIcon size="xs" fixedWidth icon={faTag} />,
25+
"create-point": () => (
26+
<FontAwesomeIcon size="xs" fixedWidth icon={faCrosshairs} />
27+
),
28+
"create-box": () => (
29+
<FontAwesomeIcon size="xs" fixedWidth icon={faVectorSquare} />
30+
),
31+
"create-polygon": () => (
32+
<FontAwesomeIcon size="xs" fixedWidth icon={faDrawPolygon} />
33+
),
34+
"create-expanding-line": () => (
35+
<FontAwesomeIcon size="xs" fixedWidth icon={faGripLines} />
36+
),
37+
"show-mask": () => <FontAwesomeIcon size="xs" fixedWidth icon={faMask} />,
38+
}
439

540
export default iconDictionary

src/MainLayout/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import RegionSelector from "../RegionSelectorSidebarBox"
3030
import ImageSelector from "../ImageSelectorSidebarBox"
3131
import HistorySidebarBox from "../HistorySidebarBox"
3232

33+
const emptyArr = []
3334
const useStyles = makeStyles(styles)
3435

3536
const HotkeyDiv = withHotKeys(({ hotKeys, children, divRef, ...props }) => (
@@ -196,39 +197,40 @@ export const MainLayout = ({
196197
iconSidebarItems={[
197198
{
198199
name: "select",
199-
toolTip: "Select",
200+
helperText: "Select",
201+
selected: true,
200202
},
201203
{
202204
name: "pan",
203-
toolTip: "Drag/Pan",
205+
helperText: "Drag/Pan",
204206
},
205207
{
206208
name: "zoom",
207-
toolTip: "Zoom In/Out",
209+
helperText: "Zoom In/Out",
208210
},
209211
{
210212
name: "show-tags",
211-
toolTip: "Show / Hide Tags",
213+
helperText: "Show / Hide Tags",
212214
},
213215
{
214216
name: "create-point",
215-
toolTip: "Add Point",
217+
helperText: "Add Point",
216218
},
217219
{
218220
name: "create-box",
219-
toolTip: "Add Bounding Box",
221+
helperText: "Add Bounding Box",
220222
},
221223
{
222224
name: "create-polygon",
223-
toolTip: "Add Polygon",
225+
helperText: "Add Polygon",
224226
},
225227
{
226228
name: "create-expanding-line",
227-
toolTip: "Add Expanding Line",
229+
helperText: "Add Expanding Line",
228230
},
229231
{
230232
name: "show-mask",
231-
toolTip: "Show / Hide Mask",
233+
helperText: "Show / Hide Mask",
232234
},
233235
]}
234236
rightSidebarItems={[

src/RegionSelectorSidebarBox/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ const MemoRow = memo(
160160
prevProps.color === nextProps.color
161161
)
162162

163+
const emptyArr = []
164+
163165
export const RegionSelectorSidebarBox = ({
164-
regions,
166+
regions = emptyArr,
165167
onDeleteRegion,
166168
onChangeRegion,
167169
onSelectRegion,
@@ -203,7 +205,7 @@ const mapUsedRegionProperties = (r) => [
203205

204206
export default memo(RegionSelectorSidebarBox, (prevProps, nextProps) =>
205207
isEqual(
206-
prevProps.regions.map(mapUsedRegionProperties),
207-
nextProps.regions.map(mapUsedRegionProperties)
208+
(prevProps.regions || emptyArr).map(mapUsedRegionProperties),
209+
(nextProps.regions || emptyArr).map(mapUsedRegionProperties)
208210
)
209211
)

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14522,10 +14522,10 @@ react-markdown@^4.0.6:
1452214522
unist-util-visit "^1.3.0"
1452314523
xtend "^4.0.1"
1452414524

14525-
react-material-workspace-layout@^0.1.6:
14526-
version "0.1.6"
14527-
resolved "https://registry.yarnpkg.com/react-material-workspace-layout/-/react-material-workspace-layout-0.1.6.tgz#38412f8ca2e282ebc169d709cc12137351c8c427"
14528-
integrity sha512-494vMTYgyPfC5MS7opvRcrWvDyYh3cmKP5uWH8LdSF7oDDVGi9WDEqRQK8eFt0GrBSfNk85eHUEnX74B2cjsDg==
14525+
react-material-workspace-layout@^0.1.8:
14526+
version "0.1.8"
14527+
resolved "https://registry.yarnpkg.com/react-material-workspace-layout/-/react-material-workspace-layout-0.1.8.tgz#b81ca443d6a57b4668ce823c00c52d14d5556020"
14528+
integrity sha512-XgC7ucxKZ1YMxA3hMPAhrrsqcCG0oZ5NAC+ua2brkvr8io4u1Nrj5BFrzGIfpRqJIzO2BVOn4DOZJhpgXIQKOQ==
1452914529
dependencies:
1453014530
"@material-ui/core" "^4.10.0"
1453114531
"@material-ui/icons" "^4.9.1"

0 commit comments

Comments
 (0)