The discussion is about replacing the default check icon on the review page with a custom icon. Joart wants to use the api.replaceIcon method, but it replaces all check icons on the forum.
Canapin suggests using JavaScript to check if the current page is the review page and then replace the icon. Joart tries the code but encounters an error due to a missing semicolon.
Canapin corrects the code and points out that the icon change won’t trigger on the first page load and will remain changed on other pages. They also suggest reverting the icon change when the URL isn’t /review.
Don provides a CSS solution that hides the default check icon and adds a custom icon to a ::before pseudo-element. This solution uses a theme component and allows for different icons on light and dark color schemes.
If I use this: api.replaceIcon('check', 'full-circle-icon');
all the checks of the forum will be replaced by the full-circle…
But I don’t want to replace the icon in the other pages.
How can I modify do that? Thank you for your answer
Not 100% sure it would work because I haven’t tried it, but you can try to get the current page with javascript, check if it’s a review page, then change the icon with your line of code.
I believe there was a JS example somewhere on meta using the API to get the current page we’re on, but I couldn’t find it again.
Or maybe you can just return the current URL to check if you’re on /review.
But be aware that onPageChange doesn’t trigger on the first page load. If you open directly yourforum/reviews in your browser, then onPageChange won’t trigger and the icon won’t be replaced.
I don’t know how to trigger the icon change on both the first page load and on a page change though. Maybe there’s an API method for that, but I didn’t find it.
Plus, once the icon is changed, it will remain changed on other pages as you navigate, so you should revert the icon change if the URL isn’t /review.
In short… I think it requires a bit more work to be fully functional. Note that I’m not exactly an expert in Discourse code or javascript. Maybe someone with more knowledge will be able to help further.
edit: the code doesn’t work when you go to /review the first time, I suppose this is because the page is loaded and the icon isn’t dynamically changed. So, we should find another way to do that. Sorry that I can’t help more with this.