-
Notifications
You must be signed in to change notification settings - Fork 17
feat: CP-11851 Core concierge #432
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
Open
vvava
wants to merge
22
commits into
main
Choose a base branch
from
feat/CP-11851_core-ai
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7770728
feat: initial funcionality, send placeholder
vvava 6c1465c
feat: improve send funcion
vvava 8d81814
chore: localization
vvava 56ce557
feat: prompt styling
vvava e92e06f
feat: button animation
vvava 1d758f2
chore: translation
vvava 6c8991d
refactor: remove unnecessary parts and shuffle
vvava 72964ac
feat: smoother exit animation for btn bg
vvava d76d34e
fix: remove logs and add word break
vvava 9e7c7bc
Merge branch 'main' into feat/CP-11851_core-ai
vvava c91666d
feat: add featureflags, fix settings
vvava f51987f
refactor: remove logs and small changes
vvava 53640e1
fix: remove logs
vvava 2583f27
refactor: separate components
vvava d743605
fix: design and behaviour glitches
vvava bd46916
fix: remove logs and bg width
vvava 19cf2df
fix: light theme colors
vvava 707ce52
feat: support enable / disable networks
vvava 03b564a
Merge branch 'main' into feat/CP-11851_core-ai
vvava 195ad1e
refactor: rethink the naming and component logic
vvava 6f940e1
refactor: move components to separate files
vvava 06a391b
Merge branch 'main' into feat/CP-11851_core-ai
vvava 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 hidden or 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 hidden or 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,218 @@ | ||
| import { | ||
| Box, | ||
| getHexAlpha, | ||
| Stack, | ||
| Typography, | ||
| useTheme, | ||
| } from '@avalabs/k2-alpine'; | ||
| import { useRef, useState } from 'react'; | ||
| import { useHistory } from 'react-router-dom'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { CSSTransition, TransitionGroup } from 'react-transition-group'; | ||
| import { | ||
| AnimatedButton, | ||
| PromptButtonBackground, | ||
| TextAnimation, | ||
| } from './components/styledComponents'; | ||
| import { useFeatureFlagContext, useSettingsContext } from '@core/ui'; | ||
| import { FeatureGates } from '@core/types'; | ||
|
|
||
| export const ConciergePrompt = ({ isAIBackdropOpen, setIsAIBackdropOpen }) => { | ||
| const theme = useTheme(); | ||
| const history = useHistory(); | ||
| const { t } = useTranslation(); | ||
|
|
||
| const [isHoverAreaHidden, setIsHoverAreaHidden] = useState(false); | ||
| const { coreAssistant } = useSettingsContext(); | ||
| const { featureFlags } = useFeatureFlagContext(); | ||
| const timer = useRef<NodeJS.Timeout>(null); | ||
| const hasBackdropEntered = useRef(false); | ||
|
|
||
| const buttonLabels = [ | ||
| t('Ask Core Concierge to send crypto'), | ||
| t('Ask Core Concierge to swap tokens'), | ||
| t('Ask Core Concierge to bridge tokens'), | ||
| t('Ask Core Concierge to transfer for you'), | ||
| t('Ask Core Concierge to manage accounts'), | ||
| ]; | ||
|
|
||
| const getRandomButtonLabel = () => { | ||
| return buttonLabels[Math.floor(Math.random() * buttonLabels.length)]; | ||
| }; | ||
|
|
||
| const nodeRef = useRef(null); | ||
| const nodeRef2 = useRef(null); | ||
| const nodeRef3 = useRef(null); | ||
vvava marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (!coreAssistant || !featureFlags[FeatureGates.CORE_ASSISTANT]) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| {/* THE BOX AREA WHERE WE WANT TO CATCH THE CURSOR */} | ||
| <Stack | ||
| className="prompt-hover-area" | ||
vvava marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sx={{ | ||
| width: '100%', | ||
| height: '40px', | ||
| position: 'absolute', | ||
| top: '56px', | ||
| zIndex: isHoverAreaHidden ? 0 : theme.zIndex.tooltip - 1, | ||
| }} | ||
| onMouseEnter={() => { | ||
| timer.current = setTimeout(() => { | ||
| setIsAIBackdropOpen(true); | ||
| }, 400); | ||
| }} | ||
| onMouseLeave={() => { | ||
| if (!isAIBackdropOpen && timer.current) { | ||
| clearTimeout(timer.current); | ||
| } | ||
| }} | ||
| /> | ||
| <TransitionGroup component={null}> | ||
| <Stack> | ||
| {/* GRADIENT BACKGROUND */} | ||
| <CSSTransition | ||
| key={1} | ||
| timeout={200} | ||
| classNames="overlay" | ||
| appear | ||
| enter | ||
| exit | ||
| in={isAIBackdropOpen} | ||
| nodeRef={nodeRef2} | ||
| > | ||
| <Stack | ||
| sx={{ | ||
| '.prompt-background': { | ||
| display: 'none', | ||
| opacity: 0, | ||
| transition: `opacity 400ms linear`, | ||
| }, | ||
| '.overlay-enter.prompt-background': { | ||
| display: 'block', | ||
| }, | ||
| '.overlay-enter-done.prompt-background': { | ||
| display: 'block', | ||
| opacity: 1, | ||
| }, | ||
| '.overlay-exit.prompt-background': { | ||
| display: 'block', | ||
| opacity: 1, | ||
| }, | ||
| '.overlay-exit-done.prompt-background': { | ||
| display: 'block', | ||
| opacity: 0, | ||
| }, | ||
| }} | ||
vvava marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| > | ||
| <PromptButtonBackground | ||
| ref={nodeRef2} | ||
| className="prompt-background" | ||
| /> | ||
| </Stack> | ||
| </CSSTransition> | ||
| {/* BACKDROP */} | ||
| <CSSTransition | ||
| key={2} | ||
| timeout={1000} | ||
| classNames="backdrop" | ||
| appear | ||
| exit | ||
| in={isAIBackdropOpen} | ||
| nodeRef={nodeRef3} | ||
| onExited={() => { | ||
| hasBackdropEntered.current = false; | ||
| }} | ||
| > | ||
| <Stack | ||
| sx={{ | ||
| position: 'fixed', | ||
| top: 0, | ||
| left: 0, | ||
| right: 0, | ||
| bottom: 0, | ||
| background: '#28282ECC', | ||
| backdropFilter: 'none', | ||
| display: 'none', | ||
| transition: 'opacity 400ms linear', | ||
| opacity: 0, | ||
| zIndex: theme.zIndex.appBar - 1, | ||
| '&.backdrop-enter': { | ||
| display: 'flex', | ||
| }, | ||
| '&.backdrop-enter-done': { | ||
| display: 'flex', | ||
|
||
| opacity: 1, | ||
| }, | ||
| }} | ||
| ref={nodeRef3} | ||
| onMouseMove={() => { | ||
| if (hasBackdropEntered.current) { | ||
| setIsAIBackdropOpen(false); | ||
| setIsHoverAreaHidden(false); | ||
| } | ||
| }} | ||
| /> | ||
| </CSSTransition> | ||
| {/* THE BUTTON */} | ||
| <CSSTransition | ||
| key={3} | ||
| timeout={1000} | ||
| classNames="button" | ||
| appear | ||
| exit | ||
| in={isAIBackdropOpen} | ||
| nodeRef={nodeRef} | ||
| onEntered={() => { | ||
| // it needs to be delayed (waiting for the button animation getting done) to avoid the glitch | ||
| setTimeout(() => { | ||
| setIsHoverAreaHidden(true); | ||
| hasBackdropEntered.current = true; | ||
| }, 500); | ||
| }} | ||
| > | ||
| <Stack | ||
| sx={{ | ||
| position: 'absolute', | ||
| top: '56px', | ||
| width: '100%', | ||
| height: '40px', | ||
| px: 1.5, | ||
| }} | ||
| > | ||
| <AnimatedButton | ||
| variant="contained" | ||
| sx={{ | ||
| borderColor: 'common.white_10', | ||
| maxWidth: '100%', | ||
| justifyContent: 'flex-start', | ||
| px: 1.5, | ||
| backgroundColor: getHexAlpha(theme.palette.text.primary, 30), | ||
| color: 'common.white', | ||
| }} | ||
| onClick={() => { | ||
| history.push('/concierge'); | ||
| }} | ||
| size="large" | ||
| fullWidth | ||
| ref={nodeRef} | ||
| > | ||
| <Box component="span" sx={{ mr: 1, fontSize: 24 }}> | ||
| ✨ | ||
| </Box> | ||
| <TextAnimation> | ||
| <Typography variant="subtitle3"> | ||
| {isAIBackdropOpen && getRandomButtonLabel()} | ||
| </Typography> | ||
| </TextAnimation> | ||
| </AnimatedButton> | ||
| </Stack> | ||
| </CSSTransition> | ||
| </Stack> | ||
| </TransitionGroup> | ||
| </> | ||
| ); | ||
| }; | ||
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.