Skip to content

Commit

Permalink
Merge pull request #1213 from sccalabr/1204
Browse files Browse the repository at this point in the history
Replacing About with a Help dropdown that has contact and documentati…
  • Loading branch information
dartpain authored Oct 14, 2024
2 parents 2b547f7 + 5f62c0d commit 44405b2
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 75 deletions.
Binary file added frontend/signal-desktop-keyring.gpg
Binary file not shown.
6 changes: 3 additions & 3 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ function MainLayout() {
}

export default function App() {
const [,,componentMounted] = useDarkTheme();
if(!componentMounted) {
return <div />
const [, , componentMounted] = useDarkTheme();
if (!componentMounted) {
return <div />;
}
return (
<div className="h-full relative overflow-auto">
Expand Down
113 changes: 49 additions & 64 deletions frontend/src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Discord from './assets/discord.svg';
import Expand from './assets/expand.svg';
import Github from './assets/github.svg';
import Hamburger from './assets/hamburger.svg';
import Info from './assets/info.svg';
import SettingGear from './assets/settingGear.svg';
import Twitter from './assets/TwitterX.svg';
import UploadIcon from './assets/upload.svg';
Expand Down Expand Up @@ -41,6 +40,7 @@ import {
setSourceDocs,
} from './preferences/preferenceSlice';
import Upload from './upload/Upload';
import Help from './components/Help';

interface NavigationProps {
navOpen: boolean;
Expand Down Expand Up @@ -304,7 +304,6 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
<></>
)}
</div>

<div className="flex h-auto flex-col justify-end text-eerie-black dark:text-white">
<div className="flex flex-col-reverse border-b-[1px] dark:border-b-purple-taupe">
<div className="relative my-4 mx-4 flex gap-2">
Expand Down Expand Up @@ -359,68 +358,54 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
</p>
</NavLink>
</div>
<div className="flex justify-between gap-2 border-b-[1.5px] py-2 dark:border-b-purple-taupe">
<NavLink
onClick={() => {
if (isMobile) {
setNavOpen(!navOpen);
}
resetConversation();
}}
to="/about"
className={({ isActive }) =>
`my-auto mx-4 flex h-9 cursor-pointer gap-4 rounded-3xl hover:bg-gray-100 dark:hover:bg-[#28292E] ${
isActive ? 'bg-gray-3000 dark:bg-[#28292E]' : ''
}`
}
>
<img
src={Info}
alt="icon"
className="ml-2 w-5 filter dark:invert"
/>
<p className="my-auto pr-1 text-sm">{t('about')}</p>
</NavLink>
<div className="flex items-center justify-evenly gap-1 px-1">
<NavLink
target="_blank"
to={'https://discord.gg/WHJdfbQDR4'}
className={
'rounded-full hover:bg-gray-100 dark:hover:bg-[#28292E]'
}
>
<img
src={Discord}
alt="discord"
className="m-2 w-6 self-center filter dark:invert"
/>
</NavLink>
<NavLink
target="_blank"
to={'https://twitter.com/docsgptai'}
className={
'rounded-full hover:bg-gray-100 dark:hover:bg-[#28292E]'
}
>
<img
src={Twitter}
alt="x"
className="m-2 w-5 self-center filter dark:invert"
/>
</NavLink>
<NavLink
target="_blank"
to={'https://github.com/arc53/docsgpt'}
className={
'rounded-full hover:bg-gray-100 dark:hover:bg-[#28292E]'
}
>
<img
src={Github}
alt="github"
className="m-2 w-6 self-center filter dark:invert"
/>
</NavLink>
<div className="flex flex-col justify-end text-eerie-black dark:text-white">
<div className="flex justify-between items-center px-1 py-1">
<div className="flex items-center gap-1">
<div className="rounded-full hover:bg-gray-100 dark:hover:bg-[#28292E]">
<Help />
</div>
</div>
<div className="flex items-center gap-1">
<NavLink
target="_blank"
to={'https://discord.gg/WHJdfbQDR4'}
className={
'rounded-full hover:bg-gray-100 dark:hover:bg-[#28292E]'
}
>
<img
src={Discord}
alt="discord"
className="m-2 w-6 self-center filter dark:invert"
/>
</NavLink>
<NavLink
target="_blank"
to={'https://twitter.com/docsgptai'}
className={
'rounded-full hover:bg-gray-100 dark:hover:bg-[#28292E]'
}
>
<img
src={Twitter}
alt="x"
className="m-2 w-5 self-center filter dark:invert"
/>
</NavLink>
<NavLink
target="_blank"
to={'https://github.com/arc53/docsgpt'}
className={
'rounded-full hover:bg-gray-100 dark:hover:bg-[#28292E]'
}
>
<img
src={Github}
alt="github"
className="m-2 w-6 self-center filter dark:invert"
/>
</NavLink>
</div>
</div>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/assets/documentation-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions frontend/src/assets/documentation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/src/assets/envelope-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/src/assets/envelope.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions frontend/src/components/Help.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React, { useState, useRef, useEffect } from 'react';
import InfoDark from '../assets/info-dark.svg';
import PageIcon from '../assets/documentation.svg'; // Ensure this path is correct
import EmailIcon from '../assets/envelope.svg'; // Replace with your actual email icon path

const Help = () => {
const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef<HTMLDivElement | null>(null);
const buttonRef = useRef<HTMLButtonElement | null>(null);

const toggleDropdown = () => {
setIsOpen((prev) => !prev);
};

const handleClickOutside = (event: MouseEvent) => {
if (
dropdownRef.current &&
!dropdownRef.current.contains(event.target as Node) &&
buttonRef.current &&
!buttonRef.current.contains(event.target as Node)
) {
setIsOpen(false);
}
};

useEffect(() => {
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, []);

const dropdownPosition = () => {
if (!buttonRef.current) return { top: '100%', left: '0' };

const rect = buttonRef.current.getBoundingClientRect();
const dropdownHeight = 80; // Adjust based on the content height
const spaceBelow = window.innerHeight - rect.bottom;

const dropdownWidth = 192; // Adjust to fit your design
const spaceRight = window.innerWidth - rect.right;

let leftPosition = 0; // Default to align with the button

if (spaceRight < dropdownWidth) {
leftPosition = dropdownWidth - rect.width;
}

if (spaceBelow >= dropdownHeight) {
return { top: '100%', left: `${leftPosition}px` }; // Open downward
} else {
return { top: `${-dropdownHeight}px`, left: `${leftPosition}px` }; // Open upward
}
};

return (
<div className="relative inline-block" ref={dropdownRef}>
<button
ref={buttonRef}
onClick={toggleDropdown}
className="flex items-center rounded-full hover:bg-gray-100 dark:hover:bg-[#28292E] px-3 py-1"
>
<img
src={InfoDark}
alt="icon"
className="m-2 w-6 self-center text-sm filter dark:invert"
/>
Help
</button>
{isOpen && (
<div
className={`absolute mt-2 w-48 shadow-lg bg-white dark:bg-gray-800`}
style={{ ...dropdownPosition(), borderRadius: '0.5rem' }}
>
<a
href="https://docs.docsgpt.cloud/"
target="_blank"
rel="noopener noreferrer"
className="flex items-center px-4 py-2 text-black dark:text-white hover:bg-gray-200 dark:hover:bg-gray-700"
>
<img src={PageIcon} alt="Documentation" className="mr-2 w-4 h-4" />
Documentation
</a>
<a
href="mailto:[email protected]"
className="flex items-center px-4 py-2 text-black dark:text-white hover:bg-gray-200 dark:hover:bg-gray-700"
>
<img src={EmailIcon} alt="Email Us" className="mr-2 w-4 h-4" />
Email Us
</a>
</div>
)}
</div>
);
};

export default Help;
9 changes: 6 additions & 3 deletions frontend/src/components/SourceDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ function SourceDropdown({
className="flex cursor-pointer items-center justify-between hover:bg-gray-100 dark:text-bright-gray dark:hover:bg-purple-taupe"
onClick={handleEmptyDocumentSelect}
>
<span className="ml-4 flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap py-3" onClick = {() => {
handlePostDocumentSelect(null);
}}>
<span
className="ml-4 flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap py-3"
onClick={() => {
handlePostDocumentSelect(null);
}}
>
{t('none')}
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/locale/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ i18n
zh: {
translation: zh,
},
"zh-TW": {
'zh-TW': {
translation: zhTW,
},
},
Expand Down

0 comments on commit 44405b2

Please sign in to comment.