Skip to content

Commit c52c29e

Browse files
committed
looks promising
1 parent 995a998 commit c52c29e

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
lines changed

src/command-pallette/CommandPalletteUI/CommandPaletteSearchBar.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
flex-grow: 1;
77
}
88

9-
@media (max-width: 1040px) {
9+
@container (max-width: 1040px) {
1010
.command-palette-search-bar {
1111
width: 100% !important;
1212
}

src/command-pallette/CommandPalletteUI/CommandPaletteSearchBar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useEffect, RefObject, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { createPortal } from 'react-dom';
4+
import { useRecoilValue } from 'recoil';
45
import { Icon, Input } from '@ui5/webcomponents-react';
56
import { K8sResource } from 'types';
67
import { useEventListener } from 'hooks/useEventListener';
78
import { useObjectState } from 'shared/useObjectState';
89
import { CommandPaletteUI } from './CommandPaletteUI';
9-
import { useRecoilValue } from 'recoil';
1010
import { availableNodesSelector } from 'state/navigation/availableNodesSelector';
1111
import { showKymaCompanionState } from 'state/companion/showKymaCompanionAtom';
1212
import { SCREEN_SIZE_BREAKPOINT_M } from './types';
@@ -103,6 +103,8 @@ export function CommandPaletteSearchBar({
103103
}
104104
}, [shellbarRef?.current, shellbarWidth, shouldShowDialog]); // eslint-disable-line react-hooks/exhaustive-deps
105105

106+
const htmlWrapEl = document.getElementById('html-wrap');
107+
106108
return (
107109
<>
108110
<Input
@@ -126,8 +128,9 @@ export function CommandPaletteSearchBar({
126128
}}
127129
resourceCache={resourceCache}
128130
updateResourceCache={updateResourceCache}
131+
shellbarWidth={shellbarWidth}
129132
/>,
130-
document.body,
133+
htmlWrapEl || document.body,
131134
)}
132135
</>
133136
);

src/command-pallette/CommandPalletteUI/CommandPaletteUI.scss

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.command-palette-ui {
2-
position: fixed;
2+
position: absolute;
33
top: calc(var(--_ui5-v2-7-0_shellbar_root_height) + 0.5rem);
44
width: 100%;
55
height: 100%;
@@ -14,8 +14,8 @@
1414
display: flex;
1515
width: 60vw;
1616
max-width: 700px;
17-
position: fixed;
18-
top: 0.5rem;
17+
position: absolute;
18+
top: calc(var(--_ui5-v2-7-0_shellbar_root_height) * -1);
1919
opacity: 0%; //prevent visually jumping
2020
}
2121

@@ -43,12 +43,11 @@
4343
}
4444
}
4545

46-
@media (max-width: 1040px) {
47-
.command-palette-ui {
46+
.command-palette-ui {
47+
@media (max-width: 1040px) {
4848
&__wrapper {
49-
width: 100vw;
49+
width: 100%;
5050
max-width: unset;
51-
top: 0;
5251
height: 100%;
5352
opacity: 100%;
5453
}
@@ -70,3 +69,28 @@
7069
}
7170
}
7271
}
72+
73+
.command-palette-ui {
74+
&__wrapper.full-size {
75+
width: 100%;
76+
max-width: unset;
77+
height: 100%;
78+
opacity: 100%;
79+
80+
.input-container {
81+
display: flex;
82+
flex-direction: row;
83+
align-items: center;
84+
85+
.search-with-display-more {
86+
margin-right: 2.5rem;
87+
}
88+
89+
.input-back-button {
90+
display: block;
91+
padding: 0 0.25rem;
92+
box-sizing: content-box;
93+
}
94+
}
95+
}
96+
}

src/command-pallette/CommandPalletteUI/CommandPaletteUI.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Button, Icon, Input } from '@ui5/webcomponents-react';
1616
import './CommandPaletteUI.scss';
1717
import { handleActionIfFormOpen } from 'shared/components/UnsavedMessageBox/helpers';
1818
import { isResourceEditedState } from 'state/resourceEditedAtom';
19+
import { showKymaCompanionState } from 'state/companion/showKymaCompanionAtom';
1920
import { isFormOpenState } from 'state/formOpenAtom';
2021
import { SCREEN_SIZE_BREAKPOINT_M } from './types';
2122

@@ -46,13 +47,15 @@ type CommandPaletteProps = {
4647
hide: () => void;
4748
resourceCache: Record<string, K8sResource[]>;
4849
updateResourceCache: (key: string, resources: K8sResource[]) => void;
50+
shellbarWidth: number;
4951
};
5052

5153
export function CommandPaletteUI({
5254
showCommandPalette,
5355
hide,
5456
resourceCache,
5557
updateResourceCache,
58+
shellbarWidth,
5659
}: CommandPaletteProps) {
5760
const namespace = useRecoilValue(activeNamespaceIdState);
5861
const [isResourceEdited, setIsResourceEdited] = useRecoilState(
@@ -69,6 +72,7 @@ export function CommandPaletteUI({
6972
const [activeResultIndex, setActiveResultIndex] = useState(0);
7073
const [isHistoryMode, setHistoryMode] = useState(false);
7174
const [historyIndex, setHistoryIndex] = useState(0);
75+
const showCompanion = useRecoilValue(showKymaCompanionState);
7276

7377
const commandPaletteRef = useRef<HTMLDivElement | null>(null);
7478

@@ -110,18 +114,19 @@ export function CommandPaletteUI({
110114

111115
//position Command Palette
112116
if (
113-
window.innerWidth > SCREEN_SIZE_BREAKPOINT_M &&
117+
shellbarWidth > SCREEN_SIZE_BREAKPOINT_M &&
114118
headerInput &&
115119
paletteCurrent
116120
) {
117121
const shellbarRect = headerInput.getBoundingClientRect();
118-
paletteCurrent.style.right = `${window.innerWidth -
119-
shellbarRect.right}px`;
122+
paletteCurrent.style.right = `${shellbarWidth - shellbarRect.right}px`;
123+
paletteCurrent.style.left = 'unset';
120124
paletteCurrent.style.opacity = '100%'; //prevent visually jumping
121125
} else if (paletteCurrent) {
122126
paletteCurrent.style.right = '0px';
127+
paletteCurrent.style.left = '0px';
123128
}
124-
}, [showCommandPalette, window.innerWidth]); // eslint-disable-line react-hooks/exhaustive-deps
129+
}, [showCommandPalette, shellbarWidth, showCommandPalette]); // eslint-disable-line react-hooks/exhaustive-deps
125130

126131
const commandPaletteInput = document.getElementById('command-palette-search');
127132

@@ -233,11 +238,14 @@ export function CommandPaletteUI({
233238
},
234239
[isHistoryMode, activeResultIndex, query, results],
235240
);
236-
237241
return (
238242
<Background hide={hide}>
239243
<div
240-
className="command-palette-ui__wrapper"
244+
className={`command-palette-ui__wrapper ${
245+
showCompanion.show && shellbarWidth < SCREEN_SIZE_BREAKPOINT_M
246+
? 'full-size'
247+
: ''
248+
}`}
241249
role="dialog"
242250
ref={commandPaletteRef}
243251
>

0 commit comments

Comments
 (0)