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

In-page search #60

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

kordwarshuis
Copy link

Adds an "instant search" or "dynamic search" (results while you type). Matches are highlighted. Autoscroll to the first match.

@kordwarshuis
Copy link
Author

@kordwarshuis
Copy link
Author

Hi, could you maybe take a look at this? I made this for the Trust over IP (ToIP) organisation and Henk van Cann. Would be great if it could be integrated.

@csuwildcat
Copy link
Member

Will pull in and test this week.

@kordwarshuis
Copy link
Author

Thanks!

@csuwildcat
Copy link
Member

Just looked at the demo and have a bit of feedback:

  • The search bar in the top header appears to break the layout in mobile, because it causes the header content to extend horizontally. We'd need this to look/render well on mobile before pulling it in.
  • When you add the highlighting of matched string segments to the page, I would prefer if we could do so in a way that does not cause layout shift. I would advise the following:
    • Set the wrapping spans to display: inline-block, position: relative;, and remove all margin/padding that causes layout shift.
    • Use a CSS ::before pseudo element in the span set to position: absolute and z-index it at -1, which will let you style more freely without causing layout shift.
    • You'll need to add position: relative, z-index: 0 to the element to enable those absolutely positioned pseudo elements to have a -1 index and show through the layer.
  • It would be nice to have arrows to jump to the next/previous match

@kordwarshuis
Copy link
Author

Good suggestions, I will implement them.

@kordwarshuis
Copy link
Author

kordwarshuis commented May 20, 2024

  • I think the search bar is responsive now and on smaller screens moves to below. I am not sure if it is ok that it takes extra space on mobile default?
  • I used the “outline” property to avoid lay out shift. If you don't like the behaviour of the fade in and fade out of outline border on active match, I can change it.
  • I added arrows, and also key bindings (right and left arrow keys) for going through search matches.
  • Search input gets focus after 1 sec.

Please let me know if this is ok?

@kordwarshuis
Copy link
Author

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.

None yet

2 participants