Skip to content

Commit

Permalink
fix scrolling behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedBasem20 committed Aug 10, 2023
1 parent 304ceb2 commit 5585ef2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 22 deletions.
8 changes: 6 additions & 2 deletions aiida-registry-app/src/App.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#root {
text-align: left;
}
Expand Down Expand Up @@ -65,6 +64,11 @@ h1 {
background-color: #d5cccc;
}

#detailsContainer {
display: flex;
margin-left: 50px;
}

#sidebar .MuiDrawer-paper {
width: 340px;
max-height:calc(100vh);
Expand Down Expand Up @@ -202,7 +206,7 @@ td {
.footer {
display: table;
/* Distance with other content */
width: calc(100% - 380px);
width: calc(100% - 64px);
margin-top: 16px;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
Expand Down
49 changes: 29 additions & 20 deletions aiida-registry-app/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import whiteLogo from './assets/logo-white-text.svg'
import MARVEL from './assets/MARVEL.png'
import MaX from './assets/MaX.png'
import './App.css'
import Box from '@mui/material/Box';
import { useEffect } from 'react';

import MainIndex from './Components/MainIndex'
import Details from './Components/Details'
Expand Down Expand Up @@ -62,35 +62,44 @@ function Footer() {
/**
* DetailsContainer component displays the details of a specific plugin identified by the key parameter.
* It renders the Details component on the left side and the Sidebar component on the right side.
*
* @component
* @example
* // Render DetailsContainer with a specific plugin key:
* <DetailsContainer />
*
*
* @returns {JSX.Element} JSX element representing the DetailsContainer.
*/

function DetailsContainer() {
const { key } = useParams();
var prevScrollpos = window.scrollY;
window.onscroll = function() {
var currentScrollPos = window.scrollY;
if (prevScrollpos > currentScrollPos) {
document.querySelector("header").style.top = "0";
document.querySelector("#sidebar .MuiDrawer-paper").style.marginTop = '155px';
} else {
if (prevScrollpos > 150) {
document.querySelector("header").style.top = "-155px";
document.querySelector("#sidebar .MuiDrawer-paper").style.marginTop = '0';
useEffect(() => {
//Decrease the footer width on the details page to save some space for the sidebar.
document.querySelector('footer').style.width = 'calc(100% - 380px)';

// Clean up the styling when the component unmounts
return () => {
document.querySelector('footer').style.width = 'calc(100% - 64px)'; // Revert to default styles
};
}, []);
function setupScrollBehavior() {
//Display the header and move the sidebar under it when scrolling up
//& Hide the header and align sidebar to top when scrolling down.
var prevScrollpos = window.scrollY;
window.onscroll = function() {
var currentScrollPos = window.scrollY;
if (prevScrollpos > currentScrollPos) {
document.querySelector("header").style.top = "0";
document.querySelector("#sidebar .MuiDrawer-paper").style.marginTop = '155px';
} else {
if (prevScrollpos > 150) {
document.querySelector("header").style.top = "-155px";
document.querySelector("#sidebar .MuiDrawer-paper").style.marginTop = '0';
}
}
prevScrollpos = currentScrollPos;
}
}
prevScrollpos = currentScrollPos;
}
setupScrollBehavior();

return (
<>
<div style={{display:'flex', marginLeft:'50px'}}>
<div id='detailsContainer'>
<Details pluginKey={key} />
<Sidebar pluginKey={key} />
</div>
Expand Down
17 changes: 17 additions & 0 deletions aiida-registry-app/src/Components/MainIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ function MainIndex() {
const [sortOption, setSortOption] = useState('alpha');
const [sortedData, setSortedData] = useState(plugins);
document.documentElement.style.scrollBehavior = 'auto';

function setupScrollBehavior() {
var prevScrollpos = window.scrollY;
window.onscroll = function() {
var currentScrollPos = window.scrollY;
if (prevScrollpos > currentScrollPos) {
document.querySelector("header").style.top = "0"; //Display the header when scrolling up.
} else {
if (prevScrollpos > 150) {
document.querySelector("header").style.top = "-155px"; //Hide the header when scrolling down.
}
}
prevScrollpos = currentScrollPos;
}
}
setupScrollBehavior();

const handleSort = (option) => {
setSortOption(option);

Expand Down

1 comment on commit 5585ef2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential issues in retrieved plugin metadata (ignore those for plugins not managed by you)

WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-QECpWorkChain]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-aenet]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-aenet]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-alloy]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-alloy]
WARNING! Entry point 'elastic' does not start with prefix 'alloy.' [aiida-alloy]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-autocas]
WARNING! No bdist_wheel available for PyPI release [aiida-bands-inspect]
WARNING! AiiDA version not found [aiida-bands-inspect]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-bigdft]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-castep]
WARNING! No bdist_wheel available for PyPI release [aiida-catmat]
WARNING! AiiDA version not found [aiida-catmat]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-catmat]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-catmat]
WARNING! Entry point 'vasp_base_parser' does not start with prefix 'catmat.' [aiida-catmat]
WARNING! Entry point 'vasp.base' does not start with prefix 'catmat.' [aiida-catmat]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-ce]
WARNING! No bdist_wheel available for PyPI release [aiida-champ]
WARNING! AiiDA version not found [aiida-champ]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-champ]
WARNING! Entry point 'CHAMP' does not start with prefix 'champ.' [aiida-champ]
WARNING! Entry point 'CHAMP' does not start with prefix 'champ.' [aiida-champ]
WARNING! Entry point 'CHAMP' does not start with prefix 'champ.' [aiida-champ]
WARNING! Entry point 'CHAMP' does not start with prefix 'champ.' [aiida-champ]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-core]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-crystal-dft]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-crystal17]
WARNING! Entry point 'potcar' does not start with prefix 'cusp.' [aiida-cusp]
WARNING! Development status in classifiers (alpha) does not match development_status in metadata (stable) [aiida-diff]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-diff]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-dynamic-workflows]
WARNING! AiiDA version not found [aiida-dynamic-workflows]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.github.com/environ-developers/aiida-environ/master/setup.json [aiida-environ]
WARNING! AiiDA version not found [aiida-environ]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-eon]
WARNING! AiiDA version not found [aiida-eon]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-eonclient]
WARNING! AiiDA version not found [aiida-eonclient]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.github.com/sphuber/aiida-fenics/master/setup.json [aiida-fenics]
WARNING! AiiDA version not found [aiida-fenics]
WARNING! AiiDA version not found [aiida-fireworks-scheduler]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-fireworks-scheduler]
WARNING! Entry point 'fireworks' does not start with prefix 'fireworks_scheduler.' [aiida-fireworks-scheduler]
WARNING! Entry point 'fireworks-scheduler' does not start with prefix 'fireworks_scheduler.' [aiida-fireworks-scheduler]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-fleur]
WARNING! Prefix 'gaussian' does not follow naming convention. [aiida-gaussian-datatypes]
WARNING! Unable to read wheel file from PyPI release: No entry_points.txt found in wheel [aiida-graphql]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-graphql]
WARNING! Entry point 'general-MD' does not start with prefix 'gromacs.' [aiida-gromacs]
WARNING! Entry point 'general-MD' does not start with prefix 'gromacs.' [aiida-gromacs]
WARNING! Unable to read wheel file from PyPI release: No entry_points.txt found in wheel [aiida-grouppathx]
WARNING! Development status in classifiers (alpha) does not match development_status in metadata (beta) [aiida-grouppathx]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-grouppathx]
WARNING! Entry point 'gpx' does not start with prefix 'grouppathx.' [aiida-grouppathx]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-gudhi]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-gudhi]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-gulp]
WARNING! No bdist_wheel available for PyPI release [aiida-kkr]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.github.com/JuDFTteam/aiida-kkr/develop/setup.json [aiida-kkr]
WARNING! AiiDA version not found [aiida-kkr]
WARNING! Development status in classifiers (beta) does not match development_status in metadata (stable) [aiida-kkr]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-kkr]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-lammps]
WARNING! Entry point 'dynaphopy' does not start with prefix 'lammps.' [aiida-lammps]
WARNING! Entry point 'dynaphopy' does not start with prefix 'lammps.' [aiida-lammps]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-lsmo]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-lsmo]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-metavo-scheduler]
WARNING! Entry point 'sshmetavo' does not start with prefix 'metavo_scheduler.' [aiida-metavo-scheduler]
WARNING! Entry point 'pbsprometavo' does not start with prefix 'metavo_scheduler.' [aiida-metavo-scheduler]
WARNING! Entry point 'sshmetavo' does not start with prefix 'metavo_scheduler.' [aiida-metavo-scheduler]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-mpds]
WARNING! Entry point 'crystal.mpds' does not start with prefix 'mpds.' [aiida-mpds]
WARNING! Entry point 'crystal.cif' does not start with prefix 'mpds.' [aiida-mpds]
WARNING! Entry point 'crystal.aiida' does not start with prefix 'mpds.' [aiida-mpds]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.githubusercontent.com/nanotech-empa/aiida-nanotech-empa/master/setup.json [aiida-nanotech-empa]
WARNING! AiiDA version not found [aiida-nanotech-empa]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-nanotech-empa]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.githubusercontent.com/atztogo/aiida-nims-scheduler/master/setup.json [aiida-nims-scheduler]
WARNING! AiiDA version not found [aiida-nims-scheduler]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-nims-scheduler]
WARNING! Prefix 'quantumespresso.ocv' does not follow naming convention. [aiida-open_circuit_voltage]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-orca]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-phtools]
WARNING! No bdist_wheel available for PyPI release [aiida-porousmaterials]
WARNING! AiiDA version not found [aiida-porousmaterials]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-porousmaterials]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-psi4]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-python]
WARNING! AiiDA version not found [aiida-python]
WARNING! Prefix 'aiidapython' does not follow naming convention. [aiida-python]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-qeq]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-qeq]
WARNING! No bdist_wheel available for PyPI release [aiida-qp2]
WARNING! AiiDA version not found [aiida-qp2]
WARNING! Entry point 'noncollinearhydrogen' does not start with prefix 'quantumespresso.' [aiida-quantumespresso]
WARNING! Entry point 'spinorbithydrogen' does not start with prefix 'quantumespresso.' [aiida-quantumespresso]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-quantumespresso-hp]
WARNING! Prefix 'quantumespresso.hp' does not follow naming convention. [aiida-quantumespresso-hp]
WARNING! No bdist_wheel available for PyPI release [aiida-raspa]
WARNING! AiiDA version not found [aiida-raspa]
WARNING! Prefix 'core' does not follow naming convention. [aiida-shell]
WARNING! No bdist_wheel available for PyPI release [aiida-siesta]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.github.com/siesta-project/aiida_siesta_plugin/master/setup.json [aiida-siesta]
WARNING! No bdist_wheel available for PyPI release [aiida-spirit]
WARNING! AiiDA version not found [aiida-spirit]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-sshonly]
WARNING! Entry point 'ssh_only' does not start with prefix 'sshonly.' [aiida-sshonly]
WARNING! No bdist_wheel available for PyPI release [aiida-statefile-schedulers]
WARNING! AiiDA version not found [aiida-statefile-schedulers]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-statefile-schedulers]
WARNING! No bdist_wheel available for PyPI release [aiida-strain]
WARNING! AiiDA version not found [aiida-strain]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-supercell]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-supercell]
WARNING! No bdist_wheel available for PyPI release [aiida-symmetry-representation]
WARNING! AiiDA version not found [aiida-symmetry-representation]
WARNING! No bdist_wheel available for PyPI release [aiida-tbextraction]
WARNING! AiiDA version not found [aiida-tbextraction]
WARNING! No bdist_wheel available for PyPI release [aiida-tbmodels]
WARNING! AiiDA version not found [aiida-tbmodels]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-tcod]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-tcod]
WARNING! Entry point 'UppASD_core_calculations' does not start with prefix 'uppasd.' [aiida-uppasd]
WARNING! Entry point 'UppASD_core_parsers' does not start with prefix 'uppasd.' [aiida-uppasd]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-wannier90-workflows]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-wien2k]
WARNING! AiiDA version not found [aiida-wien2k]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-yambo]
WARNING! AiiDA version not found [aiida-yascheduler]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.githubusercontent.com/antimomarrazzo/aiida-z2pack/master/setup.json [aiida-z2pack]
WARNING! AiiDA version not found [aiida-z2pack]
WARNING! No bdist_wheel available for PyPI release [aiida-zeopp]
WARNING! AiiDA version not found [aiida-zeopp]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-zeopp]

Please sign in to comment.