Skip to content

Commit 168d94a

Browse files
committed
Refactor ResizablePanelHandle using styled components
1 parent e2b66c2 commit 168d94a

File tree

3 files changed

+68
-59
lines changed

3 files changed

+68
-59
lines changed
Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,26 @@
11
import React from 'react'
22
import {
3-
PanelResizeHandle,
4-
PanelResizeHandleProps,
5-
} from 'react-resizable-panels'
6-
import classNames from 'classnames'
7-
8-
import styles from './styles.module.scss'
9-
10-
interface ResizablePanelHandleProps extends PanelResizeHandleProps {
11-
direction?: 'horizontal' | 'vertical'
12-
}
3+
HandleContainer,
4+
Line,
5+
ResizablePanelHandleProps,
6+
StyledPanelResizeHandle,
7+
} from './resizable-panel-handle.styles'
138

149
const ResizablePanelHandle = ({
1510
className,
1611
direction = 'vertical',
1712
...rest
1813
}: ResizablePanelHandleProps) => (
19-
<PanelResizeHandle
20-
className={classNames(
21-
className,
22-
direction === 'vertical' ? styles.vertical : styles.horizontal,
23-
)}
14+
<StyledPanelResizeHandle
15+
$direction={direction}
16+
className={className}
2417
{...rest}
2518
>
26-
<div
27-
className={classNames(
28-
styles.handle,
29-
direction === 'vertical' ? styles.vertical : '',
30-
)}
31-
>
32-
<div className={styles.line} />
33-
<div className={styles.line} />
34-
</div>
35-
</PanelResizeHandle>
19+
<HandleContainer $direction={direction}>
20+
<Line />
21+
<Line />
22+
</HandleContainer>
23+
</StyledPanelResizeHandle>
3624
)
3725

3826
export default ResizablePanelHandle
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {
2+
PanelResizeHandle,
3+
PanelResizeHandleProps,
4+
} from 'react-resizable-panels'
5+
import styled, { css } from 'styled-components'
6+
7+
export interface ResizablePanelHandleProps extends PanelResizeHandleProps {
8+
direction?: 'horizontal' | 'vertical'
9+
}
10+
11+
export const StyledPanelResizeHandle = styled(PanelResizeHandle)<{
12+
$direction: 'horizontal' | 'vertical'
13+
}>`
14+
${({ $direction }) =>
15+
$direction === 'vertical'
16+
? css`
17+
width: 16px;
18+
height: 100%;
19+
display: flex;
20+
flex-direction: column;
21+
justify-content: center;
22+
`
23+
: css`
24+
height: 16px;
25+
width: 100%;
26+
display: flex;
27+
flex-direction: row;
28+
justify-content: center;
29+
`}
30+
`
31+
32+
export const HandleContainer = styled.div<{
33+
$direction: 'horizontal' | 'vertical'
34+
children?: React.ReactNode
35+
}>`
36+
width: 16px;
37+
height: 16px;
38+
display: flex;
39+
flex-direction: column;
40+
justify-content: center;
41+
align-items: center;
42+
gap: 2px;
43+
44+
${({ $direction }) =>
45+
$direction === 'vertical' &&
46+
css`
47+
transform: rotate(90deg);
48+
`}
49+
`
50+
51+
export const Line = styled.div`
52+
width: 12px;
53+
height: 1px;
54+
background-color: #343741;
55+
`

redisinsight/ui/src/components/base/layout/resize/handle/styles.module.scss

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)