Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Odysseus] Overhauling framework in line with backend services #78989

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initial fixes for the Wapuu Widget
  • Loading branch information
AllTerrainDeveloper committed Jul 4, 2023
commit 4989b1ab23e4773386d307ddb71a7871884a588b
13 changes: 11 additions & 2 deletions client/odysseus/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TextControl, Button } from '@wordpress/components';
import classnames from 'classnames';
import { useRef, useEffect, useState } from 'react';
import { useSelector } from 'calypso/state';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
Expand All @@ -21,6 +22,8 @@ const OdysseusAssistant = () => {
{ content: 'Hello, I am Wapuu! Your personal assistant.', role: 'assistant' },
] );

const environmentBadge = document.querySelector( 'body > .environment-badge' );

// Clear messages when switching sections
useEffect( () => {
setMessages( [] );
Expand Down Expand Up @@ -108,7 +111,13 @@ const OdysseusAssistant = () => {
}

return (
<div className={ `chatbox ${ isVisible ? 'chatbox-show' : 'chatbox-hide' }` }>
<div
className={ classnames( 'chatbox', {
'chatbox-show': isVisible,
'chatbox-hide': ! isVisible,
'using-environment-badge': environmentBadge,
} ) }
>
<WapuuRibbon
onToggleVisibility={ handleToggleVisibility }
isNudging={ isNudging }
Expand All @@ -119,13 +128,13 @@ const OdysseusAssistant = () => {
<div className="chatbox-messages">
{ messages.map( ( message, index ) => (
<div
ref={ index === messages.length - 1 ? messagesEndRef : null }
className={ `chatbox-message ${ message.role === 'user' ? 'user' : 'wapuu' }` }
key={ index }
>
{ message.content }
</div>
) ) }
<div ref={ messagesEndRef } />
</div>
<form onSubmit={ handleFormSubmit }>
<div className="chatbox-input-area">
Expand Down
11 changes: 8 additions & 3 deletions client/odysseus/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.chatbox {
position: fixed;
bottom: 64px;
bottom: 20px;
right: 20px;
width: 300px;
height: 400px;
Expand Down Expand Up @@ -51,7 +51,7 @@
}

.chatbox-messages {
overflow-y: scroll;
overflow-y: auto;
word-wrap: break-word;
padding: 12px;
border-radius: 4px;
Expand All @@ -61,7 +61,7 @@
display: flex;
flex-direction: column;
align-items: flex-start;
max-height: 294px;
max-height: 284px;
padding-bottom: 4px;
}

Expand Down Expand Up @@ -178,6 +178,11 @@
transform: rotate(15deg);
}
}

.chat-box-message-container {
width: 100%;
}

.using-environment-badge {
bottom: 64px;
}