facebookincubator / infima

A UI framework that provides websites with the minimal CSS and JS needed to get started with building a modern responsive beautiful website
https://infima.dev
MIT License
401 stars 54 forks source link

Search icon doesn't change color between light/dark mode #287

Open tuckergordon opened 1 year ago

tuckergordon commented 1 year ago

The search icon as defined in --ifm-navbar-search-input-icon is uses currentColor:

--ifm-navbar-search-input-icon: url('data:image/svg+xml;utf8,<svg fill="currentColor" ...

However, this does not have the intended effect because currentColor does not get applied on images rendered using url(). This results in the search icon not changing color when switching between light/dark theme (and makes it hard to customize the color more generally).

Perhaps a more flexible approach would be to use an actual SVG in the element, similar to how Docusarus has implemented it on their website:

image
slorber commented 1 year ago

As far as I know this CSS var is not even used on Docusaurus,

But is only found in Infima search: https://infima.dev/demo/

I'll keep this issue open because we should probably delete it from Infima, it's confusing for Docusaurus users and useless


The only official Docusaurus search icon is from the Algolia search widget lib and using a SVG, not a CSS var.

CleanShot 2023-04-28 at 12 56 10@2x CleanShot 2023-04-28 at 12 57 02@2x

And it adapts to the current theme using a CSS var that we provide:

.DocSearch-Button .DocSearch-Search-Icon {
    --docsearch-text-color: cyan;
    color: var(--docsearch-text-color);
}
CleanShot 2023-04-28 at 13 00 08@2x
tuckergordon commented 1 year ago

I'll keep this issue open because we should probably delete it from Infima, it's confusing for Docusaurus users and useless

Agreed - would be good to remove it entirely and replace the demos with an SVG-based solution.

I ran into this while using the easyops-cn/docusaurus-search-local library, so I will make a issue ticket in that repo and reference this one.