Skip to content

Commit 281fda6

Browse files
authored
Revert "decouple the resize handle from the vertical divider"
This reverts commit 2a2d121.
1 parent 2a2d121 commit 281fda6

File tree

2 files changed

+44
-65
lines changed

2 files changed

+44
-65
lines changed

src/PageLayout/PageLayout.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ export const ResizablePane: Story = args => (
701701
regular: args['Pane.position.regular'],
702702
wide: args['Pane.position.wide']
703703
}}
704+
divider="line"
704705
canResizePane={true}
705706
paneWidthStorageKey="primer-react.pane-width"
706707
>

src/PageLayout/PageLayout.tsx

Lines changed: 43 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,14 @@ const verticalDividerVariants = {
184184
}
185185
}
186186

187-
const VerticalDivider: React.FC<React.PropsWithChildren<DividerProps>> = ({variant = 'none', sx = {}}) => {
187+
const VerticalDivider: React.FC<React.PropsWithChildren<DividerProps>> = ({
188+
variant = 'none',
189+
canResize,
190+
isResizing,
191+
onClick,
192+
onMouseDown,
193+
sx = {}
194+
}) => {
188195
const responsiveVariant = useResponsiveValue(variant, 'none')
189196
return (
190197
<Box
@@ -196,66 +203,45 @@ const VerticalDivider: React.FC<React.PropsWithChildren<DividerProps>> = ({varia
196203
},
197204
sx
198205
)}
199-
></Box>
200-
)
201-
}
202-
203-
// ----------------------------------------------------------------------------
204-
// ResizeHandle (internal)
205-
206-
type ResizeHandleProps = {
207-
isResizing: boolean
208-
onClick: (e: React.MouseEvent) => void
209-
onMouseDown: (e: React.MouseEvent) => void
210-
} & SxProp
211-
212-
const ResizeHandle: React.FC<React.PropsWithChildren<ResizeHandleProps>> = ({isResizing, onClick, onMouseDown, sx}) => {
213-
return (
214-
<Box
215-
sx={merge<BetterSystemStyleObject>(
216-
{
217-
height: '100%',
218-
position: 'relative'
219-
},
220-
sx
221-
)}
222206
>
223-
<Box
224-
onMouseDown={onMouseDown}
225-
onClick={onClick}
226-
sx={{
227-
width: '16px',
228-
height: '100%',
229-
display: 'flex',
230-
justifyContent: 'center',
231-
position: 'absolute',
232-
transform: 'translateX(50%)',
233-
right: 0,
234-
opacity: isResizing ? 1 : 0,
235-
cursor: 'col-resize',
236-
'&:hover': {
237-
animation: isResizing ? 'none' : 'resizer-appear 80ms 300ms both',
238-
239-
'@keyframes resizer-appear': {
240-
from: {
241-
opacity: 0
242-
},
243-
244-
to: {
245-
opacity: 1
246-
}
247-
}
248-
}
249-
}}
250-
>
207+
{canResize && (
251208
<Box
209+
onMouseDown={onMouseDown}
210+
onClick={onClick}
252211
sx={{
253-
backgroundColor: 'accent.fg',
254-
width: '1px',
255-
height: '100%'
212+
width: '16px',
213+
height: '100%',
214+
display: 'flex',
215+
justifyContent: 'center',
216+
position: 'absolute',
217+
transform: 'translateX(50%)',
218+
right: 0,
219+
opacity: isResizing ? 1 : 0,
220+
cursor: 'col-resize',
221+
'&:hover': {
222+
animation: isResizing ? 'none' : 'resizer-appear 80ms 300ms both',
223+
224+
'@keyframes resizer-appear': {
225+
from: {
226+
opacity: 0
227+
},
228+
229+
to: {
230+
opacity: 1
231+
}
232+
}
233+
}
256234
}}
257-
/>
258-
</Box>
235+
>
236+
<Box
237+
sx={{
238+
backgroundColor: 'accent.fg',
239+
width: '1px',
240+
height: '100%'
241+
}}
242+
/>
243+
</Box>
244+
)}
259245
</Box>
260246
)
261247
}
@@ -581,14 +567,6 @@ const Pane = React.forwardRef<HTMLDivElement, React.PropsWithChildren<PageLayout
581567
onMouseDown={onMouseDown}
582568
sx={{[position === 'end' ? 'marginRight' : 'marginLeft']: SPACING_MAP[columnGap]}}
583569
/>
584-
{canResizePane && (
585-
<ResizeHandle
586-
isResizing={isResizing}
587-
onClick={onClick}
588-
onMouseDown={onMouseDown}
589-
sx={{[position === 'end' ? 'marginRight' : 'marginLeft']: SPACING_MAP[columnGap]}}
590-
/>
591-
)}
592570
<Box
593571
ref={paneRef}
594572
sx={(theme: Theme) => ({

0 commit comments

Comments
 (0)