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

Add a search box on the navigation bar #255

Merged
merged 5 commits into from
Jul 1, 2024

Conversation

suprith-hub
Copy link
Contributor

@jviotti review on this PR and can we better the search bar, I feel we should have the search logo 🤔

@suprith-hub suprith-hub changed the title Add fuse search re-open draft PR Add fuse search, re-open draft PR Jun 20, 2024
@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

Oh, this is already looking pretty gorgeous. Great job @Era-cell

Screenshot 2024-06-20 at 9 36 58 PM

assets/main.js Outdated Show resolved Hide resolved
assets/main.js Outdated
const item = document.createElement('li');
item.innerHTML = `<a class="dropdown-item" href="${result.item.permalink}">
${result.item.title}
<span style="font-size: 0.8em; color: #888;">(${result.item.dialect})</span>
Copy link
Member

Choose a reason for hiding this comment

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

Can we use Bootstrap classes here instead of an inline style? I think Bootstrap has the classes you need for what you are doing here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the color I got closer colors, which I can use. For font-size there is sizes for different headings but I couldn't find for small variations

@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

I feel we should have the search logo

Yeah, maybe try an input group with the search icon? https://getbootstrap.com/docs/5.3/forms/input-group/. We already have https://icons.getbootstrap.com available on the site for you to use

@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

We need to some work on how this looks on smaller screens, but I would leave that to the end, once everything else is set in stone

Screenshot 2024-06-20 at 9 40 44 PM

assets/main.js Outdated Show resolved Hide resolved
assets/main.js Outdated Show resolved Hide resolved
assets/main.js Outdated

function executeSearch(searchQuery) {
// TODO
// show(document.querySelector('.search-loading'));
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? Seems pretty instantaneous to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe not right now, I don't know how fast it may work when there are all the dialects present. Maybe i'll just have a statement here to remind it?

assets/main.js Outdated Show resolved Hide resolved
assets/main.js Outdated
}
});

document.addEventListener('click', function(event) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
document.addEventListener('click', function(event) {
document.addEventListener('click', (event) => {

assets/main.js Outdated Show resolved Hide resolved
assets/main.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

Already left some comments but man, this is looking great already. Very, very cool

@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

Now that I look at it, Bootstrap has this pretty search icon embedded in the input. I wonder how they do it

Screenshot 2024-06-20 at 9 46 41 PM

@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

Also, just for design brainstorming purposes, expanding the search bar doesn't look that bad. What do you think?

Screenshot 2024-06-20 at 9 48 28 PM

@suprith-hub
Copy link
Contributor Author

suprith-hub commented Jun 21, 2024

Now that I look at it, Bootstrap has this pretty search icon embedded in the input. I wonder how they do it

Screenshot 2024-06-20 at 9 46 41 PM

For now the input-group worked, the icon inside of the text-box isn't working. I will have a PR.
Normally icon provided as class should work .

@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

@Era-cell Looks really cool already, but note the vocabulary and dialect name are now invisible on light theme:

Screenshot 2024-06-21 at 7 27 02 PM

@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

Check this out:

Screenshot 2024-06-21 at 7 29 47 PM

It works well in both light & dark if you do the following:

diff --git a/assets/main.js b/assets/main.js
index 0465119..f545508 100644
--- a/assets/main.js
+++ b/assets/main.js
@@ -68,8 +68,8 @@ const updateDropdown = (results) => {
       const item = document.createElement('li');
       item.innerHTML = `<a class="dropdown-item" href="${result.item.permalink}">
         ${result.item.title}
-        <span class="text-white-50" style="font-size: 0.8em;">(${result.item.dialect})</span>
-        <span class="text-white" style="font-size: 0.9em;">${result.item.vocabulary}</span>
+        <span class="text-light-50" style="font-size: 0.8em;">(${result.item.dialect})</span>
+        <span class="fw-bold" style="font-size: 0.9em;">${result.item.vocabulary}</span>
       </a>`;
       box.appendChild(item);
     });
@@ -77,7 +77,7 @@ const updateDropdown = (results) => {
     const item = document.createElement('li');
     item.innerHTML = '<a class="dropdown-item disabled" href="#">No matches found</a>';
     box.appendChild(item);
-  }
+  }
 }

assets/main.js Outdated Show resolved Hide resolved
assets/main.js Outdated
}
});

document.addEventListener('click', (event) => {
Copy link
Member

Choose a reason for hiding this comment

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

I think you can get rid of this. I get the idea of closing automatically, but I think we should let HTML do its default job!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the use of this function is user can come out of the search without navigating to other page

temp2.mp4
temp11.mp4

assets/main.js Outdated Show resolved Hide resolved
@jviotti
Copy link
Member

jviotti commented Jun 21, 2024

Finally, this is really cool and I'd like to ship this ASAP. Let's think about mobile support on a different PR, and just add the following to hide the search bar on mobile for the time being:

diff --git a/layouts/partials/navigation.html b/layouts/partials/navigation.html
index e5dec5a..3e9708b 100644
--- a/layouts/partials/navigation.html
+++ b/layouts/partials/navigation.html
@@ -5,7 +5,7 @@
           height="42" width="42" class="me-1">
         <span class="align-middle">JSON Schema Docs</span>
       </a>
-      <div class="position-relative me-3 flex-grow-1">
+      <div class="position-relative me-3 flex-grow-1 d-none d-lg-block">
         <div class="input-group">
           <span class="input-group-text" id="basic-addon1">
             <i class="bi bi-search"></i>

@suprith-hub
Copy link
Contributor Author

Finally, this is really cool and I'd like to ship this ASAP. Let's think about mobile support on a different PR, and just add the following to hide the search bar on mobile for the time being:

diff --git a/layouts/partials/navigation.html b/layouts/partials/navigation.html
index e5dec5a..3e9708b 100644
--- a/layouts/partials/navigation.html
+++ b/layouts/partials/navigation.html
@@ -5,7 +5,7 @@
           height="42" width="42" class="me-1">
         <span class="align-middle">JSON Schema Docs</span>
       </a>
-      <div class="position-relative me-3 flex-grow-1">
+      <div class="position-relative me-3 flex-grow-1 d-none d-lg-block">
         <div class="input-group">
           <span class="input-group-text" id="basic-addon1">
             <i class="bi bi-search"></i>

Done 👍

Copy link
Member

@jviotti jviotti left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks a lot!

@jviotti
Copy link
Member

jviotti commented Jun 30, 2024

@Era-cell Can you resolve the conflict?

@jviotti jviotti changed the title Add fuse search, re-open draft PR Add a search box on the navigation bar Jun 30, 2024
@suprith-hub
Copy link
Contributor Author

I have resolved it 👍

@jviotti
Copy link
Member

jviotti commented Jun 30, 2024

@Era-cell CI seems to be complaining about the JavaScript file:

Error: Error building site: JSBUILD: failed to transform "main.js" (application/javascript): Unexpected end of file

@suprith-hub
Copy link
Contributor Author

Okay, seems good now. The power went off yesterday 😅

@jviotti
Copy link
Member

jviotti commented Jul 1, 2024

Thanks a lot!

@jviotti jviotti merged commit 26f87cf into sourcemeta:main Jul 1, 2024
1 check passed
@suprith-hub
Copy link
Contributor Author

Thanks a lot!

Thank you too, website looks very good 💖

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.

2 participants