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

Toggle search button icon between magnifier and X icon depending on search state. #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/javascripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ function toggleClassSearch() {
setTimeout(function () {
document.querySelector('.search-content input').focus();
}, 400);

if (mySearchContent.classList.contains('is--visible'))
document.querySelector('.search-toggle').children[0].children[1].setAttribute('d', 'M 11.839844 0.691406 C 12.738281 -0.226562 14.207031 -0.230469 15.113281 0.679688 C 16.019531 1.589844 16.023438 3.074219 15.121094 3.988281 L 11.164062 8 L 15.125 12.019531 C 16.019531 12.929688 16.007812 14.398438 15.097656 15.308594 C 14.191406 16.214844 12.726562 16.210938 11.835938 15.304688 L 7.898438 11.3125 L 3.957031 15.308594 C 3.054688 16.226562 1.589844 16.230469 0.683594 15.320312 C -0.222656 14.410156 -0.226562 12.925781 0.671875 12.011719 L 4.632812 8 L 0.667969 3.980469 C -0.226562 3.070312 -0.210938 1.601562 0.695312 0.691406 C 1.605469 -0.214844 3.066406 -0.210938 3.960938 0.695312 L 7.894531 4.6875 Z M 11.839844 0.691406')
else
document.querySelector('.search-toggle').children[0].children[1].setAttribute('d', 'M15.5,13.12L13.19,10.8a1.69,1.69,0,0,0-1.28-.55l-0.06-.06A6.5,6.5,0,0,0,5.77,0,6.5,6.5,0,0,0,2.46,11.59a6.47,6.47,0,0,0,7.74.26l0.05,0.05a1.65,1.65,0,0,0,.5,1.24l2.38,2.38A1.68,1.68,0,0,0,15.5,13.12ZM6.4,2A4.41,4.41,0,1,1,2,6.4,4.43,4.43,0,0,1,6.4,2Z" transform="translate(-.01)')
}