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

Fix nav changes not being displayed on small screens #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CornPopGuy
Copy link

[Fix nav changes not being displayed on small screens.

Fix nav changes not being displayed on small screens
Fix nav changes not being displayed on small screens
Copy link
Contributor

@krenny krenny left a comment

Choose a reason for hiding this comment

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

Thank you for submitting your PR. I appreciate your efforts in addressing issue #2.

You have effectively resolved the problem by adding a second

  • element. However, I would suggest using n[0].insertAdjacentElement("beforeend", a.cloneNode(true)); instead of duplicating the code.

    By using the cloneNode() function, you can avoid duplicating the code and achieve the same desired result. It creates a copy of the element, including all its children and attributes. You can find more information about the cloneNode() function here.

    Additionally, I would like to understand the benefits of the executeAsync() function for the code base. Could you please provide an explanation?

  • Comment on lines +158 to +186

    let a = document.createElement("li");
    a.setAttribute("class", "px-6 py-3");
    span = document.createElement("span");
    span.setAttribute("class", "focus:outline-none");
    span.setAttribute("tabindex", "0");
    a.appendChild(span);
    link = document.createElement("a");
    link.setAttribute("href", buttons[title].link);
    link.setAttribute("target", buttons[title].target);
    if (buttons[title].target == "_blank")
    link.setAttribute("rel", "noopener noreferrer");
    link.setAttribute(
    "class"
    , "cursor-pointer router-link flex justify-between"
    );
    span.appendChild(link);
    p = document.createElement("p");
    p.innerHTML = title;
    link.appendChild(p);
    p = document.createElement("p");
    p.setAttribute("class", "text-white");
    p.innerHTML = " • ";
    link.appendChild(p);

    n[1].insertAdjacentElement("beforeend", a);

    });
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    There is no need to duplicate this part.
    Better use .cloneNode(true);

    var s = setInterval(function () {
    try {
    let n = document.querySelectorAll('.absolute.top-0.left-0.w-full');
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Why is querySelectorAll needed here?

    Comment on lines +122 to +123
    // console.log(n2);
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Please remove unneeded console.log() or replace it with console.debug()

    Comment on lines +31 to +37
    function executeAsync(func) {
    try {
    let bar = e.target.parentElement;
    if(bar.classList == "flex justify-between cursor-pointer px-6 py-3") bar = bar.parentElement;
    if (
    !(
    bar.classList ==
    "bg-primary-900 border-t first:border-t-0 border-primary-500"
    )
    )
    throw "Clicked element isn't a navbar element";
    if (bar.children[0].children[0].innerHTML == buttons[title].navbar) {
    let listing =
    bar.children[1].children[0].children[0].cloneNode(true);
    listing.children[0].children[0].children[0].innerHTML = title;
    try {
    let link = "";
    extractString(buttons[title].link, "<", ">").forEach(
    (commands) => {
    if (commands.charAt(0) == "<")
    link = link + eval(commands.substring(1));
    else link = link + commands;
    setTimeout(func, 0);
    } catch (error) {
    // (Note: the exact output may be browser-dependent)
    }
    }
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    why is this function needed?

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants