-
Notifications
You must be signed in to change notification settings - Fork 389
Add search functionality using Pagefind #1935
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
Open
doup
wants to merge
80
commits into
bevyengine:main
Choose a base branch
from
doup:pagefind-search
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 36 commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
858edd9
Save pagefind progress
doup fe35ddd
Save search dialog progress
doup 49dc707
Use Tera templates to setup Pagefind indexing
doup d00feaa
Remove Pagefind UI css vars
doup 71a4a9a
Merge branch 'main' into pagefind-search
doup 2a61c50
Add box shadow to search dialog
doup b9e13a2
Clean-up template instancing code
doup 9fd7f54
Remove example API callout from pagefind index
doup 7326285
Add categories and improved styling
doup 521a612
Reset results scroll position after each search
doup 5365af0
Save categories state between page navigations
doup d32a2cb
Add hover highlight to category badges
doup 76d82db
Improve styling
doup 1d94d0d
Move debounce to `tools.js`
doup ade9ce8
Add button to clear filter
doup e2135de
Rename "no-results" CSS class
doup 4371f1e
Improve styling
doup da4f7f9
Improve tip styling
doup 5d3ac75
Tweaks
doup ac36f2c
Tweaks
doup a92a2ae
Refactor HTML and add keyboard navigation
doup 81723d8
Replace HTML entities with actual characters
doup 19222fd
Same page navigation should close the dialog
doup d29755f
Disable page scroll when the search dialog is open
doup 3f891bc
Ignore arrow navigation in docs when the search dialog is open
doup ef660ae
Improve search init error message
doup ee46806
Split CSS BEM components into separate files
doup ec07856
Add margin in small screens
doup 332a9e8
Improve search input & button styling
doup 0a43939
Format
doup 40e4bcc
Remove `no-scroll` class as it doesn't work as intended
doup 46e5b61
Add search icon in header
doup c8b9e1b
Merge commit '9033e706408f6d2c76a7e47498c87f913b684643' into pagefind…
doup 20c53de
Allow focus for close button
doup 18c5b43
Add `button-square` color as CSS var
doup 286359c
Open Search dialog only when `s` is pressed and no input is focused
doup 8fa9c53
Replace `a` with `button`
doup fe51c4d
Use CSS vars in search dialog "components"
doup 287251a
Use `<button>` for search categories
doup 192a77d
Reset "clear filter" element state when opening the dialog
doup ee9dcc4
Add search dialog light-mode colors
doup a00d8b1
Merge commit 'd1bef5ce8b0c0c7ca4900c4f1584de1af426804d' into pagefind…
doup 0052234
Tweak search category border radius
doup 5457f2c
Change "clear search filter" element type to `button` to improve a11y
doup 77c10bd
Tweak light mode colors
doup 7ba082d
Split JS files
doup f76916e
Improve "search is open" detection in docs navigation
doup 4205046
Add search documentation
doup 8507cd0
Delete script
doup c9c9014
Remove results container from tab navigation (doesn't affect children)
doup 66b21be
Remove score filtering
doup bdc83b6
Guard against possible undefined value
doup 06af6cd
No need to initialize
doup 5e8eb54
Update README
doup 811bd4f
Update deploy actions
doup 7ea8205
Override `on` trigger for testing
doup f4cc20f
Disable bevy assets
doup c00e3ac
Enable deploys in any repo
doup ee24b39
Tweak pagefind script
doup 2b40ad1
Tweak style
doup 4cc1816
Tweak search index building
doup b077790
Tweak pagefind action
doup 57c5c81
Revert deploy action test config
doup d46f69d
Tweak action task names
doup 8a8f17c
Revert "Revert deploy action test config"
doup 5604ca6
Upload to pages using GH official actions
doup c1baf86
Set permissions
doup 3a32fb9
Add deploy `permissions/environment`
doup 0efb703
Remove URL
doup 3be1b7a
Change content to check if deploy works
doup f629e2f
Uncomment
doup 0b4268a
Merge commit '6d4cd58fab43c3b75a59ab419af718c37750c294' into pagefind…
doup 21f788d
Fix README pagefind instructions
doup 30d94f6
Remove CSS Relative Color for `search-category`
doup c2195c9
Merge commit '5793a8c2773fa2ace27bcf35b9e9de50412086a5' into pagefind…
doup 0e00697
Remove CSS Relative Colors from `.search-result`
doup 9a5c028
Add `search-result` commit to the list of ones to be reverted
doup 3c2ef91
Merge commit 'ba0a014b2bd7146f2ca3e8e0beb625a3f9fc263a' into pagefind…
doup 1084b18
Merge commit '9a3b61da10d97fca8ae4209dbc2a3c5168ef5aa9' into pagefind…
doup b310c4b
Ups…
doup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
site: public | ||
output_path: static/pagefind | ||
exclude_selectors: | ||
- ".tree-menu" | ||
- ".example__back" | ||
- ".example__github" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
rm -rf public | ||
zola build | ||
./pagefind |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.hidden { | ||
display: none; | ||
display: none !important; | ||
} | ||
|
||
// Visual outline on focused elements, for accessibility | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
("chevron-right", 9), | ||
("github", 24), | ||
("pencil", 19), | ||
("search", 24), | ||
("times", 16), | ||
); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,9 @@ | ||
.main-menu-backdrop { | ||
visibility: hidden; | ||
position: fixed; | ||
top: 0px; | ||
left: 0px; | ||
width: 100%; | ||
height: 100%; | ||
z-index: $z-main-menu-backdrop; | ||
background-color: var(--main-menu-backdrop-color); | ||
cursor: pointer; | ||
opacity: 0; | ||
transition: opacity $duration * 2; | ||
@include backdrop($z-main-menu-backdrop); | ||
} | ||
|
||
@include state-checked("mobile-menu") { | ||
.main-menu-backdrop { | ||
visibility: visible; | ||
opacity: 1; | ||
@include backdrop-visible(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
.search-category { | ||
--search-category-bg-color: #666; | ||
|
||
background-color: transparent; | ||
border: 1px solid #444; | ||
font-size: calc-rem(18px); | ||
padding: 4px 8px; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
user-select: none; | ||
color: #aaa; | ||
|
||
&:hover { | ||
color: #fff; | ||
background-color: rgba(#fff, 0.1); | ||
} | ||
|
||
&--quickstart, | ||
&--book { | ||
--search-category-bg-color: #537134; | ||
} | ||
|
||
&--examples { | ||
--search-category-bg-color: #885d26; | ||
} | ||
|
||
&--migrations { | ||
--search-category-bg-color: #2b5e77; | ||
} | ||
|
||
&--errors { | ||
--search-category-bg-color: #953562; | ||
} | ||
|
||
&--news { | ||
--search-category-bg-color: #2c5580; | ||
} | ||
|
||
&--contribute { | ||
--search-category-bg-color: #78527e; | ||
} | ||
doup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
&--active { | ||
background-color: var(--search-category-bg-color); | ||
color: unquote("hsl(from var(--search-category-bg-color) h s 90)"); | ||
border-color: unquote( | ||
"hsl(from var(--search-category-bg-color) h s calc(l + 10))" | ||
); | ||
|
||
&:hover { | ||
background-color: unquote( | ||
"hsl(from var(--search-category-bg-color) h s calc(l + 4))" | ||
); | ||
} | ||
} | ||
|
||
&--compact { | ||
padding: 2px 4px; | ||
font-size: calc-rem(14px); | ||
cursor: default; | ||
border-radius: 2px; | ||
|
||
&:hover { | ||
background-color: var(--search-category-bg-color); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
.search-result { | ||
$hover-bg: rgba(#fff, 0.04); | ||
|
||
display: block; | ||
background-color: rgba(#000, 0.15); | ||
border-radius: 8px; | ||
padding: 8px; | ||
|
||
&--compact { | ||
text-decoration: none; | ||
|
||
&:focus { | ||
outline: var(--focus-outline); | ||
} | ||
|
||
&:hover { | ||
background-color: $hover-bg; | ||
} | ||
} | ||
|
||
&__header { | ||
display: flex; | ||
align-items: start; | ||
justify-content: space-between; | ||
gap: 8px; | ||
margin-bottom: 4px; | ||
} | ||
|
||
&__title, | ||
&__sub-title { | ||
@include override-anchor { | ||
color: #fff; | ||
} | ||
|
||
display: block; | ||
margin: 0; | ||
font-weight: 500; | ||
word-break: break-word; | ||
} | ||
|
||
&__title { | ||
font-size: calc-rem(24px); | ||
} | ||
|
||
&__sub-item { | ||
border-radius: 8px; | ||
text-decoration: none; | ||
padding: 4px 6px; | ||
position: relative; | ||
|
||
&:focus { | ||
outline: var(--focus-outline); | ||
} | ||
|
||
&:before { | ||
content: "#"; | ||
position: absolute; | ||
top: 4px; | ||
left: -16px; | ||
font-size: calc-rem(20px); | ||
font-weight: 400; | ||
color: #ccc; | ||
} | ||
|
||
&:hover { | ||
background-color: $hover-bg; | ||
} | ||
} | ||
|
||
&__sub-title { | ||
font-size: calc-rem(20px); | ||
font-weight: 400; | ||
} | ||
|
||
&__category { | ||
flex-shrink: 0; | ||
} | ||
|
||
&__sub-results { | ||
display: flex; | ||
flex-direction: column; | ||
margin: 8px 0 0; | ||
padding-left: 24px; | ||
|
||
li { | ||
list-style: disclosure-closed; | ||
} | ||
} | ||
|
||
&__excerpt { | ||
@include text-ellipsis(2); | ||
margin: 4px 0 0; | ||
color: #888; | ||
font-size: calc-rem(16px); | ||
line-height: 1.4; | ||
|
||
mark { | ||
padding: 2px 4px; | ||
background-color: rgba(#fff, 0.1); | ||
color: #ddd; | ||
border-radius: 4px; | ||
font-size: 0.95em; | ||
} | ||
} | ||
|
||
&__more { | ||
font-size: calc-rem(18px); | ||
padding: 16px 28px 8px; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend adding
set -e
to the top of any shell script used as part of ci, so that silent failures don't end up with false positive builds.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for local dev, I'll delete it when the PR is ready. Which makes me remember that I need to document how to setup in local. I'll add few extra tasks in the PR description.