-
Notifications
You must be signed in to change notification settings - Fork 411
Expand file tree
/
Copy pathStyledExample.tsx
More file actions
65 lines (62 loc) · 1.8 KB
/
StyledExample.tsx
File metadata and controls
65 lines (62 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from 'react';
import { SplitPane, Pane } from '../src';
import type { DividerProps } from '../src/types';
function CustomDivider(props: DividerProps) {
const {
direction,
isDragging,
disabled,
onMouseDown,
onTouchStart,
onTouchEnd,
onKeyDown,
} = props;
return (
<div
role="separator"
aria-orientation={direction === 'horizontal' ? 'vertical' : 'horizontal'}
tabIndex={disabled ? -1 : 0}
className={`custom-divider ${direction}${isDragging ? ' dragging' : ''}`}
onMouseDown={disabled ? undefined : onMouseDown}
onTouchStart={disabled ? undefined : onTouchStart}
onTouchEnd={disabled ? undefined : onTouchEnd}
onKeyDown={disabled ? undefined : onKeyDown}
/>
);
}
export function StyledExample() {
return (
<div className="example-container styled-example">
<div className="example-header">
<h2>Custom Divider</h2>
<p>Use a custom divider component for different styles.</p>
</div>
<div className="example-content">
<SplitPane direction="horizontal" divider={CustomDivider}>
<Pane defaultSize="33%">
<div className="pane styled-pane purple">
<h3>Panel 1</h3>
</div>
</Pane>
<Pane defaultSize="34%">
<div className="pane styled-pane pink">
<h3>Panel 2</h3>
<div className="code dark">
<code>
{`<SplitPane divider={CustomDivider}>
<Pane>...</Pane>
</SplitPane>`}
</code>
</div>
</div>
</Pane>
<Pane defaultSize="33%">
<div className="pane styled-pane blue">
<h3>Panel 3</h3>
</div>
</Pane>
</SplitPane>
</div>
</div>
);
}