123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import {CSSProperties} from 'react';
- import BaseResizePanel from 'react-resize-panel';
- import styled from '@emotion/styled';
- type Props = {
- direction: 'n' | 'e' | 's' | 'w';
- minHeight?: number;
- minWidth?: number;
- modifierClass?: string;
- style?: CSSProperties;
- };
- export const CLASSNAMES = {
- bar: {
- height: 'resizeHeightBar',
- width: 'resizeWidthBar',
- },
- handle: {
- height: 'resizeHeightHandle',
- width: 'resizeWidthHandle',
- },
- };
- const ResizePanel = styled(function ResizePanelContent({
- direction,
- modifierClass = '',
- ...props
- }: Props) {
- const movesUpDown = ['n', 's'].includes(direction);
- const borderClass = movesUpDown ? CLASSNAMES.bar.height : CLASSNAMES.bar.width;
- const handleClass = movesUpDown ? CLASSNAMES.handle.height : CLASSNAMES.handle.width;
- return (
- <BaseResizePanel
- direction={direction}
- {...props}
- borderClass={`${borderClass} ${modifierClass}`}
- handleClass={`${handleClass} ${modifierClass}`}
- />
- );
- })`
- position: relative;
- `;
- export default ResizePanel;
|