Skip to content

Commit d4ab61a

Browse files
💄 style: Add DraggableSideNav
1 parent 5feee0f commit d4ab61a

File tree

15 files changed

+678
-564
lines changed

15 files changed

+678
-564
lines changed

src/Avatar/style.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const useStyles = createStyles(({ stylish, css, token, prefixCls }) => {
1111
`,
1212
outlined: stylish.variantOutlinedWithoutHover,
1313
root: css`
14+
flex: none;
1415
background: transparent;
1516
&.${prefixCls}-avatar {
1617
user-select: none;

src/DraggablePanel/DraggablePanel.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const DraggablePanel = memo<DraggablePanelProps>(
3737
placement = 'right',
3838
resize,
3939
style,
40+
showBorder = true,
41+
showHandleHighlight = false,
4042
showHandleWideArea = DEFAULT_SHOW_HANDLE_WIDE_AREA,
4143
size,
4244
defaultSize: customizeDefaultSize,
@@ -73,7 +75,7 @@ const DraggablePanel = memo<DraggablePanelProps>(
7375
: placement;
7476
}, [direction, placement]);
7577

76-
const { styles, cx } = useStyles({ headerHeight, showHandleWideArea });
78+
const { styles, cx } = useStyles({ headerHeight, showBorder, showHandleWideArea });
7779

7880
const [isExpand, setIsExpand] = useControlledState(defaultExpand, {
7981
onChange: onExpandChange,
@@ -305,9 +307,12 @@ const DraggablePanel = memo<DraggablePanelProps>(
305307
handleClasses={
306308
canResizing
307309
? {
308-
[reversePlacement(internalPlacement)]: handleVariants({
309-
placement: reversePlacement(internalPlacement),
310-
}),
310+
[reversePlacement(internalPlacement)]: cx(
311+
handleVariants({
312+
placement: reversePlacement(internalPlacement),
313+
}),
314+
showHandleHighlight && styles.handleHighlight,
315+
),
311316
}
312317
: {}
313318
}

src/DraggablePanel/demos/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export default () => {
2626
options: ['left', 'right', 'top', 'bottom'],
2727
value: 'left',
2828
},
29+
showBorder: true,
30+
showHandleHighlight: false,
2931
showHandleWhenCollapsed: false,
3032
},
3133
{ store },

src/DraggablePanel/style.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@ const LAYOUT = {
1010
export const useStyles = createStyles(
1111
(
1212
{ prefixCls, token, stylish },
13-
{ headerHeight, showHandleWideArea }: { headerHeight: number; showHandleWideArea: boolean },
13+
{
14+
headerHeight,
15+
showBorder,
16+
showHandleWideArea,
17+
}: { headerHeight: number; showBorder: boolean; showHandleWideArea: boolean },
1418
) => {
1519
const prefix = `${prefixCls}-draggable-panel`;
1620

1721
// Base styles
1822
const borderStyles = {
1923
borderBottom: css`
20-
border-block-end-width: 1px;
24+
border-block-end-width: ${showBorder ? '1px' : '0'};
2125
`,
2226
borderLeft: css`
23-
border-inline-start-width: 1px;
27+
border-inline-start-width: ${showBorder ? '1px' : '0'};
2428
`,
2529
borderRight: css`
26-
border-inline-end-width: 1px;
30+
border-inline-end-width: ${showBorder ? '1px' : '0'};
2731
`,
2832
borderTop: css`
29-
border-block-start-width: 1px;
33+
border-block-start-width: ${showBorder ? '1px' : '0'};
3034
`,
3135
};
3236

@@ -81,8 +85,16 @@ export const useStyles = createStyles(
8185
z-index: 50;
8286
transition: all 0.2s ${token.motionEaseOut};
8387
}
88+
`;
89+
90+
const handleHighlightStyle = css`
91+
&:hover {
92+
&::before {
93+
background: ${token.colorPrimary};
94+
box-shadow: 0 0 8px ${token.colorPrimary}40;
95+
}
96+
}
8497
85-
&:hover,
8698
&:active {
8799
&::before {
88100
background: ${token.colorPrimary} !important;
@@ -290,6 +302,7 @@ export const useStyles = createStyles(
290302
...borderStyles,
291303
...floatPositions,
292304
...handleStyles,
305+
handleHighlight: handleHighlightStyle,
293306
...toggleStyles,
294307
...componentStyles,
295308
};

src/DraggablePanel/type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export interface DraggablePanelProps extends DivProps {
2929
pin?: boolean;
3030
placement: PlacementType;
3131
resize?: RndProps['enableResizing'];
32+
/**
33+
* Whether to show border
34+
* @default true
35+
*/
36+
showBorder?: boolean;
37+
showHandleHighlight?: boolean;
3238
showHandleWhenCollapsed?: boolean;
3339
showHandleWideArea?: boolean;
3440
size?: Partial<Size>;

0 commit comments

Comments
 (0)