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 sort by select-box for searching crate #2297

Merged
merged 3 commits into from
Nov 24, 2023

Conversation

linyihai
Copy link
Contributor

@linyihai linyihai commented Oct 31, 2023

This PR for #2152

The main features are:

  • Add a drop-down selection box to the top right of the search result to support searching by category. This prototype comes from crates-io, so the main drop-down options also come from it.
  • Another improvement is that when the dropdown option is changed, the search will be triggered if there is content in the search box

In the end, I didn't find a good way to test it, so I built some packages locally, changed the drop-down options, and saw how the results returned compared to crates-io.

the finally look is:

image

@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Oct 31, 2023
@Nemo157 Nemo157 linked an issue Oct 31, 2023 that may be closed by this pull request
@Nemo157
Copy link
Member

Nemo157 commented Oct 31, 2023

From the screenshot it looks like a different text color is being used. I'm not sure if the existing CSS has handling for a select in the navbar, it may just need some class applied, or it might need some extra rules added.

@linyihai
Copy link
Contributor Author

image
thanks for you suggestions, I add the same CSS into the select-box, now it looks well.

static/keyboard.js Outdated Show resolved Hide resolved
static/keyboard.js Outdated Show resolved Hide resolved
static/keyboard.js Outdated Show resolved Hide resolved
@syphar syphar added S-waiting-on-author Status: This PR is incomplete or needs to address review comments and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Nov 4, 2023
@GuillaumeGomez
Copy link
Member

Thanks for the update! I'll try to review it by the end of the week.

@GuillaumeGomez
Copy link
Member

So currently it looks like this:

image

With these changes:

diff --git a/templates/style/_vars.scss b/templates/style/_vars.scss
index aa97be9d..f28a0c19 100644
--- a/templates/style/_vars.scss
+++ b/templates/style/_vars.scss
@@ -7,6 +7,7 @@ $font-family-mono: "Source Code Pro", Menlo, Monaco, Consolas, "DejaVu Sans Mono
 
 // Sizes
 $top-navbar-height: 32px; // height of the floating top navbar
+$search-result-right-left-padding: 1em; // Size of the right and left padding for the search results
 
 // Pure compatible media queries
 // usage:
diff --git a/templates/style/style.scss b/templates/style/style.scss
index 0f3d7f92..149a6789 100644
--- a/templates/style/style.scss
+++ b/templates/style/style.scss
@@ -244,6 +244,7 @@ div.landing {
 #search-select-nav {
     display: flex;
     flex-direction: column;
+    padding: 1em $search-result-right-left-padding;
 
     .item-end {
         align-self: flex-end
@@ -282,7 +283,7 @@ div.recent-releases-container {
     .release {
         display: block;
         border-bottom: 1px solid var(--color-border);
-        padding: 0.4em 1em;
+        padding: 0.4em $search-result-right-left-padding;
         color: var(--color-standard);
 
         a {

It now looks like this:

image

Could you apply them please?

@linyihai
Copy link
Contributor Author

So currently it looks like this:

image

With these changes:

diff --git a/templates/style/_vars.scss b/templates/style/_vars.scss
index aa97be9d..f28a0c19 100644
--- a/templates/style/_vars.scss
+++ b/templates/style/_vars.scss
@@ -7,6 +7,7 @@ $font-family-mono: "Source Code Pro", Menlo, Monaco, Consolas, "DejaVu Sans Mono
 
 // Sizes
 $top-navbar-height: 32px; // height of the floating top navbar
+$search-result-right-left-padding: 1em; // Size of the right and left padding for the search results
 
 // Pure compatible media queries
 // usage:
diff --git a/templates/style/style.scss b/templates/style/style.scss
index 0f3d7f92..149a6789 100644
--- a/templates/style/style.scss
+++ b/templates/style/style.scss
@@ -244,6 +244,7 @@ div.landing {
 #search-select-nav {
     display: flex;
     flex-direction: column;
+    padding: 1em $search-result-right-left-padding;
 
     .item-end {
         align-self: flex-end
@@ -282,7 +283,7 @@ div.recent-releases-container {
     .release {
         display: block;
         border-bottom: 1px solid var(--color-border);
-        padding: 0.4em 1em;
+        padding: 0.4em $search-result-right-left-padding;
         color: var(--color-standard);
 
         a {

It now looks like this:

image

Could you apply them please?

No problem.

@GuillaumeGomez
Copy link
Member

Looks good to me, thanks! Let's wait for @Nemo157 to check if it looks good to them as well.

@GuillaumeGomez GuillaumeGomez merged commit aa69512 into rust-lang:master Nov 24, 2023
8 checks passed
@github-actions github-actions bot added S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Nov 24, 2023
@linyihai linyihai deleted the sort-by-search branch November 27, 2023 01:55
@syphar syphar removed the S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it label Nov 29, 2023
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.

Feature Request: sort results by date
4 participants