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

Difficulty seeing text on the search bar in dark mode. #40

Open
harutiro opened this issue Feb 17, 2024 · 0 comments
Open

Difficulty seeing text on the search bar in dark mode. #40

harutiro opened this issue Feb 17, 2024 · 0 comments

Comments

@harutiro
Copy link

problem

In my environment, when using dark mode, the text color becomes white and assimilates with the background color.
The demo site also confirmed that when searching in dark mode, the text turns white and is difficult to read.

スクリーンショット 2024-02-18 4 43 45 スクリーンショット 2024-02-18 4 38 58

countermeasure

As a countermeasure, it may be a good idea to add a class for dark mode to the input tag class in "layouts/partials/search.html".
In this case, I used 'dark:bg-slate-800' as it is used in the background color.

{{ if .Site.Params.enableSearch }}
<label class="mb-2 block px-2">
  <span></span>
  <input type="text" placeholder="Search articles" class="searchInput dark:bg-slate-800 bg-white rounded px-2 py-1 w-full border" />
</label>
<script>
  const searchElt = document.querySelector('.searchInput')
  if (searchElt) {
    searchElt.addEventListener('input', evt => {
      const value = evt.target.value || '';

      const articles = document.querySelectorAll('.article')
      if (!value) {
        articles.forEach(article => article.classList.remove('hidden'))
      } else {
        articles.forEach(article => article.classList.add('hidden'))
        Array.from(articles).filter(article => {
          const title = article.querySelector('h3')
          if (!title) return false;

          return title.textContent.toLowerCase().includes(value.toLowerCase())
        }).forEach(article => article.classList.remove('hidden'))
      }
    })
  }
</script>
{{ end }}
スクリーンショット 2024-02-18 4 49 30 スクリーンショット 2024-02-18 4 49 51
legomb added a commit to legomb/digital-garden-hugo-theme that referenced this issue Apr 20, 2024
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

No branches or pull requests

1 participant