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

Use icons instead of words for search result types #10661

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

Conversation

zyphlar
Copy link
Contributor

@zyphlar zyphlar commented Feb 17, 2024

The default external search behavior outputs words like

  1. object MyInterface(int foo)

for each search result, however for any sizable project this gets visually very cluttered while adding relatively little understanding. Iconography is probably a better way of helping people skim for what they want.

This PR is a work in progress and feedback/changes/rewrites welcome, but I think it would be valuable for everyone. The use of Google Fonts is optional, any similar symbol would be just as useful, I just wanted to minimize the number of asset files to worry about while maximizing the number of available free icons at my disposal.

Here's what the PR looks like:

Stock, with some css tweaks:

  .material-symbols-outlined {
    font-size: 1em;
  }
  .searchresult .material-symbols-outlined {
    margin-left: 0.5em;
    vertical-align: middle;
  }

Screenshot 2024-02-17 002551

Or with doxygen-awesome-css in dark mode:

  .material-symbols-outlined {
    font-size: 1em;
  }
  .searchresult .material-symbols-outlined {
    margin-left: 0.5em;
    vertical-align: bottom;
  }

Screenshot 2024-02-17 002631

Copy link

sonarcloud bot commented Feb 17, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
81.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@albert-github
Copy link
Collaborator

I'm not sure whether a reference to the google fonts is a good choice (but you already wrote: The use of Google Fonts is optional, any similar symbol would be just as useful, I just wanted to minimize the number of asset files to worry about while maximizing the number of available free icons at my disposal.):

  • potential licensing / copyright issues
  • need for an internet connection, one could have a local server running to do tests etc. or be inside a closed network that has no connection to the outside world.

I think it would be better to use a local set of icons, which would also give the possibility (through redefinition / settings) to use ones own preferred icons.

Furthermore it might be better to have the icon before the text as now it is a bit "ragged".

Note: as you mention it is still work in progress maybe an idea to make this more clear by setting the PR into WIP mode (right hand side of the PR page).:
image

src/htmlgen.cpp Outdated
@@ -420,6 420,8 @@ static QCString substituteHtmlKeywords(const QCString &str,
if (!serverBasedSearch)
{
searchCssJs = "<script type=\"text/javascript\" src=\"$relpath^search/searchdata.js\"></script>\n";
} else {
searchCssJs = "<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Material Symbols Outlined:opsz,wght,FILL,GRAD@24,400,0,0\" />";
Copy link
Owner

Choose a reason for hiding this comment

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

I don't really like the external dependency. May break in the future and prevents off-line browsing. Better to bundle the set of icons with doxygen.


icon = "asterisk";

if (item.type == "dir")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggest to use a map instead of if..else if..else if, i.e.

const myMap = {
    "key 1" : "value 1", 
    "key 2" : "value 2", 
    ...
    "key n" : "value n"
};

@zyphlar
Copy link
Contributor Author

zyphlar commented Feb 17, 2024

Thanks for the feedback! All good points. It may be possible to bundle a WebFont with appropriate licensing to reduce the internet dependency.

As for putting the icons on the left vs the right, I started out on the left but it visually clashed with the numbering, as if there were two bullets. To me the right hand side sort of has a "external link information, here's what you'll get if you click" feel, kinda like Google's "cached" or other link metadata. I don't have a strong opinion though, anyone with a good sense for design is welcome to improve. I wonder if the numbered bullets are even that important? Or maybe the icons float to the left of the number like a pre-bullet?

@zyphlar zyphlar marked this pull request as draft February 17, 2024 21:17
@albert-github
Copy link
Collaborator

As for putting the icons on the left vs the right, I started out on the left but it visually clashed with the numbering, as if there were two bullets. ...

I'm not getting this, how does this clash? I was thinking something like: <number> <icon> <text>
Maybe you could shown an image of the "left side problem"

@doxygen
Copy link
Owner

doxygen commented Feb 18, 2024

As for putting the icons on the left vs the right, I started out on the left but it visually clashed with the numbering, as if there were two bullets. ...

I'm not getting this, how does this clash? I was thinking something like: <number> <icon> <text> Maybe you could shown an image of the "left side problem"

The number also doesn't add that much, so the icon could also serve as the "bullet" instead of a number.

@zyphlar
Copy link
Contributor Author

zyphlar commented May 18, 2024

@albert-github @doxygen I finally got around to working on this again, here's what it looks like with the "left hand side number clash problem" and with no numbers, just icons. I think no numbers just icons looks best, personally, though I wonder if people may prefer to have the option. To get rid of the external dependency without a whole bunch of SVG wrangling and file copying and duplication between light and dark and relative path nonsense, I checked out the Google Font license and copied the font file and its license into the repo. If we want to try and find two dozen other icons and not use Google at all that's OK but webfont technology is pretty slick, <span class="material-symbols-outlined">icon_name</span> generates a day or night colored icon with zero javascript, and it's Apache licensed.

Left hand side icon with numbers:

Screenshot from 2024-05-17 20-31-03

No numbers just icons:

Screenshot from 2024-05-17 20-32-14

Stock (no awesome-css):

Screenshot from 2024-05-17 22-21-40

I also print the result type in the title attribute so that arbitrary icons may be less confusing:

Screenshot from 2024-05-17 20-39-00

Please see the updated PR, depending on your decisions I think after cursory review this is pretty good to go!

@zyphlar zyphlar marked this pull request as ready for review May 18, 2024 05:23
@zyphlar zyphlar force-pushed the custom_search_iconography branch from 5f5d6bd to baa2b3e Compare May 18, 2024 07:29
@zyphlar
Copy link
Contributor Author

zyphlar commented May 18, 2024

Also fun fact, this woff file contains a few instances of the bytes 0x0d0a which means that git may interpret it as text and try to replace it with 0x0a ... in other words, turn \r\n into \n in a binary file.

Anyway I think I fixed that issue lol :) you can see what files git has mistakenly interpreted as text by running git ls-files --eol | head

@zyphlar
Copy link
Contributor Author

zyphlar commented Jun 24, 2024

@albert-github this should be ready if it looks good to you

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

3 participants