forked from React-Group/interstellar_ai
Merge pull request 'main' (#114) from sageTheDm/interstellar_ai:main into main
Reviewed-on: https://interstellardevelopment.org/code/code/React-Group/interstellar_ai/pulls/114
This commit is contained in:
commit
72f2d23019
4 changed files with 151 additions and 83 deletions
|
@ -1,46 +1,77 @@
|
||||||
import React, { useState } from 'react';
|
import React, { useState, useRef, useEffect } from 'react';
|
||||||
import Login from './Login';
|
import Login from './Login';
|
||||||
|
|
||||||
interface HeaderProps {
|
interface HeaderProps {
|
||||||
onViewChange: (view: 'AI' | 'FAQ' | 'Documentation' | 'Credits') => void; // Include 'Credits'
|
onViewChange: (view: 'AI' | 'FAQ' | 'Documentation' | 'Credits') => void;
|
||||||
showDivs: boolean;
|
showDivs: boolean;
|
||||||
toggleDivs: () => void;
|
toggleDivs: () => void;
|
||||||
showHistoryModelsToggle: boolean;
|
showHistoryModelsToggle: boolean;
|
||||||
showToggle: boolean;
|
showToggle: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Header: React.FC<HeaderProps> = ({ onViewChange, showDivs, toggleDivs, showHistoryModelsToggle, showToggle }) => {
|
const Header: React.FC<HeaderProps> = ({
|
||||||
|
onViewChange,
|
||||||
|
showDivs,
|
||||||
|
toggleDivs,
|
||||||
|
showHistoryModelsToggle,
|
||||||
|
showToggle,
|
||||||
|
}) => {
|
||||||
const [menuOpen, setMenuOpen] = useState(false);
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
|
const dropdownRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const toggleRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
// Toggle menu state
|
||||||
const toggleMenu = () => {
|
const toggleMenu = () => {
|
||||||
setMenuOpen(!menuOpen);
|
setMenuOpen((prevMenuOpen) => !prevMenuOpen);
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonClicked = (page: "AI" | "Documentation" | "FAQ" | "Credits") => { // Add 'Credits' to the options here
|
// Handle button click
|
||||||
|
const buttonClicked = (page: "AI" | "Documentation" | "FAQ" | "Credits") => {
|
||||||
onViewChange(page);
|
onViewChange(page);
|
||||||
toggleMenu();
|
setMenuOpen(false); // Close the menu when a button is clicked
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Effect to handle clicks outside of the dropdown
|
||||||
|
useEffect(() => {
|
||||||
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
|
// Check if the click is outside both the dropdown and the hamburger menu
|
||||||
|
if (
|
||||||
|
dropdownRef.current &&
|
||||||
|
!dropdownRef.current.contains(event.target as Node) &&
|
||||||
|
toggleRef.current &&
|
||||||
|
!toggleRef.current.contains(event.target as Node)
|
||||||
|
) {
|
||||||
|
setMenuOpen(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('mousedown', handleClickOutside);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('mousedown', handleClickOutside);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<header>
|
<header>
|
||||||
<div className={`hamburger ${menuOpen ? "open" : ""}`} onClick={toggleMenu}>
|
{showToggle && showHistoryModelsToggle && (
|
||||||
|
<button onClick={toggleDivs} className="nav-btn show-hide-btn">
|
||||||
|
{showDivs ? 'Hide' : 'Show'}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
<nav ref={dropdownRef} className={`nav-links ${menuOpen ? "active" : ""}`}>
|
||||||
|
<button onClick={() => buttonClicked("AI")} className="nav-btn">Chat</button>
|
||||||
|
<button onClick={() => buttonClicked("FAQ")} className="nav-btn">FAQ</button>
|
||||||
|
<button onClick={() => buttonClicked("Documentation")} className="nav-btn">Documentation</button>
|
||||||
|
<button onClick={() => buttonClicked("Credits")} className="nav-btn">Credits</button>
|
||||||
|
</nav>
|
||||||
|
<div ref={toggleRef} className={`hamburger ${menuOpen ? "open" : ""}`} onClick={toggleMenu}>
|
||||||
<span></span>
|
<span></span>
|
||||||
<span></span>
|
<span></span>
|
||||||
<span></span>
|
<span></span>
|
||||||
</div>
|
</div>
|
||||||
<nav className={`nav-links ${menuOpen ? "active" : ""}`}>
|
<div className="header-logo">
|
||||||
<button onClick={() => buttonClicked("AI")} className="nav-btn">Chat</button>
|
|
||||||
<button onClick={() => buttonClicked("FAQ")} className="nav-btn">FAQ</button>
|
|
||||||
<button onClick={() => buttonClicked("Documentation")} className="nav-btn">Documentation</button>
|
|
||||||
<button onClick={() => buttonClicked("Credits")} className="nav-btn">Credits</button> {/* Add Credits tab */}
|
|
||||||
{showToggle && showHistoryModelsToggle && (
|
|
||||||
<button onClick={toggleDivs} className="nav-btn">
|
|
||||||
{showDivs ? 'Hide History/Models' : 'Show History/Models'}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</nav>
|
|
||||||
<div className="header-button header-logo">
|
|
||||||
{/* AI logo or text */}
|
{/* AI logo or text */}
|
||||||
</div>
|
</div>
|
||||||
<div className="login-button-container">
|
<div className="login-button-container">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
header{
|
header {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -10,15 +10,16 @@ header{
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hamburger{
|
/* Hamburger button styles */
|
||||||
|
.hamburger {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 5vw;
|
left: 5vw;
|
||||||
display: none;
|
display: flex; /* Always show hamburger button */
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hamburger span{
|
.hamburger span {
|
||||||
width: 25px;
|
width: 25px;
|
||||||
height: 3px;
|
height: 3px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
@ -26,43 +27,53 @@ header{
|
||||||
transition: 0.3s;
|
transition: 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hamburger.open span:nth-child(1){
|
.hamburger.open span:nth-child(1) {
|
||||||
transform: rotate(45deg) translate(5px, 10px);
|
transform: rotate(45deg) translate(5px, 10px);
|
||||||
}
|
}
|
||||||
.hamburger.open span:nth-child(2){
|
.hamburger.open span:nth-child(2) {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
.hamburger.open span:nth-child(3){
|
.hamburger.open span:nth-child(3) {
|
||||||
transform: rotate(-45deg) translate(5px, -10px);
|
transform: rotate(-45deg) translate(5px, -10px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Navigation links (hidden in header, shown in dropdown) */
|
||||||
|
.nav-links {
|
||||||
.nav-links{
|
display: none; /* Default hidden */
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 1vw;
|
top: 10vh; /* Adjust as needed */
|
||||||
display: flex;
|
left: 0;
|
||||||
gap: 0.5vw;
|
background-color: var(--burger-menu-background-color);
|
||||||
width:max-content;
|
width: 100%;
|
||||||
height: 100%;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-btn{
|
.nav-links.active {
|
||||||
|
display: flex; /* Show when active */
|
||||||
|
height: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-btn {
|
||||||
background-color: var(--input-button-color);
|
background-color: var(--input-button-color);
|
||||||
border: none;
|
border: none;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
height: 50%;
|
height: 50px; /* Consistent height */
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 2px 15px;
|
padding: 10px;
|
||||||
font-family: var(--font-family);
|
font-family: var(--font-family);
|
||||||
|
width: 100%; /* Full width */
|
||||||
|
text-align: center; /* Center text */
|
||||||
|
margin: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-btn:hover{
|
.nav-btn:hover {
|
||||||
background-color: var(--input-button-hover-color);
|
background-color: var(--input-button-hover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-logo{
|
/* Logo styles */
|
||||||
|
.header-logo {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
height: 5vh;
|
height: 5vh;
|
||||||
background-image: url(../../public/img/logo.png);
|
background-image: url(../../public/img/logo.png);
|
||||||
|
@ -73,7 +84,8 @@ header{
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-button-container{
|
/* Login button styles */
|
||||||
|
.login-button-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0.1vh;
|
top: 0.1vh;
|
||||||
right: 1vw;
|
right: 1vw;
|
||||||
|
@ -82,9 +94,9 @@ header{
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-login-button{
|
.header-login-button {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width:max-content;
|
width: max-content;
|
||||||
font-size: var(--font-size);
|
font-size: var(--font-size);
|
||||||
padding: 0.5vw 1vw;
|
padding: 0.5vw 1vw;
|
||||||
background-color: var(--input-button-color);
|
background-color: var(--input-button-color);
|
||||||
|
@ -102,3 +114,11 @@ header{
|
||||||
.header-login-button:hover {
|
.header-login-button:hover {
|
||||||
background-color: var(--input-button-hover-color);
|
background-color: var(--input-button-hover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.show-hide-btn{
|
||||||
|
width: fit-content;
|
||||||
|
align-self: left;
|
||||||
|
position: absolute;
|
||||||
|
left: 10vw;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
|
@ -22,7 +22,7 @@
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 1dvh 0 0 0 ;
|
padding: 1dvh 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Left panel styles */
|
/* Left panel styles */
|
||||||
|
@ -100,20 +100,19 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-logo{
|
.header-logo {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-left: -40px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hamburger.open{
|
.hamburger.open {
|
||||||
margin-top: 0.5vh;
|
margin-top: 0.5vh;
|
||||||
padding-left: 1vw;
|
padding-left: 1vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-links{
|
.nav-links {
|
||||||
display: none;
|
display: none; /* Hidden by default */
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10vh;
|
top: 10vh; /* Adjust as needed */
|
||||||
left: 0;
|
left: 0;
|
||||||
background-color: var(--burger-menu-background-color);
|
background-color: var(--burger-menu-background-color);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -123,24 +122,42 @@
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-links.active{
|
.nav-links.active {
|
||||||
display: flex;
|
display: flex; /* Show when active */
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-btn{
|
.nav-btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
|
background-color: var(--input-button-color);
|
||||||
|
border: none;
|
||||||
|
font-size: 0.9em;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-btn:hover {
|
||||||
|
background-color: var(--input-button-hover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.hamburger {
|
.hamburger {
|
||||||
display: flex;
|
display: flex; /* Always show hamburger button */
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-login-button{
|
.header-login-button {
|
||||||
right: 5vh;
|
right: 5vh; /* Keep login button visible */
|
||||||
|
}
|
||||||
|
|
||||||
|
.show-hide-btn{
|
||||||
|
width: fit-content;
|
||||||
|
left: 20vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-logo {
|
||||||
|
background-image: url(../../public/img/logo-small.png);
|
||||||
|
width: 4em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
public/img/logo-small.png
Normal file
BIN
public/img/logo-small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
Loading…
Reference in a new issue