Skip to content

Conversation

juancampa
Copy link
Contributor

@juancampa juancampa commented Jan 3, 2025

  • Improvements to search UI by tweaking the CSS
  • Added some term weights to improve ranking
  • Upgraded pagefind

I had to copy the entire Search.astro component from starlight to configure pagefind. It still needs more tweaking but they are working on improving the ranking system so we should keep an eye on this milesone: https://github.com/CloudCannon/pagefind/milestone/6

The excerpts generated by pagefind are not very good which is why the text appear nonsensical in some cases. I'll ask if there's any work planned on this front, if not, it could be something we contribute to the project: https://github.com/CloudCannon/pagefind

Screenshot 2025-01-03 at 16 31 32

Copy link

height bot commented Jan 3, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

Copy link

vercel bot commented Jan 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2025 10:21pm

Copy link
Contributor

@pmillspaugh pmillspaugh left a comment

Choose a reason for hiding this comment

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

Nice! Works well when I tested.

Some design thoughts:

  • I lean toward removing border-radius to make things look more Membrane-y
  • Maybe also the highlighted results should be grayscale?
  • The Starlight icons seem like a mismatch visually

}
}

@media (min-width: 50rem) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the rem breakpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the break point that starlight uses. I copied it from their CSS. I'll add a comment!

Comment on lines 475 to 482
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke-width='0.5' stroke-dasharray='1 1' stroke='currentColor' stroke-linecap='round' viewBox='0 0 16 1000' preserveAspectRatio='xMinYMin slice'%3E%3Cpath d='M8 0v1000m6-988H8'/%3E%3C/svg%3E")
0% 0% / 100% no-repeat;
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke-width='0.5' stroke-dasharray='1 1' stroke='currentColor' stroke-linecap='round' viewBox='0 0 16 1000' preserveAspectRatio='xMinYMin slice'%3E%3Cpath d='M8 0v1000m6-988H8'/%3E%3C/svg%3E")
0% 0% / 100% no-repeat;
}
#starlight__search .pagefind-ui__result-nested:last-child::before {
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke-width='0.5' stroke-dasharray='1 1' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 16 16'%3E%3Cpath d='M8 0v12m6 0H8'/%3E%3C/svg%3E");
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke-width='0.5' stroke-dasharray='1 1' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 16 16'%3E%3Cpath d='M8 0v12m6 0H8'/%3E%3C/svg%3E");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the dashed lines look a bit funky, especially near corners. Just my two cents 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. It makes it look like it's curved or the bottom line is crooked. I was trying to prevent these gaps from happening (from the prod docs):

Screenshot 2025-01-03 at 17 55 56@2x

I just found a way to close those gaps and made them solid again 👍

@media (min-width: 50rem) {
dialog[aria-label="Search"] {
margin: 4rem auto auto;
border-radius: .5rem;
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of 0 border-radius? Feels more Membrane-y 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.

Fixed. This CSS was copied from the original, didn't notice it was there

@juancampa
Copy link
Contributor Author

  • Maybe also the highlighted results should be grayscale?

I tried this initially but it made it look noisy and hard to parse visually

Copy link
Collaborator

@iamseeley iamseeley 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! Left a comment about a potential style change 🤘

width: 90%;
max-width: 40rem;
height: max-content;
min-height: 15rem;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kinda weird they set a min-height here? It looks strange when you open the search dialog and there's so much blank space. I think this looks better:
image

Suggested change
min-height: 15rem;
min-height: 0 !important;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the same thing 👍

Co-authored-by: Thomas Seeley <104278845+iamseeley@users.noreply.github.com>
@juancampa
Copy link
Contributor Author

Thank you guys for the review. Unfortunately, pagefind's search results are not very good at the moment, weights don't do much and excerpts are poorly chosen and poorly formatted, especially around tables. The good news is that they are working on it.

In the meantime I've applied to Algolia's DocSearch which is the other search provided integrated into starlight. If we get approved we might switch to that. It comes with its own UI so hopefully is customizable too.

Screenshot 2025-01-04 at 17 20 02

@juancampa juancampa merged commit ef80b7a into main Jan 4, 2025
2 checks passed
@juancampa juancampa deleted the juan/improve-search branch January 4, 2025 22:27
@juancampa juancampa mentioned this pull request Jan 7, 2025
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