-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Unified search] Make resizable button as the EUI one (#137698)
* [Unified search] Make resizable button as the EUI one * Fix jest test * Add keyboard support * Convert to button, move to the border * Address PR comments * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * Fix the margin * recommended css changes Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Michael Marcialis <michael.marcialis@elastic.co>
- Loading branch information
1 parent
1bcd865
commit ef48e27
Showing
5 changed files
with
149 additions
and
15 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
87 changes: 87 additions & 0 deletions
87
...nified_search/public/query_string_input/text_based_languages_editor/resizable_button.scss
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
.unifiedTextLangEditor--resizableButtonContainer { | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.unifiedTextLangEditor--resizableButton { | ||
position: relative; | ||
flex-shrink: 0; | ||
z-index: 1; | ||
cursor: row-resize; | ||
height: $euiSize; | ||
margin-top: -($euiSize / 2); | ||
margin-bottom: -($euiSize / 2); | ||
|
||
&:before, | ||
&:after { | ||
content: ''; | ||
display: block; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
width: $euiSizeM; | ||
height: 1px; | ||
background-color: $euiColorDarkestShade; | ||
transition: ( | ||
width $euiAnimSpeedFast ease, | ||
height $euiAnimSpeedFast ease, | ||
transform $euiAnimSpeedFast ease, | ||
background-color $euiAnimSpeedFast ease | ||
); | ||
} | ||
|
||
&:before { | ||
transform: translate(-50%, -2px); | ||
} | ||
|
||
&:after { | ||
transform: translate(-50%, 2px); | ||
} | ||
|
||
//Lighten the "grab" icon on :hover | ||
&:hover:not(:disabled) { | ||
&:before, | ||
&:after { | ||
background-color: $euiColorMediumShade; | ||
transition-delay: $euiAnimSpeedFast; //Delay transition on hover so animation is not accidentally triggered on mouse over | ||
} | ||
} | ||
|
||
//Add a transparent background to the container and emphasis the "grab" icon with primary color on :focus | ||
&:focus:not(:disabled) { | ||
background-color: transparentize($euiColorPrimary, .9); | ||
|
||
&:before, | ||
&:after { | ||
background-color: $euiColorPrimary; | ||
// Overrides default transition so that "grab" icon background-color doesn't animate | ||
transition: ( | ||
width $euiAnimSpeedFast ease, | ||
height $euiAnimSpeedFast ease, | ||
transform $euiAnimSpeedFast ease | ||
); | ||
transition-delay: $euiAnimSpeedFast / 2; | ||
} | ||
} | ||
|
||
//Morph the "grab" icon into a fluid 2px straight line on :hover and :focus | ||
&:hover:not(:disabled), | ||
&:focus:not(:disabled) { | ||
&:before, | ||
&:after { | ||
width: 100%; | ||
} | ||
|
||
&:before { | ||
transform: translate(-50%, -1px); | ||
} | ||
|
||
&:after { | ||
transform: translate(-50%, 0); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...unified_search/public/query_string_input/text_based_languages_editor/resizable_button.tsx
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import './resizable_button.scss'; | ||
|
||
export function ResizableButton({ | ||
onMouseDownResizeHandler, | ||
onKeyDownResizeHandler, | ||
}: { | ||
onMouseDownResizeHandler: ( | ||
mouseDownEvent: React.MouseEvent<HTMLButtonElement, MouseEvent> | ||
) => void; | ||
onKeyDownResizeHandler: (keyDownEvernt: React.KeyboardEvent) => void; | ||
}) { | ||
const setFocus = (e: React.MouseEvent<HTMLButtonElement>) => e.currentTarget.focus(); | ||
|
||
return ( | ||
<div className="unifiedTextLangEditor--resizableButtonContainer"> | ||
<button | ||
data-test-subj="unifiedTextLangEditor-resize" | ||
className="unifiedTextLangEditor--resizableButton" | ||
onMouseDown={onMouseDownResizeHandler} | ||
onKeyDown={onKeyDownResizeHandler} | ||
onClick={setFocus} | ||
/> | ||
</div> | ||
); | ||
} |
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