Skip to content

Commit 85daba0

Browse files
committed
fix: update react-resize-panel to fix HMR issue and error thrown on
"Next" load
1 parent 6c21655 commit 85daba0

File tree

6 files changed

+93
-43
lines changed

6 files changed

+93
-43
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"dependencies": {
99
"@material-ui/core": "^4.10.0",
1010
"@material-ui/icons": "^4.9.1",
11+
"@seveibar/react-resize-panel": "^0.3.7",
1112
"classnames": "^2.2.6",
1213
"react": "^16.13.1",
13-
"react-resize-panel": "^0.3.5",
1414
"react-use-dimensions": "^1.2.1",
1515
"use-event-callback": "^0.1.0"
1616
},

src/RightSidebar/index.stories.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@ import FeaturedVideoIcon from "@material-ui/icons/FeaturedVideo"
55

66
export default {
77
title: "RightSidebar",
8-
component: RightSidebar,
8+
component: RightSidebar
99
}
1010

1111
export const Basic = () => (
12-
<RightSidebar>
13-
<SidebarBox icon={<FeaturedVideoIcon />} title="Region Selector">
14-
Content inside sidebar box
15-
</SidebarBox>
16-
<SidebarBox icon={<FeaturedVideoIcon />} title="Region Selector">
17-
Content inside sidebar box
18-
</SidebarBox>
19-
</RightSidebar>
12+
<div style={{ width: 500, height: 500 }}>
13+
<RightSidebar>
14+
<SidebarBox icon={<FeaturedVideoIcon />} title="Region Selector">
15+
Content inside sidebar box
16+
</SidebarBox>
17+
<SidebarBox icon={<FeaturedVideoIcon />} title="Region Selector">
18+
Content inside sidebar box
19+
</SidebarBox>
20+
</RightSidebar>
21+
</div>
22+
)
23+
24+
export const NoChildren = () => (
25+
<div style={{ width: 500, height: 500 }}>
26+
<RightSidebar></RightSidebar>
27+
</div>
2028
)

src/SidebarBox/index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import classnames from "classnames"
1111
import useEventCallback from "use-event-callback"
1212
import Typography from "@material-ui/core/Typography"
1313
import { useIconDictionary } from "../icon-dictionary.js"
14-
import ResizePanel from "react-resize-panel"
14+
import ResizePanel from "@seveibar/react-resize-panel"
1515

1616
const useStyles = makeStyles({
1717
container: {
1818
borderBottom: `2px solid ${grey[400]}`,
19-
"&:first-child": { borderTop: `1px solid ${grey[400]}` },
19+
"&:first-child": { borderTop: `1px solid ${grey[400]}` }
2020
},
2121
header: {
2222
display: "flex",
@@ -32,9 +32,9 @@ const useStyles = makeStyles({
3232
justifyContent: "center",
3333
"& .MuiSvgIcon-root": {
3434
width: 16,
35-
height: 16,
36-
},
37-
},
35+
height: 16
36+
}
37+
}
3838
},
3939
title: {
4040
fontSize: 11,
@@ -44,8 +44,8 @@ const useStyles = makeStyles({
4444
color: grey[800],
4545
"& span": {
4646
color: grey[600],
47-
fontSize: 11,
48-
},
47+
fontSize: 11
48+
}
4949
},
5050
expandButton: {
5151
padding: 0,
@@ -56,21 +56,21 @@ const useStyles = makeStyles({
5656
height: 20,
5757
transition: "500ms transform",
5858
"&.expanded": {
59-
transform: "rotate(180deg)",
60-
},
61-
},
59+
transform: "rotate(180deg)"
60+
}
61+
}
6262
},
6363
expandedContent: {
6464
maxHeight: 300,
6565
overflowY: "auto",
6666
"&.noScroll": {
6767
overflowY: "visible",
68-
overflow: "visible",
69-
},
70-
},
68+
overflow: "visible"
69+
}
70+
}
7171
})
7272

73-
const getExpandedFromLocalStorage = (title) => {
73+
const getExpandedFromLocalStorage = title => {
7474
try {
7575
return JSON.parse(
7676
window.localStorage[`__REACT_WORKSPACE_SIDEBAR_EXPANDED_${title}`]
@@ -91,7 +91,7 @@ export const SidebarBox = ({
9191
subTitle,
9292
children,
9393
noScroll = false,
94-
expandedByDefault,
94+
expandedByDefault
9595
}) => {
9696
const classes = useStyles()
9797
const content = (
@@ -108,7 +108,7 @@ export const SidebarBox = ({
108108
: expandedByDefault
109109
)
110110
const changeExpanded = useCallback(
111-
(expanded) => {
111+
expanded => {
112112
changeExpandedState(expanded)
113113
setExpandedInLocalStorage(title, expanded)
114114
},

src/SidebarBox/index.stories.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React, { useState, useEffect } from "react"
2+
import SidebarBox from "./"
3+
import FeaturedVideoIcon from "@material-ui/icons/FeaturedVideo"
4+
5+
export default {
6+
title: "SidebarBox",
7+
component: SidebarBox
8+
}
9+
10+
export const Basic = () => (
11+
<div style={{ width: 300, height: 400 }}>
12+
<SidebarBox icon={<FeaturedVideoIcon />} title="Region Selector">
13+
Content inside sidebar box
14+
</SidebarBox>
15+
</div>
16+
)
17+
18+
export const NoChildren = () => (
19+
<div style={{ width: 300, height: 400 }}>
20+
<SidebarBox icon={<FeaturedVideoIcon />} title="Region Selector" />
21+
</div>
22+
)
23+
24+
export const StopRendering = () => {
25+
const [t, setT] = useState(0)
26+
useEffect(() => {
27+
let tLocal = 0
28+
setInterval(() => {
29+
setT(tLocal)
30+
tLocal = (tLocal + 1) % 4
31+
}, 500)
32+
}, [])
33+
return (
34+
<div key={t} style={{ width: 300, height: 500 }}>
35+
{(t === 0 || t === 3) && (
36+
<SidebarBox icon={<FeaturedVideoIcon />} title="Region Selector">
37+
{t === 0 || t === 2 ? <div style={{ height: 300 }}>hello</div> : null}
38+
</SidebarBox>
39+
)}
40+
</div>
41+
)
42+
}

src/Workspace/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ const Container = styled("div")({
1616
flexDirection: "column",
1717
height: "100%",
1818
overflow: "hidden",
19-
maxWidth: "100vw",
19+
maxWidth: "100vw"
2020
})
2121
const SidebarsAndContent = styled("div")({
2222
display: "flex",
2323
flexGrow: 1,
2424
width: "100%",
2525
height: "100%",
2626
overflow: "hidden",
27-
maxWidth: "100vw",
27+
maxWidth: "100vw"
2828
})
2929

3030
export default ({
@@ -38,9 +38,9 @@ export default ({
3838
headerLeftSide = null,
3939
iconDictionary = emptyObj,
4040
rightSidebarExpanded,
41-
children,
41+
children
4242
}) => {
43-
const [workContainerRef, workContainerSize] = useDimensions()
43+
const [sidebarAndContentRef, sidebarAndContent] = useDimensions()
4444
return (
4545
<IconDictionaryContext.Provider value={iconDictionary}>
4646
<Container style={style}>
@@ -49,19 +49,19 @@ export default ({
4949
onClickItem={onClickHeaderItem}
5050
items={headerItems}
5151
/>
52-
<SidebarsAndContent>
52+
<SidebarsAndContent ref={sidebarAndContentRef}>
5353
{iconSidebarItems.length === 0 ? null : (
5454
<IconSidebar
5555
onClickItem={onClickIconSidebarItem}
5656
selectedTools={selectedTools}
5757
items={iconSidebarItems}
5858
/>
5959
)}
60-
<WorkContainer ref={workContainerRef}>{children}</WorkContainer>
60+
<WorkContainer>{children}</WorkContainer>
6161
{rightSidebarItems.length === 0 ? null : (
6262
<RightSidebar
6363
initiallyExpanded={rightSidebarExpanded}
64-
height={workContainerSize.height || 0}
64+
height={sidebarAndContent.height || 0}
6565
>
6666
{rightSidebarItems}
6767
</RightSidebar>

yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,16 @@
16971697
micromatch "^4.0.0"
16981698
p-reduce "^2.0.0"
16991699

1700+
"@seveibar/react-resize-panel@^0.3.7":
1701+
version "0.3.7"
1702+
resolved "https://registry.yarnpkg.com/@seveibar/react-resize-panel/-/react-resize-panel-0.3.7.tgz#7c7bf449b0f2d83697e23008a5bc869c033fcc4c"
1703+
integrity sha512-oglctCuyCb04Ps4f1nY+IRmy5IyoGPjCv42rNAWdfDHzGb/wf81mvwTegHbouuaKWbmRH2E/c76ypSl2aGZFzQ==
1704+
dependencies:
1705+
cash-dom "^4.1.5"
1706+
classnames "^2.2.6"
1707+
lodash.debounce "^4.0.8"
1708+
react-draggable "^4.0.3"
1709+
17001710
"@sheerun/mutationobserver-shim@^0.3.2":
17011711
version "0.3.3"
17021712
resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.3.tgz#5405ee8e444ed212db44e79351f0c70a582aae25"
@@ -11217,16 +11227,6 @@ react-popper@^1.3.7:
1121711227
typed-styles "^0.0.7"
1121811228
warning "^4.0.2"
1121911229

11220-
react-resize-panel@^0.3.5:
11221-
version "0.3.5"
11222-
resolved "https://registry.yarnpkg.com/react-resize-panel/-/react-resize-panel-0.3.5.tgz#43aa3450bf5b5a2566b40c4201445ced96c2a905"
11223-
integrity sha512-iyHOFTrSt+WV4Ilzi81x6KH3FU7VsGP736rmxepwGrgAEATmCvXzZdluTm3NpsptP7aC3hLODmXwnxusyA393A==
11224-
dependencies:
11225-
cash-dom "^4.1.5"
11226-
classnames "^2.2.6"
11227-
lodash.debounce "^4.0.8"
11228-
react-draggable "^4.0.3"
11229-
1123011230
1123111231
version "3.4.1"
1123211232
resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-3.4.1.tgz#f551298b5c71985cc491b9acf3c8e8c0ae3ada0a"

0 commit comments

Comments
 (0)