Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/resize as optional #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ Modal from Ant Design, draggable.
- [x] During resize window.
- [x] Multiple modals with managed `zIndex`.
- [x] Open from center.
- [x] Resize with option key.
- [ ] Better API for using as a controlled component.
- [ ] Open from quadrants.
- [ ] Better escape key management.
- [ ] Resize with option key.

## 📦 Install

Expand Down
23 changes: 14 additions & 9 deletions packages/ant-design-draggable-modal/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* NOTE: This is not compiled.
*/

.ant-design-draggable-modal {
.ant-design-draggable-modal {
pointer-events: none;
overflow: hidden !important;
}
Expand Down Expand Up @@ -44,6 +44,19 @@
padding: 16px;
}

.ant-design-draggable-modal-resize-handle {
right: -10px;
width: 44px;
bottom: -10px;
cursor: se-resize;
height: 44px;
position: absolute;
}

.ant-design-draggable-modal--without-resize {
display: none;
}

.ant-design-draggable-modal-resize-handle-inner {
width: 12px;
right: 14px;
Expand All @@ -55,11 +68,3 @@
border-left: 0;
}

.ant-design-draggable-modal-resize-handle {
right: -10px;
width: 44px;
bottom: -10px;
cursor: se-resize;
height: 44px;
position: absolute;
}
31 changes: 31 additions & 0 deletions packages/ant-design-draggable-modal/src/ResizeHandle.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from 'react'
import { render } from '@testing-library/react'
import { ResizeHandle } from './ResizeHandle'

describe('should render correctly', () => {
it('shoude render with resize', () => {
const { container } = render(<ResizeHandle resize />)
expect(container.firstChild).toMatchInlineSnapshot(`
<div
class="ant-design-draggable-modal-resize-handle"
>
<div
class="ant-design-draggable-modal-resize-handle-inner"
/>
</div>
`)
})

it('shoude render without resize', () => {
const { container } = render(<ResizeHandle resize={false} />)
expect(container.firstChild).toMatchInlineSnapshot(`
<div
class="ant-design-draggable-modal--without-resize"
>
<div
class="ant-design-draggable-modal-resize-handle-inner"
/>
</div>
`)
})
})
12 changes: 7 additions & 5 deletions packages/ant-design-draggable-modal/src/ResizeHandle.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as React from 'react'

export const ResizeHandle = (
props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>,
): React.ReactElement => (
<div className="ant-design-draggable-modal-resize-handle" {...props}>
interface ResizeHandleProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>{
resize?: boolean
}

export const ResizeHandle = ({resize = true, ...props}: ResizeHandleProps) => (
<div className={resize ? 'ant-design-draggable-modal-resize-handle' : 'ant-design-draggable-modal--without-resize'} {...props}>
<div className="ant-design-draggable-modal-resize-handle-inner" />
</div>
)
)