Skip to content

Commit

Permalink
Convert to button, move to the border
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Aug 4, 2022
1 parent d1fb8c0 commit 8a0a47c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
const onKeyDownResizeHandler = useCallback(
(keyDownEvent) => {
let height = editorHeight;
if (keyDownEvent.keyCode === KEYCODE_ARROW_UP) {
height = height - 1;
const validatedHeight = Math.min(Math.max(height, EDITOR_MIN_HEIGHT), EDITOR_MAX_HEIGHT);
setEditorHeight(validatedHeight);
}

if (keyDownEvent.keyCode === KEYCODE_ARROW_DOWN) {
height = height + 1;
if (
keyDownEvent.keyCode === KEYCODE_ARROW_UP ||
keyDownEvent.keyCode === KEYCODE_ARROW_DOWN
) {
const step = keyDownEvent.keyCode === KEYCODE_ARROW_UP ? -10 : 10;
height = height + step;
const validatedHeight = Math.min(Math.max(height, EDITOR_MIN_HEIGHT), EDITOR_MAX_HEIGHT);
setEditorHeight(validatedHeight);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

.unifiedTextLangEditor--resizableButtonWrapper {
position: relative;
}

.unifiedTextLangEditor--resizableButtonContainer {
text-align: center;
position: absolute;
width: 100%;
top: $euiSizeS;
}

.unifiedTextLangEditor--resizableButton {
Expand Down Expand Up @@ -35,7 +41,7 @@
}

&:after {
transform: translate(-50%, 1px);
transform: translate(-50%, 2px);
}

//Lighten the "grab" icon on :hover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,38 @@
*/

import React from 'react';
import { EuiFlexGroup } from '@elastic/eui';

import './resizable_button.scss';

export function ResizableButton({
onMouseDownResizeHandler,
onKeyDownResizeHandler,
}: {
onMouseDownResizeHandler: (mouseDownEvent: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
onMouseDownResizeHandler: (
mouseDownEvent: React.MouseEvent<HTMLButtonElement, MouseEvent>
) => void;
onKeyDownResizeHandler: (keyDownEvernt: React.KeyboardEvent) => void;
}) {
const setFocus = (e: React.MouseEvent<HTMLDivElement>) => e.currentTarget.focus();
const setFocus = (e: React.MouseEvent<HTMLButtonElement>) => e.currentTarget.focus();

return (
// <div className="unifiedTextLangEditor--resizableButtonContainer">
<div
data-test-subj="unifiedTextLangEditor-resize"
tabIndex={-1}
className="unifiedTextLangEditor--resizableButton"
onMouseDown={onMouseDownResizeHandler}
onKeyDown={onKeyDownResizeHandler}
onClick={setFocus}
aria-hidden="true"
/>
// </div>
<div className="unifiedTextLangEditor--resizableButtonWrapper">
<EuiFlexGroup
direction="column"
gutterSize="none"
className="unifiedTextLangEditor--resizableButtonContainer"
>
<button
data-test-subj="unifiedTextLangEditor-resize"
tabIndex={-1}
className="unifiedTextLangEditor--resizableButton"
onMouseDown={onMouseDownResizeHandler}
onKeyDown={onKeyDownResizeHandler}
onClick={setFocus}
aria-hidden="true"
/>
</EuiFlexGroup>
</div>
);
}

0 comments on commit 8a0a47c

Please sign in to comment.