-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add basic lms chat * refactor imports * comment transcript code * more enhancemen to provide context * fix chat display for all problems * more enhancements * more changes for the post message * styling of launch button * pass context from backend + added setting for the learn ai api URL * pre-commit fixes * add ask tim input + fixed styling * pre-commit fixes * fix bu * add chatId + pass Learning MFE URL * remove chat button alt * review changes
- Loading branch information
1 parent
a273f83
commit 8e960bf
Showing
11 changed files
with
195 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#app-root { | ||
width: 450px; | ||
height: 600px; | ||
} | ||
|
||
.video-block-chat-button-container { | ||
background: whitesmoke; | ||
box-shadow: | ||
0 -50px 0 12px whitesmoke, | ||
-12px 12px 0 0 whitesmoke, | ||
12px 12px 0 0 whitesmoke, | ||
0 2px 0 0 whitesmoke; | ||
} | ||
|
||
.ai-chat-button { | ||
display: flex; | ||
flex-direction: row; | ||
position: relative; | ||
bottom: 70px; | ||
left: 70%; | ||
width: fit-content; | ||
cursor: pointer; | ||
z-index: 1000; | ||
height: 48px; | ||
padding: 0 20px 0 24px; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 10px; | ||
align-self: stretch; | ||
border-radius: 4px; | ||
border: 2px solid #A31F34; | ||
background: #FFF; | ||
|
||
p { | ||
color: #A31F34; | ||
font-size: 16px; | ||
font-style: normal; | ||
font-weight: 500; | ||
line-height: 16px; | ||
margin-bottom: 0 !important; | ||
} | ||
|
||
.chat-icon { | ||
width: 24px; | ||
height: 24px; | ||
} | ||
|
||
&.video-block-chat-button { | ||
bottom: 0; | ||
left: 63%; | ||
margin-top: 50px; | ||
padding: 5px 20px 5px 24px; | ||
|
||
p { | ||
line-height: 20px; | ||
margin-right: 30px; | ||
} | ||
} | ||
|
||
&:hover { | ||
background: rgba(255, 0, 0, 0.06); | ||
} | ||
} | ||
|
||
@media screen and (max-width: 768px) { | ||
.ai-chat-button { | ||
bottom: 65px; | ||
left: 58%; | ||
|
||
&.video-block-chat-button { | ||
margin-top: 10px; | ||
left: 51%; | ||
} | ||
} | ||
} | ||
|
||
@media screen and (max-width: 425px) { | ||
.ai-chat-button { | ||
position: unset; | ||
margin-left: 0; | ||
} | ||
} | ||
|
||
.video { | ||
margin: 0 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,7 @@ | |
.enabled-checkbox { | ||
min-height: auto !important; | ||
} | ||
|
||
#ask-tim-drawer-title { | ||
min-height: unset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
<div> | ||
<button type="button" onclick="alert('Hello World!')">Hello World!</button> | ||
<div class="{{ block_type }}-block-chat-button-container"> | ||
<div class="ai-chat-button {{ block_type }}-block-chat-button" id="chat-button-{{ block_key }}" data-block-key="{{ block_key }}"> | ||
{% if block_type == "problem" %} | ||
<p>Help me with this problem</p> | ||
{% elif block_type == "video" %} | ||
<p><b>Questions about this video?</b><br>AskTim</p> | ||
{% endif %} | ||
<img src="/static/images/icon.svg" class="chat-icon"> | ||
</div> | ||
<div id="app-root-{{ block_key }}"></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resources( | ||
name="ol_chat_images", | ||
sources=["*.svg"], | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
(function ($) { | ||
function AiChatAsideView(runtime, element, block_element, init_args) { | ||
$(function ($) { | ||
|
||
const INITIAL_MESSAGES = [ | ||
{ | ||
content: "Hi! What are you interested in learning about?", | ||
role: "assistant", | ||
}, | ||
]; | ||
$(`#chat-button-${init_args.block_usage_key}`).on("click", { starters: init_args.starters, askTimTitle: init_args.ask_tim_drawer_title }, function (event) { | ||
const starters = event.data.starters.map(message => ({ content: message })); | ||
const blockKey = $(this).data("block-key"); | ||
|
||
window.parent.postMessage( | ||
{ | ||
type: "smoot-design::chat-open", | ||
payload: { | ||
chatId: blockKey, | ||
askTimTitle: event.data.askTimTitle, | ||
apiUrl: init_args.learn_ai_api_url, | ||
initialMessages: INITIAL_MESSAGES, | ||
conversationStarters: starters, | ||
}, | ||
}, | ||
init_args.learning_mfe_base_url, // Ensure correct parent origin | ||
); | ||
}); | ||
}); | ||
} | ||
|
||
function AiChatAside(runtime, element, block_element, init_args) { | ||
return new AiChatAsideView(runtime, element, block_element, init_args); | ||
} | ||
|
||
window.AiChatAsideInit = AiChatAside; | ||
})($); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters