|
1 | 1 | import React from 'react';
|
2 | 2 | import propTypes from 'prop-types';
|
3 | 3 |
|
4 |
| -import styled from 'styled-components'; |
| 4 | +import styled, { css } from 'styled-components'; |
5 | 5 | import { createBorderStyles, createBoxStyles } from '../common';
|
6 | 6 |
|
7 | 7 | const StyledWindow = styled.div`
|
8 | 8 | position: relative;
|
9 |
| - padding: 2px; |
| 9 | + padding: 4px; |
10 | 10 | ${createBorderStyles({ windowBorders: true })}
|
11 | 11 | ${createBoxStyles()}
|
12 | 12 | `;
|
| 13 | +const ResizeHandle = styled.span` |
| 14 | + ${({ theme }) => css` |
| 15 | + display: inline-block; |
| 16 | + position: absolute; |
| 17 | + bottom: 4px; |
| 18 | + right: 4px; |
| 19 | + width: 25px; |
| 20 | + height: 25px; |
| 21 | + background-image: linear-gradient( |
| 22 | + 135deg, |
| 23 | + ${theme.borderLightest} 16.67%, |
| 24 | + ${theme.material} 16.67%, |
| 25 | + ${theme.material} 33.33%, |
| 26 | + ${theme.borderDark} 33.33%, |
| 27 | + ${theme.borderDark} 50%, |
| 28 | + ${theme.borderLightest} 50%, |
| 29 | + ${theme.borderLightest} 66.67%, |
| 30 | + ${theme.material} 66.67%, |
| 31 | + ${theme.material} 83.33%, |
| 32 | + ${theme.borderDark} 83.33%, |
| 33 | + ${theme.borderDark} 100% |
| 34 | + ); |
| 35 | + background-size: 8.49px 8.49px; |
| 36 | + clip-path: polygon(100% 0px, 0px 100%, 100% 100%); |
| 37 | + border-width: 2px; |
| 38 | + border-style: solid; |
| 39 | + border-color: ${theme.material}; |
| 40 | + cursor: nwse-resize; |
| 41 | + `} |
| 42 | +`; |
13 | 43 |
|
14 |
| -const Window = ({ shadow, className, children, ...otherProps }) => ( |
15 |
| - <StyledWindow shadow={shadow} className={className} {...otherProps} swag> |
| 44 | +const Window = ({ resizable, shadow, children, ...otherProps }) => ( |
| 45 | + <StyledWindow shadow={shadow} {...otherProps}> |
16 | 46 | {children}
|
| 47 | + {resizable && <ResizeHandle data-testid='resizeHandle' />} |
17 | 48 | </StyledWindow>
|
18 | 49 | );
|
19 | 50 |
|
20 | 51 | Window.defaultProps = {
|
| 52 | + resizable: false, |
21 | 53 | shadow: true,
|
22 |
| - className: '', |
23 | 54 | children: null
|
24 | 55 | };
|
25 | 56 |
|
26 | 57 | Window.propTypes = {
|
27 | 58 | shadow: propTypes.bool,
|
28 |
| - className: propTypes.string, |
| 59 | + resizable: propTypes.bool, |
29 | 60 | children: propTypes.node
|
30 | 61 | };
|
31 | 62 |
|
|
0 commit comments