Skip to content

Commit

Permalink
Merge branch 'main' into add-authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeker authored Mar 1, 2024
2 parents 410369c + d1f1ce9 commit c2db380
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
16 changes: 16 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,19 @@ h3 {
.signup-error, .login-error {
font-size: 25px;
}

.search-container {
margin-bottom: 40px;
}

#searchBar {
width: 90%;
padding: 15px;
font-size: 25px;
border-radius: 5px;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
margin: auto;
}
36 changes: 29 additions & 7 deletions templates/decks.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,47 @@

{% block container %}

<div class="search-container">
<input type="text" id="searchBar" placeholder="Search decks...">
</div>

{% for deck in mainDecks %}
<a href="{{ url_for('displayDeck', username='guest', deckTitle=deck.title) }}" style="text-decoration:none">
<a href="{{ url_for('displayDeck', username='guest', deckTitle=deck.title )}}" style="text-decoration:none" class="deck-link">
<button class="main-deck">
<h3>{{ deck.title }}</h3>
</button>
</a>
{% endfor %}

{% for deck in personalDecks %}
<a href="{{ url_for('displayDeck', username=username, deckTitle=deck.title) }}" style="text-decoration:none">
<a href="{{ url_for('displayDeck', username=username, deckTitle=deck.title) }}" style="text-decoration:none" class="deck-link">>
<button class="personal-deck">
<h3>{{ deck.title }}</h3>
</button>
</a>
{% endfor %}

{% if isAuth %}
<button class="add-deck">
<h3> + </h3>
</button>

<script>
const searchBar = document.getElementById("searchBar");
const deckLinks = document.querySelectorAll(".deck-link");

searchBar.addEventListener("input", function() {
const searchTerm = searchBar.value.toLowerCase();
deckLinks.forEach(function(link) {
const deckTitle = link.querySelector("h3").textContent.toLowerCase();
if (deckTitle.includes(searchTerm)) {
link.style.display = "block";
} else {
link.style.display = "none";
}
});
});
</script>

{% if isAuth %}
<button class="add-deck">
<h3> + </h3>
</button>

<form action="{{ url_for('createDeck', username=username) }}" method="post" class="add-deck-form" style="display: none">
<p>x</p>
Expand All @@ -47,3 +68,4 @@ <h3> + </h3>
{% endif %}

{% endblock %}

0 comments on commit c2db380

Please sign in to comment.