From 53d4e904111c8e7d0c6b900c3c5bffc441531c1d Mon Sep 17 00:00:00 2001 From: Shiny Nematoda Date: Sat, 15 Jun 2024 20:16:18 +0000 Subject: [PATCH] [FEAT] folding results for repo search (#4134) closes #3855 unlike #3854, this implementation uses a generic details html tag and a bit of tailwind magic... --- ## Maintainers Note - previously tailwind classes of the form `[-a-zA-Z:0-9_.]` was disabled, however they were enabled since they were required for the `group-open:` classes --- ## Manual Testing 1. Visit the code search results after submitting a valid query for repo (if indexer disabled) or repo, user, explore (if indexer enabled) 2. Verify thst 1. the results are unfloded/open by default 2. the chevron points down when open and right when closed Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4134 Reviewed-by: Earl Warren Reviewed-by: Beowulf Co-authored-by: Shiny Nematoda Co-committed-by: Shiny Nematoda --- release-notes/8.0.0/feat/4134.md | 1 + tailwind.config.js | 18 ++++++++++-- templates/shared/search/code/results.tmpl | 35 +++++++++++++---------- tests/integration/repo_search_test.go | 2 +- 4 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 release-notes/8.0.0/feat/4134.md diff --git a/release-notes/8.0.0/feat/4134.md b/release-notes/8.0.0/feat/4134.md new file mode 100644 index 0000000000..ddef4c0fb7 --- /dev/null +++ b/release-notes/8.0.0/feat/4134.md @@ -0,0 +1 @@ +Code Search results are now displayed in a foldable box diff --git a/tailwind.config.js b/tailwind.config.js index 8f3e8c8251..42962b972b 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -44,8 +44,6 @@ export default { 'backdrop-filter', // we use double-class tw-hidden defined in web_src/css/helpers.css for increased specificity 'hidden', - // unneeded classes - '[-a-zA-Z:0-9_.]', ], theme: { colors: { @@ -100,6 +98,22 @@ export default { }, }, plugins: [ + plugin(({addUtilities}) => { + // base veriables required for tranform utilities + // added as utilities since base is not imported + // note: required when using tailwind's transform classes + addUtilities({ + '.transform-reset': { + '--tw-translate-x': 0, + '--tw-translate-y': 0, + '--tw-rotate': 0, + '--tw-skew-x': 0, + '--tw-skew-y': 0, + '--tw-scale-x': '1', + '--tw-scale-y': '1', + }, + }); + }), plugin(({addUtilities}) => { addUtilities({ // tw-hidden must win all other "display: xxx !important" classes to get the chance to "hide" an element. diff --git a/templates/shared/search/code/results.tmpl b/templates/shared/search/code/results.tmpl index a98a662654..50d4a35c3c 100644 --- a/templates/shared/search/code/results.tmpl +++ b/templates/shared/search/code/results.tmpl @@ -11,26 +11,31 @@ {{template "base/paginate" .}} diff --git a/tests/integration/repo_search_test.go b/tests/integration/repo_search_test.go index fdfd4cebfb..f177c94b87 100644 --- a/tests/integration/repo_search_test.go +++ b/tests/integration/repo_search_test.go @@ -20,7 +20,7 @@ import ( ) func resultFilenames(t testing.TB, doc *HTMLDoc) []string { - filenameSelections := doc.Find(".repository.search").Find(".repo-search-result").Find(".header").Find("span.file") + filenameSelections := doc.Find(".repository.search").Find("details.repo-search-result").Find(".header").Find("span.file") result := make([]string, filenameSelections.Length()) filenameSelections.Each(func(i int, selection *goquery.Selection) { result[i] = selection.Text()