Skip to content

Commit 3b5e510

Browse files
authored
Move the input toolbar below the input prompt (#278)
* Move the input toolbar below the input prompt * lint
1 parent 7a906eb commit 3b5e510

File tree

3 files changed

+82
-57
lines changed

3 files changed

+82
-57
lines changed

packages/jupyter-chat/src/components/input/chat-input.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
Autocomplete,
88
AutocompleteInputChangeReason,
99
Box,
10-
InputAdornment,
1110
SxProps,
1211
TextField,
13-
Theme
12+
Theme,
13+
Toolbar
1414
} from '@mui/material';
1515
import clsx from 'clsx';
1616
import React, { useEffect, useRef, useState } from 'react';
@@ -26,6 +26,8 @@ import { IChatCommandRegistry } from '../../registers';
2626
import { IAttachment } from '../../types';
2727

2828
const INPUT_BOX_CLASS = 'jp-chat-input-container';
29+
const INPUT_TEXTFIELD_CLASS = 'jp-chat-input-textfield';
30+
const INPUT_COMPONENT_CLASS = 'jp-chat-input-component';
2931
const INPUT_TOOLBAR_CLASS = 'jp-chat-input-toolbar';
3032

3133
export function ChatInput(props: ChatInput.IProps): JSX.Element {
@@ -206,7 +208,8 @@ export function ChatInput(props: ChatInput.IProps): JSX.Element {
206208
<TextField
207209
{...params}
208210
fullWidth
209-
variant="outlined"
211+
variant="filled"
212+
className={INPUT_TEXTFIELD_CLASS}
210213
multiline
211214
onKeyDown={handleKeyDown}
212215
placeholder="Start chatting"
@@ -217,21 +220,9 @@ export function ChatInput(props: ChatInput.IProps): JSX.Element {
217220
}
218221
InputProps={{
219222
...params.InputProps,
220-
endAdornment: (
221-
<InputAdornment position="end" className={INPUT_TOOLBAR_CLASS}>
222-
{toolbarElements.map(item => (
223-
<item.element
224-
model={model}
225-
chatCommandRegistry={props.chatCommandRegistry}
226-
/>
227-
))}
228-
</InputAdornment>
229-
)
223+
className: INPUT_COMPONENT_CLASS
230224
}}
231-
FormHelperTextProps={{
232-
sx: { marginLeft: 'auto', marginRight: 0 }
233-
}}
234-
helperText={input.length > 2 ? helperText : ' '}
225+
label={input.length > 2 ? helperText : ' '}
235226
/>
236227
)}
237228
inputValue={input}
@@ -248,6 +239,14 @@ export function ChatInput(props: ChatInput.IProps): JSX.Element {
248239
}
249240
}}
250241
/>
242+
<Toolbar className={INPUT_TOOLBAR_CLASS}>
243+
{toolbarElements.map(item => (
244+
<item.element
245+
model={model}
246+
chatCommandRegistry={props.chatCommandRegistry}
247+
/>
248+
))}
249+
</Toolbar>
251250
</Box>
252251
);
253252
}

packages/jupyter-chat/style/chat.css

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,7 @@
202202
gap: 4px;
203203
flex-wrap: wrap;
204204
min-height: 1.5em;
205-
padding: 8px 0;
206-
}
207-
208-
.jp-chat-attachments:empty {
209-
padding: 8px 0;
210-
min-height: 1.5em;
205+
padding: 4px 0;
211206
}
212207

213208
.jp-chat-attachment {

packages/jupyter-chat/style/input.css

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,16 @@
33
* Distributed under the terms of the Modified BSD License.
44
*/
55

6-
.jp-chat-input-toolbar {
7-
gap: 1px;
8-
}
9-
10-
.jp-chat-input-toolbar .jp-chat-tooltipped-wrap button {
11-
border-radius: 0;
12-
min-width: unset;
13-
}
14-
15-
.jp-chat-input-toolbar .jp-chat-tooltipped-wrap:first-child button {
16-
border-top-left-radius: 2px;
17-
border-bottom-left-radius: 2px;
18-
}
19-
20-
.jp-chat-input-toolbar .jp-chat-tooltipped-wrap:last-child button {
21-
border-top-right-radius: 2px;
22-
border-bottom-right-radius: 2px;
23-
}
24-
25-
.jp-chat-input-toolbar .jp-chat-attach-button,
26-
.jp-chat-input-toolbar .jp-chat-cancel-button {
27-
padding: 4px;
28-
}
29-
30-
.jp-chat-input-toolbar .jp-chat-send-include-opener {
31-
padding: 4px 0;
32-
}
33-
6+
/*
7+
* INPUT CONTAINER (component and toolbar)
8+
*/
349
.jp-chat-input-container {
3510
position: relative;
3611
transition: all 150ms ease;
3712
display: flex;
3813
flex-direction: column;
3914
justify-content: center;
4015
min-height: 56px;
41-
padding: 8px 0;
42-
}
43-
44-
/* stylelint-disable-next-line selector-class-pattern */
45-
.jp-chat-input-container .MuiTextField-root {
46-
padding-bottom: 8px;
4716
}
4817

4918
.jp-chat-input-container.jp-chat-drag-hover::after {
@@ -72,3 +41,65 @@
7241
border-radius: 3px;
7342
white-space: nowrap;
7443
}
44+
45+
/*
46+
* INPUT TEXT FIELD
47+
*/
48+
.jp-chat-input-component {
49+
border: 1px solid var(--jp-ui-font-color3);
50+
border-radius: 4px;
51+
}
52+
53+
.jp-chat-input-textfield .jp-chat-input-component::before,
54+
.jp-chat-input-textfield .jp-chat-input-component::after {
55+
border-bottom: unset !important;
56+
}
57+
58+
/* Use the textfield label below the input. */
59+
.jp-chat-input-textfield .jp-chat-input-component {
60+
padding-top: 8px !important;
61+
padding-bottom: 15px !important;
62+
background-color: unset !important;
63+
}
64+
65+
.jp-chat-input-textfield label {
66+
top: unset;
67+
left: unset;
68+
bottom: 0;
69+
right: 0;
70+
color: var(--jp-ui-font-color2) !important;
71+
}
72+
73+
/*
74+
* INPUT TOOLBAR
75+
*/
76+
.jp-chat-input-toolbar {
77+
gap: 1px;
78+
align-self: flex-end;
79+
min-height: unset !important;
80+
margin-bottom: 4px;
81+
}
82+
83+
.jp-chat-input-toolbar .jp-chat-tooltipped-wrap button {
84+
border-radius: 0;
85+
min-width: unset;
86+
}
87+
88+
.jp-chat-input-toolbar .jp-chat-tooltipped-wrap:first-child button {
89+
border-top-left-radius: 2px;
90+
border-bottom-left-radius: 2px;
91+
}
92+
93+
.jp-chat-input-toolbar .jp-chat-tooltipped-wrap:last-child button {
94+
border-top-right-radius: 2px;
95+
border-bottom-right-radius: 2px;
96+
}
97+
98+
.jp-chat-input-toolbar .jp-chat-attach-button,
99+
.jp-chat-input-toolbar .jp-chat-cancel-button {
100+
padding: 4px;
101+
}
102+
103+
.jp-chat-input-toolbar .jp-chat-send-include-opener {
104+
padding: 4px 0;
105+
}

0 commit comments

Comments
 (0)