Skip to content

Commit

Permalink
update resizable button style
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Jan 25, 2024
1 parent f279085 commit ea7c8f6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
15 changes: 4 additions & 11 deletions src/core/public/overlays/sidecar/resizable_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@ import { getPosition } from './helper';
import { ISidecarConfig, SIDECAR_DOCKED_MODE } from './sidecar_service';

interface Props {
isHorizontal: boolean;
onResize: (size: number) => void;
flyoutSize: number;
dockedMode: ISidecarConfig['dockedMode'] | undefined;
minSize?: number;
}

const MIN_SIDECAR_SIZE = 200;
const MIN_SIDECAR_SIZE = 350;

export const ResizableButton = ({
dockedMode,
onResize,
flyoutSize,
minSize = MIN_SIDECAR_SIZE,
}: Props) => {
export const ResizableButton = ({ dockedMode, onResize, flyoutSize }: Props) => {
const isHorizontal = dockedMode !== SIDECAR_DOCKED_MODE.TAKEOVER;

Check warning on line 21 in src/core/public/overlays/sidecar/resizable_button.tsx

View check run for this annotation

Codecov / codecov/patch

src/core/public/overlays/sidecar/resizable_button.tsx#L21

Added line #L21 was not covered by tests

const classes = classNames('resizableButton', {

Check warning on line 23 in src/core/public/overlays/sidecar/resizable_button.tsx

View check run for this annotation

Codecov / codecov/patch

src/core/public/overlays/sidecar/resizable_button.tsx#L23

Added line #L23 was not covered by tests
Expand Down Expand Up @@ -54,7 +47,7 @@ export const ResizableButton = ({
}
const newFlyoutSize = initialFlyoutSize.current + offset;

Check warning on line 48 in src/core/public/overlays/sidecar/resizable_button.tsx

View check run for this annotation

Codecov / codecov/patch

src/core/public/overlays/sidecar/resizable_button.tsx#L48

Added line #L48 was not covered by tests

onResize(Math.max(newFlyoutSize, minSize));
onResize(Math.max(newFlyoutSize, MIN_SIDECAR_SIZE));

Check warning on line 50 in src/core/public/overlays/sidecar/resizable_button.tsx

View check run for this annotation

Codecov / codecov/patch

src/core/public/overlays/sidecar/resizable_button.tsx#L50

Added line #L50 was not covered by tests
};
window.addEventListener('mousemove', onMouseMove);
window.addEventListener('mouseup', onMouseUp);
Expand All @@ -63,7 +56,7 @@ export const ResizableButton = ({
initialMouseXorY.current = getPosition(event, isHorizontal);
initialFlyoutSize.current = flyoutSize;

Check warning on line 57 in src/core/public/overlays/sidecar/resizable_button.tsx

View check run for this annotation

Codecov / codecov/patch

src/core/public/overlays/sidecar/resizable_button.tsx#L52-L57

Added lines #L52 - L57 were not covered by tests
},
[isHorizontal, flyoutSize, dockedMode, minSize, onResize]
[isHorizontal, flyoutSize, dockedMode, onResize]
);

return (

Check warning on line 62 in src/core/public/overlays/sidecar/resizable_button.tsx

View check run for this annotation

Codecov / codecov/patch

src/core/public/overlays/sidecar/resizable_button.tsx#L62

Added line #L62 was not covered by tests
Expand Down
2 changes: 0 additions & 2 deletions src/core/public/overlays/sidecar/sidecar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ export const Sidecar = ({ sidecarConfig$, options, setSidecarConfig, i18n, mount
<i18n.Context>
<div data-test-subj={options['data-test-subj']} style={flyoutSizeStyle} className={classes}>
<ResizableButton
isHorizontal={sidecarConfig?.dockedMode !== 'takeover'}
onResize={handleResize}
dockedMode={sidecarConfig?.dockedMode}
flyoutSize={sidecarConfig?.paddingSize ?? 0}
minSize={sidecarConfig?.minSize}
/>
<MountWrapper mount={mount} className="osdSidecarMountWrapper" />
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/core/public/overlays/sidecar/sidecar_service.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@
height: 100vh;
right: 0;
flex-direction: row;
padding-left: 8px;
}

&.osdSidecarFlyout--dockedLeft {
top: 0;
height: 100vh;
left: 0;
flex-direction: row-reverse;
padding-right: 8px;
}

&.osdSidecarFlyout--dockedTakeover {
width: 100vw !important;
bottom: 0;
flex-direction: column;
padding-top: 8px;
}

&.osdSidecarFlyout--hide {
Expand Down
1 change: 0 additions & 1 deletion src/core/public/overlays/sidecar/sidecar_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export interface ISidecarConfig {
// takeover mode will docked to bottom
dockedMode: SIDECAR_DOCKED_MODE;
paddingSize: number;
minSize?: number;
isHidden?: boolean;
}

Expand Down

0 comments on commit ea7c8f6

Please sign in to comment.