Skip to content
Snippets Groups Projects
Commit 49d53cc1 authored by Liliana Sanfilippo's avatar Liliana Sanfilippo
Browse files

Wenn ich bei einer Seite runterscrolle und dann auf eine andere Seite klicke,...

Wenn ich bei einer Seite runterscrolle und dann auf eine andere Seite klicke, springe ich nicht zum Seitenanfang der neuen Seite, sondern auf die selbe Höhe auf der ich davor war.
parent 8d19dbef
No related branches found
No related tags found
No related merge requests found
...@@ -131,7 +131,7 @@ hr{ ...@@ -131,7 +131,7 @@ hr{
body { body {
/* padding-top: 56px; */ /* padding-top: 56px; */
background-color: var(--ourbeige); background-color: var(--ourbeige);
color: #493843; color: var(--offblack);
} }
body.dark-mode { body.dark-mode {
background-color: var(--offblack); background-color: var(--offblack);
......
...@@ -28,13 +28,13 @@ export function Villagebutton({ title, source, page }: { title: string; source: ...@@ -28,13 +28,13 @@ export function Villagebutton({ title, source, page }: { title: string; source:
export function Villbuttonrow(){ export function Villbuttonrow(){
return( return(
<div className="small-row align-items-center bottom-buttons"> <div className="small-row align-items-center bottom-buttons">
<Villagebutton page="/human-practices" source="https://static.igem.wiki/teams/5247/design/icons/humanpractices.png" title="Human Practice"></Villagebutton> <Villagebutton page="/human-practices?tab=hp-quote" source="https://static.igem.wiki/teams/5247/design/icons/humanpractices.png" title="Human Practice"></Villagebutton>
<Villagebutton page="/team" source="https://static.igem.wiki/teams/5247/design/icons/team.png" title="Team"></Villagebutton> <Villagebutton page="/team?tab=members" source="https://static.igem.wiki/teams/5247/design/icons/team.png" title="Team"></Villagebutton>
<Villagebutton page="/experiments" source="https://static.igem.wiki/teams/5247/design/icons/lab.png" title="Experiments"></Villagebutton> <Villagebutton page="/experiments?tab=heading" source="https://static.igem.wiki/teams/5247/design/icons/lab.png" title="Experiments"></Villagebutton>
<Villagebutton page="/description" source="https://static.igem.wiki/teams/5247/design/icons/dna.png" title="Description"></Villagebutton> <Villagebutton page="/description?tab=obenindescription" source="https://static.igem.wiki/teams/5247/design/icons/dna.png" title="Description"></Villagebutton>
<Villagebutton page="/engineering" source="https://static.igem.wiki/teams/5247/design/icons/genetic-engineering.png" title="Engineering"></Villagebutton> <Villagebutton page="/engineering?tab=tab-our-cycle&scrollTo=ourcycle" source="https://static.igem.wiki/teams/5247/design/icons/genetic-engineering.png" title="Engineering"></Villagebutton>
<Villagebutton page="/safety" source="https://static.igem.wiki/teams/5247/design/icons/safety.png" title="Safety"></Villagebutton> <Villagebutton page="/safety?tab=obeninsafety" source="https://static.igem.wiki/teams/5247/design/icons/safety.png" title="Safety"></Villagebutton>
<Villagebutton page="/results" source="https://static.igem.wiki/teams/5247/design/icons/results.png" title="Results"></Villagebutton> <Villagebutton page="/results?tab=resultheading" source="https://static.igem.wiki/teams/5247/design/icons/results.png" title="Results"></Villagebutton>
</div> </div>
) )
} }
......
...@@ -11,45 +11,39 @@ import { ButtonRowTabs } from "../components/Tabs"; ...@@ -11,45 +11,39 @@ import { ButtonRowTabs } from "../components/Tabs";
import { useEffect } from "react"; import { useEffect } from "react";
import PieChart from "../components/Graph"; import PieChart from "../components/Graph";
import PreCyse from "../components/precyse"; import PreCyse from "../components/precyse";
import { handleScrollToCollapse, openNestedTab, openTab } from "../utils/TabNavigation";
import { openFromOtherPage } from "../utils/openFromOtherpAge";
export function Description() { export function Description() {
const location = useLocation(); const location = useLocation();
useEffect(() => { useEffect(() => {
const params = new URLSearchParams(location.search); const params = new URLSearchParams(location.search);
const collapseId = params.get('collapseId'); const collapseId = params.get('collapseId');
const tabId = params.get('tab'); const tabId = params.get('tab');
const subTabId = params.get('subTab'); // Neues Parameter für verschachtelte Tabs
// Open the tab specified by tabId
if (tabId) { // Open the tab specified by tabId (and subTab if nested)
// Hide all tabs if (tabId) {
const tabs = document.querySelectorAll('.enginneeringtab'); if (subTabId) {
tabs.forEach((tab) => { // If subTab is provided, open the nested tab
(tab as HTMLElement).style.display = 'none'; openNestedTab(tabId, subTabId);
}); } else {
// Otherwise, just open the main tab
// Show the selected tab openTab(tabId);
const selectedTab = document.getElementById(tabId); }
if (selectedTab) { }
selectedTab.style.display = 'block';
} // Scroll to the section specified by collapseId after opening the tab
} if (collapseId) {
handleScrollToCollapse(collapseId);
// Scroll to the section specified by collapseId after opening the tab }
if (collapseId) {
const collapseElement = document.getElementById(collapseId); // Open the tab from another page
if (collapseElement) { if (tabId) {
const elementTop = collapseElement.getBoundingClientRect().top + window.pageYOffset; openFromOtherPage(tabId)({ currentTarget: document.getElementById(tabId)! });
const offset = window.innerHeight / 2 - collapseElement.offsetHeight / 2; }
const scrollPosition = elementTop - offset; }, [location.search]);
window.scrollTo({
top: scrollPosition,
behavior: 'smooth',
});
}
}
}, [location.search]);
return ( return (
<div className="row mt-4"> <div className="row mt-4">
...@@ -58,7 +52,7 @@ export function Description() { ...@@ -58,7 +52,7 @@ export function Description() {
<section className="section"> <section className="section">
<H2 id="Abstract" text="Abstract"/> <H2 id="Abstract" text="Abstract"/>
<p>We are proud to introduce our next-generation prime editing technology <PreCyse/> . We aim to develop an innovative gene therapy against cystic fibrosis, tackling the most common mutation ΔF508 of the Cystic Fibrosis Transmembrane Conductance Regulator (CFTR) gene. We optimize lipid nanoparticles (LNPs) for the efficient and cell-specific delivery of our therapeutic mRNA. Current treatment strategies are limited in terms of speed, precision and effectiveness, often failing to achieve long-lasting improvements. In addition, high costs and limited accessibility of pharmaceuticals contribute to adverse prognosis of many patients. We want to develop a monthly applied which represents a cure that is more advanced and user-friendly compared to other medications due to its longer lasting time, lowering the frequency of use. </p> <p id="obenindescription" >We are proud to introduce our next-generation prime editing technology <PreCyse/> . We aim to develop an innovative gene therapy against cystic fibrosis, tackling the most common mutation ΔF508 of the Cystic Fibrosis Transmembrane Conductance Regulator (CFTR) gene. We optimize lipid nanoparticles (LNPs) for the efficient and cell-specific delivery of our therapeutic mRNA. Current treatment strategies are limited in terms of speed, precision and effectiveness, often failing to achieve long-lasting improvements. In addition, high costs and limited accessibility of pharmaceuticals contribute to adverse prognosis of many patients. We want to develop a monthly applied which represents a cure that is more advanced and user-friendly compared to other medications due to its longer lasting time, lowering the frequency of use. </p>
</section> </section>
</div> </div>
......
...@@ -5,58 +5,51 @@ import { useEffect } from "react"; ...@@ -5,58 +5,51 @@ import { useEffect } from "react";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { openElement } from "../utils/openElement"; import { openElement } from "../utils/openElement";
import { H3 } from "../components/Headings"; import { H3 } from "../components/Headings";
import { openFromOtherPage } from "../utils/openFromOtherpAge";
import { openNestedTab, openTab, handleScrollToCollapse } from "../utils/TabNavigation";
export function Engineering() { export function Engineering() {
const location = useLocation(); const location = useLocation();
useEffect(() => { useEffect(() => {
const params = new URLSearchParams(location.search); const params = new URLSearchParams(location.search);
const collapseId = params.get('collapseId'); const collapseId = params.get('collapseId');
const tabId = params.get('tab'); const tabId = params.get('tab');
const subTabId = params.get('subTab'); // Neues Parameter für verschachtelte Tabs
// Open the tab specified by tabId // Open the tab specified by tabId (and subTab if nested)
if (tabId) { if (tabId) {
// Hide all tabs if (subTabId) {
const tabs = document.querySelectorAll('.enginneeringtab'); // If subTab is provided, open the nested tab
tabs.forEach((tab) => { openNestedTab(tabId, subTabId);
(tab as HTMLElement).style.display = 'none'; } else {
}); // Otherwise, just open the main tab
openTab(tabId);
// Show the selected tab
const selectedTab = document.getElementById(tabId);
if (selectedTab) {
selectedTab.style.display = 'block';
}
} }
}
// Scroll to the section specified by collapseId after opening the tab // Scroll to the section specified by collapseId after opening the tab
if (collapseId) { if (collapseId) {
const collapseElement = document.getElementById(collapseId); handleScrollToCollapse(collapseId);
if (collapseElement) { }
const elementTop = collapseElement.getBoundingClientRect().top + window.pageYOffset;
const offset = window.innerHeight / 2 - collapseElement.offsetHeight / 2;
const scrollPosition = elementTop - offset;
window.scrollTo({ // Open the tab from another page
top: scrollPosition, if (tabId) {
behavior: 'smooth', openFromOtherPage(tabId)({ currentTarget: document.getElementById(tabId)! });
}); }
}
}
}, [location.search]); }, [location.search]);
return ( return (
<> <>
<div className="row mt-4"> <div className="row mt-4">
<div className="col"> <div className="col">
<br/> <br/> <br/> <br/> <br/> <br/>
<div id="tab-our-cycle" className="enginneeringtab" style={{display: "block"}}> <div id="tab-our-cycle" className="enginneeringtab" style={{display: "block"}}>
<section > <section > <br id="obenengineering"/>
<div className="bg-lb box" > <div className="bg-lb box" >
<H3 text="Our cycle" id="Our Cycle"></H3> <H3 text="Our cycle" id="ourcycle"></H3>
<p>Hallo Prime Editing diesdas</p> <p>Hallo Prime Editing diesdas</p>
</div> </div>
<div className="box" > <div className="box" >
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { useEffect } from "react"; import { useEffect } from "react";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { openFromOtherPage } from "../utils/openFromOtherpAge"; import { openFromOtherPage } from "../utils/openFromOtherpAge";
import { H2 } from "../components/Headings";
export function Experiments() { export function Experiments() {
const location = useLocation(); const location = useLocation();
...@@ -33,6 +34,7 @@ export function Experiments() { ...@@ -33,6 +34,7 @@ export function Experiments() {
return ( return (
<> <>
<H2 id="heading" text="Heading" ></H2>
<div className="row mt-4"> <div className="row mt-4">
<div className="col-lg-8"> <div className="col-lg-8">
......
...@@ -93,10 +93,10 @@ export function HumanPractices() { ...@@ -93,10 +93,10 @@ export function HumanPractices() {
return ( return (
<div className="row mt-4"> <div className="row mt-4">
<BlockQuoteB <span id="hp-quote"><BlockQuoteB
text="Human Practices is the study of how your work affects the world, and how the world affects your work." text="Human Practices is the study of how your work affects the world, and how the world affects your work."
cite="- Peter Carr, Director of Judging" cite="- Peter Carr, Director of Judging"
/> /> </span>
<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.6mRPyWPFEIQzo-HP4kEukgHaEK%26pid%3DApi&f=1&ipt=ad1e62d3df6a343c1c163a8246d424a7b61015ac43a0cbe279976cf544be7aa7&ipo=images" alt="placeholder"></img> <img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.6mRPyWPFEIQzo-HP4kEukgHaEK%26pid%3DApi&f=1&ipt=ad1e62d3df6a343c1c163a8246d424a7b61015ac43a0cbe279976cf544be7aa7&ipo=images" alt="placeholder"></img>
<H2 text="Introduction" id="intro"/> <H2 text="Introduction" id="intro"/>
......
import { useEffect } from "react"; import { useEffect } from "react";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { openFromOtherPage } from "../utils/openFromOtherpAge"; import { openFromOtherPage } from "../utils/openFromOtherpAge";
import { H2 } from "../components/Headings";
export function Results() { export function Results() {
const location = useLocation(); const location = useLocation();
...@@ -34,6 +35,7 @@ export function Results() { ...@@ -34,6 +35,7 @@ export function Results() {
return ( return (
<> <>
<H2 id="resultheading" text="Heading" ></H2>
<div className="row mt-4"> <div className="row mt-4">
<div className="col-lg-5"> <div className="col-lg-5">
<p>test hallo welt</p> <p>test hallo welt</p>
......
...@@ -2,39 +2,42 @@ import { useEffect } from "react"; ...@@ -2,39 +2,42 @@ import { useEffect } from "react";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { openFromOtherPage } from "../utils/openFromOtherpAge"; import { openFromOtherPage } from "../utils/openFromOtherpAge";
import { H2 } from "../components/Headings"; import { H2 } from "../components/Headings";
import { openNestedTab, openTab, handleScrollToCollapse } from "../utils/TabNavigation";
export function Safety() { export function Safety() {
const location = useLocation(); const location = useLocation();
useEffect(() => { useEffect(() => {
const params = new URLSearchParams(location.search); const params = new URLSearchParams(location.search);
const collapseId = params.get('collapseId'); const collapseId = params.get('collapseId');
const tabId = params.get('tab'); const tabId = params.get('tab');
const subTabId = params.get('subTab'); // Neues Parameter für verschachtelte Tabs
// Scroll to the section specified by collapseId
if (collapseId) { // Open the tab specified by tabId (and subTab if nested)
const collapseElement = document.getElementById(collapseId); if (tabId) {
if (collapseElement) { if (subTabId) {
const elementTop = collapseElement.getBoundingClientRect().top + window.pageYOffset; // If subTab is provided, open the nested tab
const offset = window.innerHeight / 2 - collapseElement.offsetHeight / 2; openNestedTab(tabId, subTabId);
const scrollPosition = elementTop - offset; } else {
// Otherwise, just open the main tab
window.scrollTo({ openTab(tabId);
top: scrollPosition,
behavior: 'smooth',
});
}
}
// Open the tab specified by tabId
if (tabId) {
openFromOtherPage(tabId)({ currentTarget: document.getElementById(tabId)! });
} }
}
// Scroll to the section specified by collapseId after opening the tab
if (collapseId) {
handleScrollToCollapse(collapseId);
}
// Open the tab from another page
if (tabId) {
openFromOtherPage(tabId)({ currentTarget: document.getElementById(tabId)! });
}
}, [location.search]); }, [location.search]);
return ( return (
<> <>
<div className="col"> <div className="col">
<section className="section"> <section id="obeninsafety" className="section">
<div id="Role"><H2 text="Role in iGem"/></div> <div id="Role"><H2 text="Role in iGem"/></div>
</section> </section>
</div> </div>
......
...@@ -30,8 +30,8 @@ export function EngSide(){ ...@@ -30,8 +30,8 @@ export function EngSide(){
<div className="sticky-top"> <div className="sticky-top">
<nav className="sidebar"> <nav className="sidebar">
<div> <div>
<a onClick={openThem({it: "our-cycle"})}> <a onClick={openThem({it: "our-cycle", scrollToId: "ourcycle"})}>
<div className="detail-sideitem"> <div className="detail-sideitem">
<div id="parent-our-cycle" className="sideitem active-sideitem"> <div id="parent-our-cycle" className="sideitem active-sideitem">
<summary>Our Cycle</summary> <summary>Our Cycle</summary>
<span id="our-cycle" className="sidesubtab" style={{display: "block"}}> <span id="our-cycle" className="sidesubtab" style={{display: "block"}}>
......
export function openThem({it}: {it: string}){ export function openThem({it, scrollToId}: {it: string, scrollToId?: string}) {
const gotoandopen = (_event : React.MouseEvent<HTMLElement, MouseEvent>) => { const gotoandopen = (_event: React.MouseEvent<HTMLElement, MouseEvent>) => {
console.log("it classname: " + document.getElementById(it)?.className);
console.log("it classname: " + document.getElementById(it)?.className) console.log("it: " + it);
console.log("it: " + it)
let contenttabid = "tab-" + it; let contenttabid = "tab-" + it;
let parent = "parent-" + it; let parent = "parent-" + it;
console.log("we want to open " + it + " and " + contenttabid) console.log("we want to open " + it + " and " + contenttabid);
let sideitems = document.getElementsByClassName("sideitem"); let sideitems = document.getElementsByClassName("sideitem");
let subtabs = document.getElementsByClassName("sidesubtab"); let subtabs = document.getElementsByClassName("sidesubtab");
let contenttabs = document.getElementsByClassName("enginneeringtab"); let contenttabs = document.getElementsByClassName("enginneeringtab");
// Verstecke alle Subtabs und Content-Tabs
for (let i = 0; i < subtabs.length; i++) { for (let i = 0; i < subtabs.length; i++) {
(subtabs[i] as HTMLElement).style.display = "none"; (subtabs[i] as HTMLElement).style.display = "none";
console.log("Hiding sidebar subtab...") console.log("Hiding sidebar subtab...");
} }
for (let i = 0; i < contenttabs.length; i++) { for (let i = 0; i < contenttabs.length; i++) {
(contenttabs[i] as HTMLElement).style.display = "none"; (contenttabs[i] as HTMLElement).style.display = "none";
console.log("Hiding content tab...") console.log("Hiding content tab...");
} }
for (let i = 0; i < sideitems.length; i++) { for (let i = 0; i < sideitems.length; i++) {
(sideitems[i] as HTMLElement)!.classList.remove("active-sideitem"); (sideitems[i] as HTMLElement)!.classList.remove("active-sideitem");
console.log("Hiding sidebar subtab...") console.log("Hiding sidebar subtab...");
} }
document.getElementById(it)!.style.display = "block"; // Zeige den aktuellen Tab und markiere das entsprechende Sidebar-Item
document.getElementById(parent)!.classList.add("active-sideitem"); document.getElementById(it)!.style.display = "block";
document.getElementById(contenttabid)!.style.display = "block"; document.getElementById(parent)!.classList.add("active-sideitem");
document.getElementById(contenttabid)!.style.display = "block";
} // Scrolle zu der angegebenen ID, falls vorhanden
return gotoandopen; if (scrollToId && document.getElementById(scrollToId)) {
} console.log("Scrolling to: " + scrollToId);
\ No newline at end of file document.getElementById(scrollToId)!.scrollIntoView({ behavior: "smooth" });
}
};
return gotoandopen;
}
...@@ -4,34 +4,55 @@ export const useNavigation = () => { ...@@ -4,34 +4,55 @@ export const useNavigation = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const goToPagesAndOpenTab = (tabId: string, path: string) => { const goToPagesAndOpenTab = (tabId: string, path: string) => {
navigate(`${path}${tabId}`); navigate(`${path}?tab=${tabId}`);
}; };
const goToTextsAndOpenCollapsible = (collapseId: string, path: string) => { const goToTextsAndOpenCollapsible = (collapseId: string, path: string) => {
navigate(`${path}${collapseId}`); navigate(`${path}?collapseId=${collapseId}`);
}; };
const goToPageWithTabAndCollapsible = ({ path, tabId, collapseId }: { path: string, tabId: string, collapseId?: string }) => { const goToPageWithTabAndCollapsible = ({ path, tabId, collapseId }: { path: string, tabId: string, collapseId?: string }) => {
const navigate = useNavigate(); let url = `${path}?tab=${tabId}`;
navigate(`${path}?tab=${tabId}${collapseId ? `&collapseId=${collapseId}` : ''}`); if (collapseId) {
url += `&collapseId=${collapseId}`;
}
navigate(url);
}; };
const goToPageWithNestedTabs = ({ path, tabId, subTabId, collapseId }: { path: string, tabId: string, subTabId?: string, collapseId?: string }) => { const goToPageWithNestedTabs = ({ path, tabId, subTabId, collapseId }: { path: string, tabId: string, subTabId?: string, collapseId?: string }) => {
const navigate = useNavigate();
let url = `${path}?tab=${tabId}`; let url = `${path}?tab=${tabId}`;
if (subTabId) { if (subTabId) {
url += `&subTab=${subTabId}`; url += `&subTab=${subTabId}`;
} }
if (collapseId) { if (collapseId) {
url += `&collapseId=${collapseId}`; url += `&collapseId=${collapseId}`;
}
navigate(url);
};
// Erweiterte Funktion, die auch zu einer bestimmten ID innerhalb eines Tabs scrollen kann
const goToPageWithTabAndScroll = ({ path, tabId, scrollToId }: { path: string, tabId: string, scrollToId?: string }) => {
let url = `${path}?tab=${tabId}`;
if (scrollToId) {
url += `&scrollTo=${scrollToId}`;
} }
navigate(url); navigate(url);
};
/* <a onClick={() => goToPageWithTabAndCollapsible({ // Führe nach der Navigation das Scrollen aus
path: "/human-practices", setTimeout(() => {
tabId: "InvWesthoff", if (scrollToId) {
collapseId: "collapse-1" // ID of the collapsible to open const element = document.getElementById(scrollToId);
})}> if (element) {
Go to Human Practices and Open Collapsible 1 // Berechne die Scroll-Position, um das Element in der Mitte zu setzen
</a> */ const viewportHeight = window.innerHeight;
return { goToPagesAndOpenTab, goToTextsAndOpenCollapsible, goToPageWithTabAndCollapsible, goToPageWithNestedTabs }; const targetPosition = element.getBoundingClientRect().top + window.pageYOffset;
}; const scrollToPosition = targetPosition - viewportHeight / 2 + element.clientHeight / 2;
\ No newline at end of file
window.scrollTo({ top: scrollToPosition, behavior: "smooth" });
}
}
}, 500); // Verzögere das Scrollen, um sicherzustellen, dass der Tab geladen ist
};
return { goToPagesAndOpenTab, goToTextsAndOpenCollapsible, goToPageWithTabAndCollapsible, goToPageWithNestedTabs, goToPageWithTabAndScroll };
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment