Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert filter button code from jQuery to JavaScript #771

Open
brittanyrw opened this issue Oct 6, 2023 · 1 comment
Open

Convert filter button code from jQuery to JavaScript #771

brittanyrw opened this issue Oct 6, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@brittanyrw
Copy link
Owner

brittanyrw commented Oct 6, 2023

In the project, there are a set of filters at the top that will allow a user to show only movie, TV show or musical cards. The code for this is located in the app.js.

Convert the code for the filters from jQuery into JavaScript. Only convert this specific section of code.

$("#filters button").each(function () {
  $(this).on("click", function () {
    const filtertag = $(this).attr("data-filter");
    $("#message").hide();
    $("div.emoji-card-title").addClass("hide-card");
    if (filtertag == "view-all") {
      // If the user clicks on view all, show all cards.
      $("div.emoji-card").show();
    } else if (
      // If the user clicks on movies, musicals or tv shows, show the cards that fall into that category and hide all cards that do not fall into that category.
      $("div.emoji-card[data-filter='" + filtertag + "']").length > 0
    ) {
      $("div.emoji-card").show();
      $("div.emoji-card:not([data-filter='" + filtertag + "'])").hide();
    } else {
      // If there are no cards that match the filter, display a message that says that there are no cards for that category.
      $("div.emoji-card").hide();
      $("#message").show();
      $("#message").html(
        "<p>There are no " + filtertag + " cards on this page. 🙁</p>"
      );
    }
  });
});
@brittanyrw brittanyrw added enhancement New feature or request good first issue Good for newcomers and removed good first issue Good for newcomers labels Oct 6, 2023
@harmit17
Copy link

Hey @brittanyrw, I would like to work on it. Can you assign this issue to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants