From 95249a48b9c6f0a5e0b13f43122a3a47a558ef5d Mon Sep 17 00:00:00 2001 From: Seung Park Date: Mon, 25 Nov 2024 16:31:48 -0500 Subject: [PATCH] add mobile chatbot button. hide for other langs via css --- src/components/ActionBar/ActionBar.js | 30 ++++++++++--------- .../{LazyChatbot.js => ChatbotModal.js} | 4 +-- src/components/ActionBar/styles.js | 22 ++++++++++++-- 3 files changed, 38 insertions(+), 18 deletions(-) rename src/components/ActionBar/{LazyChatbot.js => ChatbotModal.js} (89%) diff --git a/src/components/ActionBar/ActionBar.js b/src/components/ActionBar/ActionBar.js index a54cd6d81..98bf422fa 100644 --- a/src/components/ActionBar/ActionBar.js +++ b/src/components/ActionBar/ActionBar.js @@ -32,12 +32,15 @@ import { offlineStyling, overlineStyling, buttonStyling, + mobileButtonStyling, } from './styles'; +import { SparkleIcon } from './SparkIcon'; const Chatbot = lazy(() => import('mongodb-chatbot-ui')); -const LazyChatbot = lazy(() => import('./LazyChatbot')); +const ChatbotModal = lazy(() => import('./ChatbotModal')); export const DEPRECATED_PROJECTS = ['atlas-app-services', 'datalake', 'realm']; +const CHATBOT_TEXT = 'Ask MongoDB AI'; const ActionBar = ({ template, slug, sidenav, ...props }) => { const url = isBrowser ? window.location.href : null; @@ -55,7 +58,7 @@ const ActionBar = ({ template, slug, sidenav, ...props }) => { const { hideMobile, setHideMobile } = useContext(SidenavContext); - const onClick = () => { + const openChatbot = () => { reportAnalytics('Chatbot button clicked'); setChatbotClicked((currVal) => !currVal); }; @@ -82,21 +85,20 @@ const ActionBar = ({ template, slug, sidenav, ...props }) => { {!isOfflineDocsBuild && ( {template !== 'openapi' && } - {locale === 'en-us' && ( - - )} + + {locale === 'en-us' && ( - + )} diff --git a/src/components/ActionBar/LazyChatbot.js b/src/components/ActionBar/ChatbotModal.js similarity index 89% rename from src/components/ActionBar/LazyChatbot.js rename to src/components/ActionBar/ChatbotModal.js index 6643f95a8..baeb7d2a0 100644 --- a/src/components/ActionBar/LazyChatbot.js +++ b/src/components/ActionBar/ChatbotModal.js @@ -2,7 +2,7 @@ import React, { useEffect } from 'react'; import { useChatbotContext, ModalView, MongoDbLegalDisclosure, PoweredByAtlasVectorSearch } from 'mongodb-chatbot-ui'; import { css } from '@leafygreen-ui/emotion'; -const LazyChatbot = ({ chatbotClicked, setChatbotClicked }) => { +const ChatbotModal = ({ chatbotClicked, setChatbotClicked }) => { const { openChat } = useChatbotContext(); useEffect(() => { if (chatbotClicked) { @@ -31,4 +31,4 @@ const LazyChatbot = ({ chatbotClicked, setChatbotClicked }) => { ); }; -export default LazyChatbot; +export default ChatbotModal; diff --git a/src/components/ActionBar/styles.js b/src/components/ActionBar/styles.js index 3925a62d1..b97e80ea8 100644 --- a/src/components/ActionBar/styles.js +++ b/src/components/ActionBar/styles.js @@ -70,6 +70,10 @@ const flexStyling = css` const middleAlignment = css` display: grid; ${centerGridStyling} + + @media ${theme.screenSize.upToMedium} { + grid-template-columns: repeat(12, 1fr); + } `; const leftInGrid = css` @@ -99,7 +103,6 @@ const centerInGrid = css` } @media ${theme.screenSize.upToMedium} { grid-column: 3/-2; - padding-right: ${theme.size.small}; } `; @@ -272,6 +275,12 @@ export const searchIconStyling = css` ${displayNone.onLargerThanMedium}; float: right; justify-content: right; + + @media ${theme.screenSize.upToMedium} { + > div { + justify-content: flex-end; + } + } `; export const offlineStyling = css` @@ -282,5 +291,14 @@ export const offlineStyling = css` export const buttonStyling = css` text-wrap-mode: nowrap; - ${displayNone.onMobileAndTablet} + ${displayNone.onMobileAndTablet}; + + &:not(:lang(EN)) { + display: none; + } +`; + +export const mobileButtonStyling = css` + cursor: pointer; + ${displayNone.onLargerThanTablet}; `;