-
Notifications
You must be signed in to change notification settings - Fork 2
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
Full width slide down syllabus chat for the resource drawer #2063
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
68bc379
Remove columned chatbot. Refactor
jonkafton a27283e
Merge branch 'main' into jk/6747-slidedown-syllabus-bot
jonkafton 2d6d489
Full width / slide down syllabus bot
jonkafton 3884f51
Merge branch 'main' into jk/6747-slidedown-syllabus-bot
jonkafton da88b27
Update Posthog replay vars
jonkafton 4fa203c
Refactor chat with entry screen for reuse
jonkafton 014f59f
Update test and clean up
jonkafton 1a0c12f
Fix enum import
jonkafton f74dcc9
Test updates
jonkafton f883bee
Prevent tab to masked content when the chat is open (accessibility)
jonkafton 823d955
Limit scroll to content area when chat enabled
jonkafton af081b0
Remove scrollbar-gutter not needed
jonkafton 6ceba50
Rewind limit scroll to content area when chat enabled
jonkafton 1b39a7d
avoid layout shift, show full scrollbar
ChristopherChudzicki cd1fe90
Make chat inert when closed. Fix pointer events stopped at opener con…
jonkafton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
110 changes: 110 additions & 0 deletions
110
frontends/main/src/page-components/AiChat/AiRecommendationBotDrawer.tsx
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,110 @@ | ||
import React from "react" | ||
import { styled, Drawer } from "ol-components" | ||
import { RiCloseLine } from "@remixicon/react" | ||
import { ActionButton } from "@mitodl/smoot-design" | ||
import type { AiChatProps } from "@mitodl/smoot-design/ai" | ||
import AiChatWithEntryScreen from "./AiChatWithEntryScreen" | ||
import { getCsrfToken } from "@/common/utils" | ||
|
||
const CloseButton = styled(ActionButton)(({ theme }) => ({ | ||
position: "absolute", | ||
top: "24px", | ||
right: "40px", | ||
backgroundColor: theme.custom.colors.lightGray2, | ||
"&&:hover": { | ||
backgroundColor: theme.custom.colors.red, | ||
color: theme.custom.colors.white, | ||
}, | ||
[theme.breakpoints.down("md")]: { | ||
right: "24px", | ||
}, | ||
})) | ||
|
||
const StyledAiChatWithEntryScreen = styled(AiChatWithEntryScreen)( | ||
({ theme }) => ({ | ||
width: "900px", | ||
[theme.breakpoints.down("md")]: { | ||
width: "100%", | ||
}, | ||
}), | ||
) | ||
|
||
const INITIAL_MESSAGES: AiChatProps["initialMessages"] = [ | ||
{ | ||
content: "What do you want to learn about today?", | ||
role: "assistant", | ||
}, | ||
] | ||
|
||
const STARTERS = [ | ||
{ | ||
content: | ||
"I'm interested in courses on quantum computing that offer certificates.", | ||
}, | ||
{ | ||
content: | ||
"I want to learn about global warming, can you recommend any videos?", | ||
}, | ||
{ | ||
content: | ||
"I would like to learn about linear regression, preferably at no cost.", | ||
}, | ||
] | ||
|
||
const AiRecommendationBotDrawer = ({ | ||
open, | ||
setOpen, | ||
}: { | ||
open: boolean | ||
setOpen: (open: boolean) => void | ||
}) => { | ||
const closeDrawer = () => { | ||
setOpen(false) | ||
// setShowEntryScreen(true) | ||
} | ||
|
||
return ( | ||
<Drawer | ||
open={open} | ||
anchor="right" | ||
onClose={closeDrawer} | ||
PaperProps={{ | ||
sx: { | ||
minWidth: (theme) => ({ | ||
[theme.breakpoints.down("md")]: { | ||
width: "100%", | ||
}, | ||
}), | ||
}, | ||
}} | ||
> | ||
<CloseButton | ||
variant="text" | ||
size="medium" | ||
onClick={closeDrawer} | ||
aria-label="Close" | ||
> | ||
<RiCloseLine /> | ||
</CloseButton> | ||
<StyledAiChatWithEntryScreen | ||
entryTitle="What do you want to learn from MIT?" | ||
starters={STARTERS} | ||
askTimTitle="to recommend a course" | ||
initialMessages={INITIAL_MESSAGES} | ||
requestOpts={{ | ||
apiUrl: process.env.NEXT_PUBLIC_LEARN_AI_RECOMMENDATION_ENDPOINT!, | ||
fetchOpts: { | ||
headers: { | ||
"X-CSRFToken": getCsrfToken(), | ||
}, | ||
}, | ||
transformBody: (messages) => ({ | ||
message: messages[messages.length - 1].content, | ||
}), | ||
}} | ||
/> | ||
</Drawer> | ||
) | ||
} | ||
|
||
export default AiRecommendationBotDrawer |
File renamed without changes.
69 changes: 0 additions & 69 deletions
69
frontends/main/src/page-components/AiRecommendationBot/AiRecommendationBot.tsx
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slipped this in - it was just badly named. mitodl/ol-infrastructure#2978 sets the env vars.