Skip to content

Commit d6d102b

Browse files
authored
Merge pull request #159 from ModusCreateOrg/ADE-200-Adam-fix
[ADE-200] UI fixes
2 parents bb9f134 + da8c72a commit d6d102b

File tree

5 files changed

+72
-47
lines changed

5 files changed

+72
-47
lines changed

frontend/src/common/components/AIAssistant/AIAssistantModal.scss

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
.ai-assistant-modal-body {
2+
border: 1px solid #fbd3f8;
3+
border-radius: 1rem;
4+
width: 100%;
5+
height: 100%;
6+
}
7+
18
.ai-assistant-modal {
29
--height: auto;
310
--max-height: 70vh;
411
--border-radius: 1rem;
5-
--box-shadow: 0 -0.25rem 1rem rgba(0, 0, 0, 0.1);
12+
--box-shadow: 0 -0.25rem 1rem rgb(0 0 0 / 10%);
613
--backdrop-opacity: 0.3;
14+
715
align-items: flex-end;
816
transition:
917
--height 0.3s ease-out,
@@ -14,13 +22,13 @@
1422
--max-height: 85vh;
1523

1624
&::part(content) {
17-
margin: 2rem 1rem 5rem 1rem;
25+
margin: 2rem 1rem 5rem;
1826
}
1927
}
2028

2129
&::part(content) {
2230
border-radius: var(--border-radius);
23-
margin: 0 1rem 5rem 1rem;
31+
margin: 0 1rem 5rem;
2432
display: flex;
2533
flex-direction: column;
2634
transition: margin 0.3s ease-out;
@@ -62,8 +70,10 @@
6270

6371
.ai-assistant-content {
6472
--padding: 0;
73+
6574
flex: 1;
66-
overflow: hidden;
75+
overflow: scroll;
76+
height: 80%;
6777
}
6878

6979
.ai-assistant-footer {

frontend/src/common/components/AIAssistant/AIAssistantModal.tsx

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -90,42 +90,44 @@ const AIAssistantModal: React.FC<AIAssistantModalProps> = ({
9090
data-testid={testid}
9191
aria-labelledby="ai-assistant-title"
9292
>
93-
<IonHeader className="ai-assistant-header">
94-
<IonToolbar className="ai-assistant-toolbar">
95-
<div className="ai-assistant-title-container">
96-
<img src={aiIcon} alt="AI Assistant Icon" className="ai-assistant-title-icon" />
97-
<span className="ai-assistant-title-text">AI Assistant</span>
98-
</div>
99-
<IonButtons slot="end">
100-
<IonButton
101-
onClick={handleExpand}
102-
aria-label={isExpanded ? 'Collapse chat' : 'Expand chat'}
103-
data-testid={`${testid}-expand-button`}
104-
>
105-
<IonIcon icon={isExpanded ? contractOutline : expandOutline} aria-hidden="true" />
106-
</IonButton>
107-
<IonButton
108-
onClick={handleClose}
109-
aria-label="Close AI Assistant"
110-
data-testid={`${testid}-close-button`}
111-
>
112-
<IonIcon icon={closeOutline} aria-hidden="true" />
113-
</IonButton>
114-
</IonButtons>
115-
</IonToolbar>
116-
</IonHeader>
93+
<div className="ai-assistant-modal-body">
94+
<IonHeader className="ai-assistant-header">
95+
<IonToolbar className="ai-assistant-toolbar">
96+
<div className="ai-assistant-title-container">
97+
<img src={aiIcon} alt="AI Assistant Icon" className="ai-assistant-title-icon" />
98+
<span className="ai-assistant-title-text">AI Assistant</span>
99+
</div>
100+
<IonButtons slot="end">
101+
<IonButton
102+
onClick={handleExpand}
103+
aria-label={isExpanded ? 'Collapse chat' : 'Expand chat'}
104+
data-testid={`${testid}-expand-button`}
105+
>
106+
<IonIcon icon={isExpanded ? contractOutline : expandOutline} aria-hidden="true" />
107+
</IonButton>
108+
<IonButton
109+
onClick={handleClose}
110+
aria-label="Close AI Assistant"
111+
data-testid={`${testid}-close-button`}
112+
>
113+
<IonIcon icon={closeOutline} aria-hidden="true" />
114+
</IonButton>
115+
</IonButtons>
116+
</IonToolbar>
117+
</IonHeader>
117118

118-
<IonContent className="ai-assistant-content">
119-
<ChatContainer
120-
messages={messages}
121-
robotIcon={faRobot}
122-
testid={`${testid}-chat-container`}
123-
/>
124-
</IonContent>
119+
<IonContent className="ai-assistant-content">
120+
<ChatContainer
121+
messages={messages}
122+
robotIcon={faRobot}
123+
testid={`${testid}-chat-container`}
124+
/>
125+
</IonContent>
125126

126-
<IonFooter className="ai-assistant-footer">
127-
<ChatInput onSendMessage={handleSendMessage} testid={`${testid}-input`} />
128-
</IonFooter>
127+
<IonFooter className="ai-assistant-footer">
128+
<ChatInput onSendMessage={handleSendMessage} testid={`${testid}-input`} />
129+
</IonFooter>
130+
</div>
129131
</IonModal>
130132
);
131133
};

frontend/src/common/components/Chat/ChatContainer.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useEffect, useRef } from 'react';
2-
import { useTranslation } from 'react-i18next';
32
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
43
import ChatMessage, { ChatMessageData } from './ChatMessage';
54
import './ChatContainer.scss';
@@ -23,7 +22,6 @@ const ChatContainer: React.FC<ChatContainerProps> = ({
2322
testid = 'chat-container',
2423
className = '',
2524
}) => {
26-
const { t } = useTranslation();
2725
const chatContainerRef = useRef<HTMLDivElement>(null);
2826

2927
// Auto-scroll to bottom when new messages arrive
@@ -41,11 +39,7 @@ const ChatContainer: React.FC<ChatContainerProps> = ({
4139
aria-label="Chat messages"
4240
data-testid={testid}
4341
>
44-
{messages.length === 0 ? (
45-
<div className="chat-empty-state" data-testid={`${testid}-empty`}>
46-
<p>{t('aiAssistant.emptyState', 'How can I help you today?')}</p>
47-
</div>
48-
) : (
42+
{messages.length > 0 &&
4943
messages.map((message) => (
5044
<ChatMessage
5145
key={message.id}
@@ -54,8 +48,7 @@ const ChatContainer: React.FC<ChatContainerProps> = ({
5448
robotIcon={robotIcon}
5549
testid={`${testid}-message`}
5650
/>
57-
))
58-
)}
51+
))}
5952
</div>
6053
);
6154
};

frontend/src/common/components/Chat/ChatInput.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
flex: 1;
1717
width: 100%;
1818
background-color: var(--ion-color-light);
19+
1920
--padding-start: 1rem;
2021
--padding-end: 1rem;
2122
--padding-top: 0.75rem;
2223
--padding-bottom: 0.75rem;
2324
--placeholder-color: var(--ion-color-medium);
2425
--placeholder-opacity: 0.8;
26+
2527
border-radius: 1.5rem;
2628
margin-right: 3.5rem;
29+
border: 1px solid #ccc;
2730
}
2831

2932
.send-fab {
@@ -32,6 +35,7 @@
3235
.send-button {
3336
--background: var(--ion-color-primary);
3437
--ion-color-base: var(--ion-color-primary);
38+
3539
width: 3rem;
3640
height: 3rem;
3741
margin: 0;

frontend/src/pages/Chat/ChatPage.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/rea
22
import { useTranslation } from 'react-i18next';
33
import { useState, useEffect, useRef } from 'react';
44
import { useLocation } from 'react-router-dom';
5+
import { useHistory } from 'react-router';
6+
import closeIcon from 'assets/icons/close.svg';
57
import ChatContainer from '../../common/components/Chat/ChatContainer';
68
import ChatInput from '../../common/components/Chat/ChatInput';
79
import { chatService } from '../../common/services/ChatService';
@@ -19,11 +21,17 @@ const ChatPage = (): JSX.Element => {
1921
const [messages, setMessages] = useState<ChatMessageData[]>([]);
2022
const location = useLocation();
2123
const prevPathRef = useRef(location.pathname);
24+
const history = useHistory();
2225

2326
const resetChatState = () => {
2427
setMessages([]);
2528
};
2629

30+
// Handle close button
31+
const handleClose = () => {
32+
history.push('/tabs/home');
33+
};
34+
2735
// Handle initial setup and cleanup
2836
useEffect(() => {
2937
// Create a new session when the component mounts using an IIFE
@@ -92,6 +100,14 @@ const ChatPage = (): JSX.Element => {
92100
<span>{t('pages.chat.title', 'AI Assistant')}</span>
93101
</div>
94102
</IonTitle>
103+
<div slot="end">
104+
<button
105+
onClick={handleClose}
106+
style={{ backgroundColor: 'transparent', marginRight: '2em' }}
107+
>
108+
<img src={closeIcon} alt="Close" />
109+
</button>
110+
</div>
95111
</IonToolbar>
96112
</IonHeader>
97113
<IonContent className="chat-page-content">

0 commit comments

Comments
 (0)