-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(SplitPanel): Refactor SplitDivider to not have dynamic css (#55138)
<!-- Describe your PR here. -->
- Loading branch information
Showing
3 changed files
with
44 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,51 @@ | ||
import {DOMAttributes} from 'react'; | ||
import type {DOMAttributes, MouseEventHandler} from 'react'; | ||
import styled from '@emotion/styled'; | ||
|
||
import {IconGrabbable} from 'sentry/icons'; | ||
import {space} from 'sentry/styles/space'; | ||
|
||
type Props = { | ||
isHeld: boolean; | ||
slideDirection: 'leftright' | 'updown'; | ||
'data-is-held': boolean; | ||
'data-slide-direction': 'leftright' | 'updown'; | ||
onDoubleClick: MouseEventHandler<HTMLElement>; | ||
onMouseDown: MouseEventHandler<HTMLElement>; | ||
}; | ||
|
||
const SplitDivider = styled( | ||
({isHeld: _a, slideDirection: _b, ...props}: Props & DOMAttributes<HTMLDivElement>) => ( | ||
<div {...props}> | ||
<IconGrabbable size="sm" /> | ||
</div> | ||
) | ||
)<Props>` | ||
const SplitDivider = styled((props: Props & DOMAttributes<HTMLDivElement>) => ( | ||
<div {...props}> | ||
<IconGrabbable size="sm" /> | ||
</div> | ||
))<Props>` | ||
display: grid; | ||
place-items: center; | ||
height: 100%; | ||
width: 100%; | ||
user-select: ${p => (p.isHeld ? 'none' : 'inherit')}; | ||
background: ${p => (p.isHeld ? p.theme.hover : 'inherit')}; | ||
user-select: inherit; | ||
background: inherit; | ||
:hover { | ||
&:hover, | ||
&[data-is-held='true'] { | ||
background: ${p => p.theme.hover}; | ||
} | ||
&[data-is-held='true'] { | ||
user-select: none; | ||
} | ||
${p => | ||
p.slideDirection === 'leftright' | ||
? ` | ||
cursor: ew-resize; | ||
height: 100%; | ||
width: ${space(2)}; | ||
` | ||
: ` | ||
cursor: ns-resize; | ||
width: 100%; | ||
height: ${space(2)}; | ||
& > svg { | ||
transform: rotate(90deg); | ||
} | ||
`} | ||
&[data-slide-direction='leftright'] { | ||
cursor: ew-resize; | ||
height: 100%; | ||
width: ${space(2)}; | ||
} | ||
&[data-slide-direction='updown'] { | ||
cursor: ns-resize; | ||
width: 100%; | ||
height: ${space(2)}; | ||
& > svg { | ||
transform: rotate(90deg); | ||
} | ||
} | ||
`; | ||
|
||
export default SplitDivider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters