Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #95 from SELab-2/language-settings
Browse files Browse the repository at this point in the history
Language settings
  • Loading branch information
ALBERICLOOS authored Mar 16, 2024
2 parents ef7532c + 47f4a29 commit 88eac89
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 9 deletions.
Binary file added frontend/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/assets/styles/small_components.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
left: 50%;
transform: translate(-50%, -50%);
z-index: 9999; /* to get over bulma's cards index */
}

.dropdown-content {
width: fit-content;
}
2 changes: 1 addition & 1 deletion frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {RiAccountPinBoxLine} from "react-icons/ri";
export function Header(): JSX.Element {
return (
<nav className={"main-nav is-flex is-flex-direction-row is-justify-content-space-between is-align-items-center"}>
<img src={"/delphi_favicon_circle.png"} alt={"image"}/>
<img src={"/logo.png"} alt={"image"}/>
<p className={"is-align-self-center"}><p>Home</p></p>
<button className={"button mx-2 is-transparent"}>
<div className={"icon-text"}>
Expand Down
70 changes: 64 additions & 6 deletions frontend/src/components/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,69 @@
import {JSX, useState} from "react";
import {BiLogOut} from "react-icons/bi";
import '../assets/styles/small_components.css'
import {JSX} from "react";
import {Link} from "react-router-dom";
import {IoMdClose} from "react-icons/io";
import {MdLanguage, MdOutlineKeyboardArrowDown} from "react-icons/md";

export type Language = "NL" | "EN";

function DropdownLanguage(props: { language: Language, changeLanguage: (language: Language) => void }): JSX.Element {

const [isOpen, setIsOpen] = useState<boolean>(false);

const toggle = (): void => {
setIsOpen(!isOpen);
}

export default function Settings(): JSX.Element {
return (
<>
<div className={"card popup px-5 py-5"}>
<div className={`dropdown ${isOpen ? 'is-active' : ''}`}>
<div className="dropdown-trigger">
<button className="button" aria-haspopup="true" aria-controls="dropdown-menu" onClick={toggle}>
<span className={"is-flex is-align-items-center px"}>
<MdLanguage className={"mr-2"}/><p>{props.language}</p>
</span>
<span className="icon is-small">
<MdOutlineKeyboardArrowDown/>
</span>
</button>
</div>
<div className={"dropdown-menu"}>
<div className="dropdown-content">
<a href="#" className="dropdown-item" onClick={() => {props.changeLanguage("EN"); toggle()}}>
English
</a>
<a className="dropdown-item" onClick={() => {props.changeLanguage("NL"); toggle()}}>
Nederlands
</a>
</div>
</div>
</div>
)
}


function Settings(props: { closeSettings: () => void }): JSX.Element {

// TODO: get current language from user
const currLang: Language = "NL";
const [language, setLanguage] = useState<Language>(currLang);

const changeLanguage = (newLang: Language): void => {
if (language !== newLang) {
// TODO: send it to the database
setLanguage(newLang);
}
}

return (
<div className={"card popup"}>
<div className={"is-flex is-align-items-center is-justify-content-right"}>
<span className={"py-2"}>
<DropdownLanguage language={language} changeLanguage={changeLanguage}/>
</span>
<button className={"button mx-2 my-1"} onClick={props.closeSettings}><IoMdClose/></button>
</div>
<div className={"px-5 pb-5"}>
<p className={"title is-flex is-justify-content-center"}>Settings</p>
<img src={"/delphi_full.png"} alt={"image"}/>
<div className={"is-flex px-5 py-1 is-align-items-center"}>
Expand All @@ -26,6 +82,8 @@ export default function Settings(): JSX.Element {
</div>
</div>
</div>
</>
</div>
)
}
}

export default Settings;
8 changes: 6 additions & 2 deletions frontend/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import Settings from "./Settings.tsx";
export function Sidebar(): JSX.Element {
const [isOpen, setIsOpen] = useState(false);

const handleSettings: () => void = () => {
setIsOpen(!isOpen)
}

return (
<>
<aside className={"menu is-flex is-flex-direction-column is-justify-content-space-between"}>
Expand All @@ -16,11 +20,11 @@ export function Sidebar(): JSX.Element {
<li><a><PiFolder size={30}/></a></li>
</ul>
<ul className={"menu-list"}>
<li><a className={"is-transparent"} onClick={() => setIsOpen(!isOpen)}><IoMdSettings size={30}/></a>
<li><a className={"is-transparent"} onClick={handleSettings}><IoMdSettings size={30}/></a>
</li>
</ul>
</aside>
{isOpen && <Settings/>}
{isOpen && <Settings closeSettings={handleSettings}/>}
</>
)
}
Expand Down

0 comments on commit 88eac89

Please sign in to comment.