-
Notifications
You must be signed in to change notification settings - Fork 0
Global Component Library #199
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
bnguyen1212
wants to merge
13
commits into
feat-admin-site
Choose a base branch
from
global-component-library
base: feat-admin-site
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 all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
584d9d4
UI package foundation:
bnguyen1212 9dc067d
shared UI primitives migration:
bnguyen1212 c6f4553
centralized navbar components:
bnguyen1212 c3947a7
final package hardening:
bnguyen1212 3e69368
fix: z-index interactions of dropdowns/sidebar with navbar
bnguyen1212 d066b0f
feat: sidebar template
bnguyen1212 b2245db
feat: implement ChatSidebarShell and integrate with ChatBot component
bnguyen1212 ba520b9
feat: refactor navigation components to accept dynamic links and impr…
bnguyen1212 f6ff801
feat: chatbot Zustand store, replace old pub/sub event bus
bnguyen1212 ef46a72
feat: extract shared planner sidebar logic
bnguyen1212 2ac6d5b
feat: bundle tailwind styling along with package
bnguyen1212 c016c13
moved dependency out of package, provided by consuming app
bnguyen1212 88270ab
feat: planner navbar prop drilling and horizontal alignment styling fix
bnguyen1212 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ node_modules | |
| dist | ||
| dist-ssr | ||
| *.local | ||
| .turbo | ||
|
|
||
| # Editor directories and files | ||
| .vscode/* | ||
|
|
||
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 |
|---|---|---|
| @@ -1,112 +1,53 @@ | ||
| import { Link, useLocation } from "react-router-dom"; | ||
| import { useAuth } from "../context/AuthContext"; | ||
| import { Route, MessagesSquare, MessageCirclePlus, UserRound } from "lucide-react"; | ||
| import { useEffect, useState } from "react"; | ||
| import { MessagesSquare } from "lucide-react"; | ||
| import { | ||
| DropdownMenu, | ||
| DropdownMenuContent, | ||
| DropdownMenuItem, | ||
| DropdownMenuTrigger, | ||
| } from "./ui/dropdown-menu"; | ||
| import { useChatbot } from "../hooks/useChatbot"; | ||
| import MobileNavbar from './MobileNavbar'; | ||
| DevEnvironmentBanner, | ||
| MobileNavbar, | ||
| NavBrand, | ||
| NavPrimaryLinks, | ||
| UserProfileMenu, | ||
| } from "@sage/ui"; | ||
| import ChatSidebarContent from '@/components/chatbot/ChatSidebarContent'; | ||
| import { useRouteMode } from "../hooks/useRouteMode"; | ||
| import { PRIMARY_NAV_LINKS, MOBILE_NAV_LINKS } from "../lib/navLinks"; | ||
|
|
||
| const ENVIRONMENT = import.meta.env.VITE_ENVIRONMENT as string | undefined; | ||
|
|
||
| const ChatBotNavbar = () => { | ||
| const { user, logout, profilePicture } = useAuth(); | ||
| const location = useLocation(); | ||
| const { initialLoad } = useChatbot(); | ||
|
|
||
| const [isInWebapp, setIsInWebapp] = useState(false); | ||
| useEffect(() => { | ||
| initialLoad(); | ||
| }, []); | ||
|
|
||
| useEffect(() => { | ||
| if (location.pathname === "/" || location.pathname === "/login" || location.pathname === "/signup" || location.pathname === "/forgot-password") { | ||
| setIsInWebapp(false); | ||
| } else { | ||
| setIsInWebapp(true); | ||
| } | ||
| }, [location]); | ||
| const { isInWebapp } = useRouteMode(); | ||
| const isDarkMode = !isInWebapp; | ||
|
|
||
| return ( | ||
| <> | ||
| {/* Desktop navbar */} | ||
| {ENVIRONMENT === 'development' && ( | ||
| <div className="fixed top-0 left-0 right-0 h-4 bg-purple-600 text-white text-center text-xs font-medium z-[200] shadow-sm flex items-center justify-center"> | ||
| Dev Environment | ||
| </div> | ||
| )} | ||
| <DevEnvironmentBanner isDevelopment={ENVIRONMENT === 'development'} /> | ||
|
|
||
| <nav className={` | ||
| ${isInWebapp ? "bg-bglight border-b-[1px] shadow-sm" : undefined} | ||
| ${isInWebapp ? "bg-bglight border-b-[1px] shadow-sm" : undefined} | ||
| py-2.5 px-6 fixed w-full z-10 hidden md:block | ||
| ${ENVIRONMENT === 'development' ? 'top-4' : 'top-0'} | ||
| `}> | ||
| <div className="flex items-center justify-between w-full"> | ||
| <Link to="/" className="ml-0"> | ||
| <img src={isInWebapp ? "/Sage_Logo_Dark.svg" : "/Sage_Logo_Light.svg"} alt="SAGE" className="h-8 w-auto" /> | ||
| </Link> | ||
| <NavBrand isDarkMode={isDarkMode} /> | ||
| <ul className="flex items-center space-x-6 mr-0"> | ||
| <li> | ||
| <Link to="/planner" className={`${isInWebapp ? "text-textdark hover:text-gray-500" : "text-textlight hover:text-gray-200"} flex items-center gap-2`}> | ||
| <Route className="stroke-accent" /> | ||
| Plan your degree | ||
| </Link> | ||
| </li> | ||
| <li> | ||
| <Link to="/chatbot" className={`${isInWebapp ? "text-textdark hover:text-gray-500" : "text-textlight hover:text-gray-200"} flex items-center gap-2`}> | ||
| <MessageCirclePlus className="stroke-accent" /> | ||
| Start a chat | ||
| </Link> | ||
| </li> | ||
| <li> | ||
| {user ? ( | ||
| <DropdownMenu> | ||
| <DropdownMenuTrigger> | ||
| <div className="p-2 rounded-full"> | ||
| {profilePicture ? ( | ||
| <img referrerPolicy="no-referrer" src={profilePicture} data-clarity-mask="True" alt="Profile" className="w-9 h-9 rounded-full object-cover" /> | ||
| ) : ( | ||
| <UserRound className="stroke-textdark"/> | ||
| )} | ||
| </div> | ||
| </DropdownMenuTrigger> | ||
| <DropdownMenuContent className="bg-bglight flex flex-col p-2 gap-2 mr-6 items-center rounded-sm"> | ||
| <DropdownMenuItem className="focus:bg-innercontainer w-full"> | ||
| <Link to="/profile" className="text-textdark hover:text-gray-700 flex flex-row w-full justify-start items-center gap-2"> | ||
| <UserRound className="stroke-accent" /> | ||
| Your Profile | ||
| </Link> | ||
| </DropdownMenuItem> | ||
| <DropdownMenuItem className="focus:bg-innercontainer w-full"> | ||
| <button onClick={logout} className="bg-destructive text-textlight text-base px-6 py-1.5 rounded-full font-semibold hover:bg-red-700 transition duration-300"> | ||
| Sign Out | ||
| </button> | ||
| </DropdownMenuItem> | ||
| </DropdownMenuContent> | ||
| </DropdownMenu> | ||
| ) : ( | ||
| <Link to="/login" className="bg-accent text-textdark text-base px-8 py-3 rounded-full font-semibold hover:bg-buttonhover transition duration-300"> | ||
| Login | ||
| </Link> | ||
| )} | ||
| </li> | ||
| <NavPrimaryLinks isDarkMode={isDarkMode} links={PRIMARY_NAV_LINKS} /> | ||
| <UserProfileMenu user={user} logout={logout} profilePicture={profilePicture} /> | ||
| </ul> | ||
| </div> | ||
| </nav> | ||
|
|
||
| {/* Mobile navbar with chat sidebar */} | ||
| <MobileNavbar | ||
| isInWebapp={isInWebapp} | ||
| sidebarIcon={<MessagesSquare className={isInWebapp ? "stroke-textdark" : "stroke-textlight"} />} | ||
| isDarkMode={isDarkMode} | ||
| isDevelopment={ENVIRONMENT === 'development'} | ||
| user={user} | ||
| logout={logout} | ||
| sidebarIcon={<MessagesSquare className={isDarkMode ? "stroke-textlight" : "stroke-textdark"} />} | ||
| sidebarContent={(onClose) => <ChatSidebarContent onClose={onClose} />} | ||
| navLinks={MOBILE_NAV_LINKS} | ||
| /> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default ChatBotNavbar; | ||
| export default ChatBotNavbar; | ||
This file was deleted.
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.
There's no useChatbotStore import and no initialLoad() call anywhere in this file here which can cause convos to not load
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.
Essentially...
component renders ChatSidebarContent (the mobile drawer) but never triggers useChatbotStore.initialLoad(user). Right now the only place that loads conversations is ChatBot.tsx's own mount effect, so opening the mobile chat drawer from another page (planner, profile) before ever visiting /chatbot will show an empty list.
Maybe we can add the initialLoad call here (or inside ChatSidebarContent itself, since that's reused in both places).