Skip to content

Commit

Permalink
Improve/fix styles and list of projects
Browse files Browse the repository at this point in the history
  • Loading branch information
mwydmuch committed Oct 20, 2023
1 parent a8d70c6 commit 1e723d6
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 66 deletions.
12 changes: 8 additions & 4 deletions _includes/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ body {
.card-property {
font-size: 0.8em;
display: inline-block;
white-space: nowrap;
/* white-space: nowrap; */
padding-right: 30px;
}

Expand Down Expand Up @@ -1116,8 +1116,7 @@ body {
transition: 0.3s;
padding: 30px;
margin-bottom: 30px

}
}

.card:hover {
/* Add shadows to create the "card" effect */
Expand All @@ -1126,7 +1125,12 @@ body {
padding: 30px;
margin-bottom: 30px;
background-color: rgb(245, 245, 245);
}
}

.lab-logo{
margin: 0 auto 25px auto;
}


.research-lab-entry {
margin-bottom: -30px;
Expand Down
2 changes: 1 addition & 1 deletion _includes/js/intro-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function draw(){
// Draw right, croped
let imgH = imgMap.height,
imgW = imgMap.width,
ratio = width / 2 / imgMap.width,
ratio = Math.max(width / 2 / imgW, height / imgH),
drawImgH = imgH * ratio,
drawImgW = imgW * ratio;

Expand Down
84 changes: 63 additions & 21 deletions _includes/js/search.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,72 @@
var projects = document.querySelectorAll('.project-card');
var searchInput = document.getElementById('search');
var projectsFound = document.getElementById('projects-found');
var showMoreButton = document.getElementById('show-more-projects');
var matchingProjects = projects.length;
var visibleProjects = 0;
var projectsPerPage = 6;

projects.forEach(function(project, index) {
console.log(project);
project.setAttribute('search-data', project.textContent.replace(/\s/g, " ").toLowerCase());
});

function debounce(callback, wait) {
let timeout;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(function () { callback.apply(this, args); }, wait);
};
}

searchInput.addEventListener('keyup', debounce( () => {
let search = searchInput.value.toLowerCase();
let found = 0;
if(searchInput){
// Add search data to projects and reset their visibility
projects.forEach(function(project, index) {
if (project.getAttribute('search-data').includes(search)) {
console.log(project);
project.setAttribute('search-data', project.textContent.replace(/\s/g, " ").toLowerCase());
if(visibleProjects < projectsPerPage){
project.style.display = 'block';
++found;
++visibleProjects;
}
});

function updateShowMoreButton() {
if (visibleProjects < matchingProjects) {
showMoreButton.style.display = 'block';
} else {
project.style.display = 'none';
showMoreButton.style.display = 'none';
}
}

// Add event listener to show more button
updateShowMoreButton();
showMoreButton.addEventListener('click', function() {
let projects = document.querySelectorAll('.search-match');
let newVisibleProjects = visibleProjects + projectsPerPage;
for (var i = visibleProjects; i < newVisibleProjects; ++i) {
if (projects[i]) {
projects[i].style.display = 'block';
++visibleProjects;
}
}
updateShowMoreButton();
});
projectsFound.innerHTML = found.toString();
}, 500))

// Add event listener to search input
function debounce(callback, wait) {
let timeout;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(function () { callback.apply(this, args); }, wait);
};
}

searchInput.addEventListener('keyup', debounce( () => {
let search = searchInput.value.toLowerCase();
matchingProjects = 0;
visibleProjects = 0;
projects.forEach(function(project, index) {
project.style.display = 'none';
if (project.getAttribute('search-data').includes(search)) {
project.classList.add('search-match');
++matchingProjects;
if(visibleProjects < projectsPerPage){
project.style.display = 'block';
++visibleProjects;
}
} else {
project.classList.remove('search-match');
}
});
projectsFound.innerHTML = matchingProjects.toString();
updateShowMoreButton();
}, 500));

}
71 changes: 38 additions & 33 deletions _includes/research-platform/lab-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,49 @@
data-target="#lab-collapse-{{forloop.index}}"
aria-expanded="true"
aria-controls="lab-collapse-{{forloop.index}}"
style="text-align: left; background: transparent; outline: 0; border: 0px;"
style="text-align: left; background: transparent; outline: 0; border: 0px; width: 100%;"
>
{% endif %}

<div class="row">
<div class="col-lg-9 col-md-9 col-sm-12">
<h3>
{% if lab.url and make_collapsable %}
<a href="{{ lab.url | relative_url }}">{{ display_name }}</a>
{% else %}
{{ display_name }}
<div class="hidden-lg hidden-md col-sm-12 col-xs-12">
{% if lab.logo %}
<img src="{{ lab.logo | relative_url }}" alt="{{lab.name}} logo" class="width-100 width-max-100px lab-logo">
{% endif %}
</h3>
<p class="card-info">
<span class="card-property"><i class="fa-solid fa-location-dot"></i> Location: {{lab.location}}{% if lab.remote %} / remote {% endif %}</span>
{% if lab.website_url %}
{% assign url = lab.website_url %}
{% assign check = url | split: '://' %}

{% if check[0] == 'http' or check[0] == 'https' %}
{% assign show_url = check[1] %}
{% else %}
{% assign show_url = url %}
{% assign url = 'https://' | append: lab.website_url %}
{% endif %}

<span class="card-property"><i class="fa-solid fa-globe"></i> Website: <a href="{{ url }}">{{ show_url }}</a></span>
{% endif %}
{% if filtered_projects.size != 0 %}
<span class="card-property"><i class="fa-solid fa-list"></i> Available projects: {{ filtered_projects | size }} </span>
</div>
<div class="col-lg-9 col-md-9 col-sm-12">
<h3>
{% if lab.url and make_collapsable %}
<a href="{{ lab.url | relative_url }}">{{ display_name }}</a>
{% else %}
{{ display_name }}
{% endif %}
</h3>
<p class="card-info">
<span class="card-property"><i class="fa-solid fa-location-dot"></i> Location: {{lab.location}}{% if lab.remote %} / remote {% endif %}</span>
{% if lab.website_url %}
{% assign url = lab.website_url %}
{% assign check = url | split: '://' %}

{% if check[0] == 'http' or check[0] == 'https' %}
{% assign show_url = check[1] %}
{% else %}
{% assign show_url = url %}
{% assign url = 'https://' | append: lab.website_url %}
{% endif %}

<span class="card-property"><i class="fa-solid fa-globe"></i> Website: <a href="{{ url }}">{{ show_url }}</a></span>
{% endif %}
{% if filtered_projects.size != 0 %}
<span class="card-property"><i class="fa-solid fa-list"></i> Available projects: {{ filtered_projects | size }} </span>
{% endif %}
</p>
</div>
<div class="col-lg-3 col-md-3 hidden-sm hidden-xs" style="text-align: right">
{% if lab.logo %}
<img src="{{ lab.logo | relative_url }}" alt="{{lab.name}} logo" class="width-100 width-max-100px lab-logo">
{% endif %}
</p>
</div>
<div class="col-lg-3 col-md-3 hidden-xs hidden-sm" style="text-align: right">
{% if lab.logo %}
<img src="{{ lab.logo | relative_url }}" alt="{{lab.name}} logo" class="width-100 width-max-100px">
{% endif %}
</div>
</div>
</div>
{% if make_collapsable == true %}
</button>
Expand All @@ -78,7 +83,7 @@ <h3>
<div id="lab-collapse-{{forloop.index}}" class="collapse show" aria-labelledby="lab-heading-{{forloop.index}}" style="height: 0px;" data-parent="#labs-accordion">
<div class="card-content">
{{ lab.content | markdownify }}
<a href="{{lab.url}}" class="btn btn-default btn-lg"><i class="fa-solid fa-file"></i> See lab's page</a>
<a href="{{lab.url}}" class="btn btn-default"><i class="fa-solid fa-file"></i> See lab's page</a>
</div>
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion _includes/research-platform/labs-collapsable.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<section id="labs" class="container content-section">
<div class="row">
<div class="col-lg-12">
<h2>/ Laboratories with projects: {{ site.labs | size }}</h2>
<h2>/ Laboratories and research groups with projects: {{ site.labs | size }}</h2>
</div>
</div>

Expand Down
31 changes: 25 additions & 6 deletions _includes/research-platform/project-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,47 @@
.education_level
.remote
make_collapsable
make_invisible
{% endcomment %}

{% assign project = include.project %}
{% assign make_collapsable = include.make_collapsable | default: false %}
{% assign make_invisible = include.make_invisible | default: false %}
{% assign lab = site.labs | where: 'short_name', project.lab_name | first %}
{% if lab == nil %}
{% assign lab = site.labs | where: 'name', project.lab_name | first %}
{% endif %}

<div class="card project-card">
{% if make_invisible == true %}
<div class="card project-card search-match" style="display: none;">
{% else %}
<div class="card project-card search-match">
{% endif %}
<div class="card-header" id="project-heading-{{forloop.index}}">
{% if make_collapsable == true %}
<button
data-toggle="collapse"
data-target="#project-collapse-{{forloop.index}}"
aria-expanded="true"
aria-controls="project-collapse-{{forloop.index}}"
style="text-align: left; background: transparent; outline: 0; border: 0px;"
style="text-align: left; background: transparent; outline: 0; border: 0px; width: 100%;"
>
{% endif %}

<div class="row">
<div class="hidden-lg hidden-md col-sm-12">
{% if lab %}
<a href="{{ lab.url | relative_url }}">
{% if lab.logo %}
<img src="{{ lab.logo | relative_url }}" alt="{{lab.name}} logo" class="width-100 width-max-100px lab-logo">
{% else %}
<h3><i class="fa-solid fa-flask"></i> {{ lab.name }} </h3>
{% endif %}
</a>
{% else %}
<h3><i class="fa-solid fa-flask"></i> {{ project.lab_name }} </h3>
{% endif %}
</div>
<div class="col-lg-9 col-md-9 col-sm-12">
<h3>
{% if project.url and make_collapsable %}
Expand Down Expand Up @@ -68,13 +87,13 @@ <h3>
{% if lab %}
<a href="{{ lab.url | relative_url }}">
{% if lab.logo %}
<img src="{{ lab.logo | relative_url }}" alt="{{lab.name}} logo" class="width-100 width-max-100px">
<img src="{{ lab.logo | relative_url }}" alt="{{lab.name}} logo" class="width-100 width-max-100px lab-logo">
{% else %}
<h4><i class="fa-solid fa-flask"></i> {{ lab.name }} </h4>
<h3><i class="fa-solid fa-flask"></i> {{ lab.name }} </h3>
{% endif %}
</a>
{% else %}
<h4><i class="fa-solid fa-flask"></i> {{ project.lab_name }} </h4>
<h3><i class="fa-solid fa-flask"></i> {{ project.lab_name }} </h3>
{% endif %}
</div>

Expand All @@ -100,7 +119,7 @@ <h4><i class="fa-solid fa-flask"></i> {{ project.lab_name }} </h4>
<div class="card-content">
{{ project.content | markdownify }}
<p><i class="fa-solid fa-address-book"></i> Contact: {{ project.leader }} ({{ project.contact | replace: "@", " [ at ] " }})</p>
<a href="{{project.url}}" class="btn btn-default btn-lg"><i class="fa-solid fa-file"></i> See project's page</a>
<a href="{{project.url}}" class="btn btn-default"><i class="fa-solid fa-file"></i> See project's page</a>
</div>
</div>
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions _includes/research-platform/projects-collapsable.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ <h2>/ Projects available: <span id="projects-found">{{ site.projects | size }}</
{% include research-platform/project-card.html
project = project
make_collapsable = true
make_invisible = true
%}
{% endfor %}
<div>
<button class="btn btn-default" id="show-more-projects" style="display: none;">Show more projects</button>
</div>
</div>
</div>
</section>
1 change: 1 addition & 0 deletions _layouts/lab.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h3>Lab's projects:</h3>
{% include research-platform/project-card.html
project = project
make_collapsable = true
make_invisible = false
%}
{% endfor %}
</div>
Expand Down

0 comments on commit 1e723d6

Please sign in to comment.