How to hide the advanced search form using CSS and HTML? - html

So I came across with this awesome Search Form. Demo can be found here.
I was trying to figure how to hide the advanced search box as following:
It does not have to be an error but some button so if the user clicked on it, it will expand the advanced search. I can't seem to figure out how to do it.
The simplified code:
<div class="s009">
<form>
<div class="inner-form">
<div class="basic-search">
<div class="input-field">
<b-form-input v-model="search_text" id="search" placeholder="Type Keywords"></b-form-input>
<div class="icon-wrap">
<svg class="svg-inline--fa fa-search fa-w-16" fill="#ccc" aria-hidden="true" data-prefix="fas" data-icon="search" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"></path>
</svg>
</div>
</div>
</div>
<div class="advance-search">
<span class="desc">ADVANCED SEARCH</span>
</div>
</div>
</form>
</div>
Is it possible to suggest some CSS/HTML solution for that?

Give us more information.
If you want just hide the advanced search box use this below code
.advance-search
{
display: none;
}
With jQuery
You can use jquery.this code works if you use add jQuery in your html file
$('document').ready(() => {
$('button').on('click', function () {
$('.advance-search').css('display', 'none')
})
})

This answer should suffice. They use the adjacent sibling selector to create "buttons" out of spans in focus. For your code it would look like this.
<div class="s009">
<form>
<div class="inner-form">
<div class="basic-search">
<div class="input-field">
<b-form-input v-model="search_text" id="search" placeholder="Type Keywords"></b-form-input>
<div class="icon-wrap">
<svg class="svg-inline--fa fa-search fa-w-16" fill="#ccc" aria-hidden="true" data-prefix="fas" data-icon="search" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"></path>
</svg>
</div>
</div>
</div>
**** <span class="show">Show</span>
**** <span class="hide">hide</span>
<div class="advance-search">
<span class="desc">ADVANCED SEARCH</span>
</div>
</div>
</form>
</div>
and the css
span.show:focus ~ .advance-search{ display: none;}
span.hide:focus ~ .advance-search{ display: block;}
addition two
Initially I was trying to do this with only html/css as per your question, however you commented about using Vue. So there are three things to note with vue:
you can store component states in data
you can show and hide elements with v-if
you can change component states on events with v-on
So you want to store data show-advanced: false, then set v-if='show-advanced' on the advance-search. With this advance-search won't display unless show-advance is set to true
<div class="advance-search" v-if='show'>...</div>
<script>
new Vue({
...
data: {
'show': false
}
...
})
</script>
To create a toggle you need a button with the attribute v-on:click="show=!show".
<button v-on:click="show=!show">Toggle</button>
Put that button where ever you want and there you go!
edit
I got a fiddle working, changed show-advanced to show, and I fixed a mistake changing v-bind to v-on

Related

How do I use boot-strap and jQuery to toggle between two icons without buttons?

I want it so that when a user clicks on the heart icon, the heart-icon is hidden and the heart-filled-icon is shown. How do I refer to the other icon within my jQuery function to change it's "display" from "none" to "shown"? I know that this example is really wrong this is just an idea of what I want to do and I can't figure it out.
$('.heart-icon').click(function(){
$('.heart-icon').hide();
$('.heart-filled-icon').show();
});
<svg width="1em" height="1em" viewBox="0 0 16 16" class="heart-icon bi bi-heart" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M8 2.748l-.717-.737C5.6.281 2.514.878 1.4 3.053c-.523 1.023-.641 2.5.314 4.385.92 1.815 2.834 3.989 6.286 6.357 3.452-2.368 5.365-4.542 6.286-6.357.955-1.886.838-3.362.314-4.385C13.486.878 10.4.28 8.717 2.01L8 2.748zM8 15C-7.333 4.868 3.279-3.04 7.824 1.143c.06.055.119.112.176.171a3.12 3.12 0 0 1 .176-.17C12.72-3.042 23.333 4.867 8 15z"/>
</svg>
<svg width="1em" height="1em" style ="display:none;" viewBox="0 0 16 16" class="heart-filled-icon bi bi-heart-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
</svg>
There are many different ways you can do this...
One way is to toggle the Bootstrap display classes. Put either d-none or d-block on the SVG's classes initially.
$('.bi').click(function(){
$('.bi').toggleClass('d-none d-block');
})
https://codeply.com/p/FmVXaxOvoA

svg sprites without output on html

I've recently been introduced to svg sprite and I decided to try it out for the first time on my current project but I'm dead sure there's something missing and I just cant figure it out even after reading some documentations and tutorials.
the sprite
<svg xmlns='http://www.w3.org/2000/svg'>
<defs>
<symbol id="icon-github" viewBox='0 0 24 24'>
<title>Github Icon</title>
<path d='M.184 10.462c-.779 4.906 1.401 10.823 8.123 13.006.12.022.231.032.335.032.782 01.32-.582 1.32-1.3-.097-.523.383-2.642-.92-2.357-2.519.536-2.821-.871-3.205-1.607 1.086 1.394 2.718 1.359 3.949.819.683-.3.326-1.064.65-1.343a.75.75 0 00-.407-1.314c-2.314-.255-4.457-1.001-4.457-4.702 0-2.168 1.505-2.362 1.09-3.269-.015-.033-.333-.754-.045-1.849 1.419.262 2.072 1.28 2.753 1.097 1.687-.46 3.544-.46 5.23 0 .704.189 1.207-.801 2.738-1.103.441 1.654-.473 2.058.103 2.677.632.68.953 1.503.953 2.447 0 5.564-4.717 3.957-5.101 5.22a.748.748 0 00.235.792c.61.513.53 1.83.465 2.889-.067 1.098-.125 2.045.482 2.579.214.19.595.393 1.284.253 6.634-2.131 8.83-8.022 8.063-12.917C21.726-2.856 2.296-2.84.184 10.462zm8.27 10.978l.004.505a11.811 11.811 0 01-1.475-.623c.425.109.913.156 1.471.118zm.37-3.7l-.015.08c-.853.252-1.509.001-1.957-.752l-.001-.002c.68.364 1.381.56 1.973.674zM12 2c11.833 0 14.502 16.267 3.469 19.941-.038-.297-.003-.857.021-1.252.058-.951.126-2.059-.213-2.985 5.088-1.059 5.513-6.646 3.554-9.135.243-.952.145-3.189-.729-3.463-.206-.065-1.305-.304-3.437 1.037a11.657 11.657 0 00-5.361 0c-1.064-.667-3.462-1.752-3.922-.6-.534 1.342-.407 2.427-.248 3.03-1.739 2.204-1.218 5.894.534 7.626-.993-.475-2.361-.637-2.656.314-.323 1.037.912.911 1.679 2.804.073.236.208.513.415.788C-1.705 14.54 1.581 2 12 2z'></path>
</symbol>
and the HTML:
<div class="container__footer">
<a class="container__button" href="https://github.com/" target="_blank">
<svg class="container__icon">
<use xlink:href="../_src/sprites/defs.svg#icon-github"></use>
</svg>
</a>
</div>
Any possible mistake I might be making?

css selector for shadow-root(closed), python 3

I want to extract next page url from the following html using css selector for scrapy spider.
<button id="omni-next-click" name="searchnextclick" class="btn btn__blue btn__rounded" aria-label="next" data-reactid="971" omnivalue="1">
<span class="icon icon__arrow-right" data-reactid="972">
<svg aria-hidden="true" data-reactid="973">
<use xlink:href="/images/adaptive/livestyleguide/walgreens.com/v3.0/themes/images/icons/symbol-defs.svg#icon__arrow-right" data-reactid="974">
#shadow-root (closed)
<svg id="icon__arrow-right" viewBox="0 0 32 32">
<title>icon__arrow-right</title>
<path d="M13.312 21.952c-0.144 0-0.288-0.064-0.4-0.176-0.224-0.224-0.224-0.592 0-0.816l4.976-4.976-4.976-4.96c-0.224-0.224-0.224-0.592 0-0.816s0.592-0.224 0.816 0l5.376 5.376c0.224 0.224 0.224 0.592 0 0.816l-5.376 5.376c-0.128 0.112-0.272 0.176-0.416 0.176z">
</path>
</svg>
</use>
</svg>
</span>
</button>
I am new to scraping. Please help me through it. How can I find css so that I can crawl through all the available pages?

Follow labels in HTML using scrapy

I am trying to understand how scrapy works when I want to extract something from a web page
So I am using the this page to practice https://banco.santander.cl/beneficios?segmento=s-personas
Now I want to get this URLs:
https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=shopping
https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=sabores
https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=decoracion
https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=salud-y-belleza
https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=panoramas
https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=otros
This would be where they are in the HTML code:
<!-- ==================================== HEADER BENEFICIOS ======================================================== -->
<div class="transition navFixed">
<div id="webviewHeaderBeneficios" class="headerBeneficios">
<div class="container">
<div class="row" style="position: relative;">
<i class="fa fa-angle-right" aria-hidden="true"></i>
<div class="col-xs-12 col-sm-12 col-md-8 beneficiosNav">
<ul class="nav nav-pills nav-justified">
<li role="presentation" class=""><span><svg width="41" height="36" viewBox="0 0 41 36" xmlns="http://www.w3.org/2000/svg"><title>41x36</title><g fill="" fill-rule="evenodd"><path d="M31.46 12.3V6.9c0-1-.8-1.8-1.78-1.8s-1.77.8-1.77 1.8v1.86l-3.5-3.5c-1.72-1.72-4.72-1.72-6.45 0L6.2 17.02c-.68.7-.68 1.83 0 2.52.7.7 1.83.7 2.52 0L20.46 7.78c.4-.38 1.06-.38 1.44 0l11.74 11.74c.35.35.8.52 1.26.52.45 0 .9-.17 1.26-.52.7-.7.7-1.82 0-2.5l-4.7-4.7z"/><path d="M20.4 11.12L10.1 21.45c-.16.16-.25.38-.25.6v7.54c0 1.76 1.43 3.2 3.2 3.2h5.1v-7.93h5.78v7.92h5.13c1.76 0 3.2-1.44 3.2-3.2v-7.54c0-.23-.1-.45-.26-.6L21.64 11.1c-.34-.34-.9-.34-1.23 0z"/></g></svg><br><p>Inicio</p></span></li>
<li role="presentation" class=""><span><svg width="41" height="36" viewBox="0 0 41 36" xmlns="http://www.w3.org/2000/svg"><title>41x36</title><g fill="" fill-rule="evenodd"><path d="M26 12.76v-3.5C26 5.82 23.4 3 20.2 3c-3.2 0-5.82 2.8-5.82 6.27v3.5c0 .42.32.77.72.77.4 0 .73-.35.73-.78v-3.5c0-2.6 1.96-4.7 4.36-4.7 2.4 0 4.36 2.1 4.36 4.7v3.5c0 .43.32.78.72.78.4 0 .72-.35.72-.78"/><path d="M29.83 10.88c-.04-1-.83-1.16-.83-1.16h-1.62v2.1l-.02 1.02c0 1.18-.95 2.13-2.13 2.13s-2.13-.95-2.13-2.13c0-.37.08-1.02.08-1.02v-2.1h-5.95l-.03 2.1s.04.65.04 1.02c0 1.18-.95 2.13-2.13 2.13-1.16 0-2.12-.95-2.12-2.13 0-.37.03-1.02.03-1.02v-2.1h-1.26s-.98 0-1.17.98C10.4 11.57 9 29.7 9 30.2c0 1.8 1.94 1.92 1.94 1.92s17.77.12 18.45 0c.66-.12 1.9-.98 1.8-2.52-.4-5.46-1.34-17.94-1.37-18.72z"/></g></svg><br><p>Shopping</p></span></li>
<li role="presentation" class=""><span><svg width="41" height="36" viewBox="0 0 41 36" xmlns="http://www.w3.org/2000/svg"><title>41x36</title><g fill="" fill-rule="evenodd"><path d="M34.97 5.65c0-1-.34-1.82-1-2.47-.22-.22-.57-.24-.82-.05-.1.1-2.14 2.1-25.95 25.73-.7.7-.7 1.87 0 2.57.35.35.8.54 1.3.54s.95-.2 1.3-.53l7.76-7.7c3-2.98 4.3-3.4 5-3.44 1.35-.1 2.5-.6 3.36-1.44 3.9-3.86 9.06-9.42 9.05-13.2zM10.97 13.86c.84.82 1.98 1.3 3.3 1.4.72.05 1.6.5 2.74 1.4.13.08.26.12.4.12.15 0 .3-.06.43-.18l1.95-1.93c.2-.22.23-.56.04-.8-1.27-1.6-1.42-2.43-1.4-2.9 0-1.08-.45-2.15-1.3-2.98l-.15-.15-5.5-4.6c-.26-.23-.64-.2-.86.06-.2.26-.17.64.08.86l5 4.2-1.7 1.66L8.94 5c-.24-.24-.62-.24-.86 0-.24.23-.24.62 0 .85l5.06 5.02-1.7 1.7L7.1 8.03c-.22-.24-.6-.25-.85-.02-.25.24-.26.62-.03.87l4.74 4.98zM34.83 28.96l-8.4-8.32c-.2-.2-.5-.24-.75-.1-.67.42-1.45.7-2.3.85-.23.03-.42.2-.48.4-.07.22-.02.46.15.62l9.18 9.1c.35.35.8.54 1.3.54s.95-.2 1.3-.53c.34-.34.53-.8.53-1.28 0-.5-.2-.94-.53-1.3z"/></g></svg><br><p>Sabores</p></span></li>
<li role="presentation" class=""><span><svg width="41" height="36" viewBox="0 0 41 36" xmlns="http://www.w3.org/2000/svg"><title>41x36</title><path d="M9.05 19.38l3.78-15.1c.2-.74.86-1.28 1.6-1.28h11.2c.77 0 1.42.52 1.6 1.27l3.8 15.1c.25 1.07-.55 2.08-1.63 2.08h-8.2V26c0 2.23 1.58 4.1 3.67 4.52.56.1.95.62.95 1.2 0 .65-.54 1.2-1.2 1.2h-9.07c-.67 0-1.2-.55-1.2-1.2 0-.58.38-1.07.94-1.2 2.08-.43 3.63-2.3 3.63-4.5v-4.57h-8.2c-1.14 0-1.94-1-1.68-2.07" fill="" fill-rule="evenodd"/></svg><br><p>Decoración</p></span></li>
<li role="presentation" class=""><span><svg width="41" height="36" viewBox="0 0 41 36" xmlns="http://www.w3.org/2000/svg"><title>41x36</title><g fill="" fill-rule="evenodd"><path d="M18.3 10.9V7.8h-6.97v3.1c-1.92.33-3.35 1.07-4.22 2.22-.9 1.17-1.2 2.72-.95 4.62 1.7 12.44 3 13.92 3.4 14.4 1.07 1.23 3.33 1.42 4.62 1.42h1.3c1.28 0 3.55-.2 4.6-1.42.43-.48 1.7-1.96 3.4-14.4.27-1.9-.05-3.45-.94-4.62-.88-1.15-2.3-1.9-4.22-2.22zm3.48 6.6c-1.48 10.76-2.6 13.03-3 13.5-.43.5-1.73.82-3.32.82h-1.3c-1.57 0-2.87-.32-3.3-.82-.4-.47-1.52-2.74-3-13.5-.2-1.42 0-2.54.6-3.32.6-.78 1.67-1.3 3.16-1.57.83-.14 1.43-.86 1.43-1.7V9.55h3.53v1.35c0 .84.6 1.56 1.43 1.7 1.5.27 2.56.8 3.17 1.58.6.78.8 1.9.6 3.32z"/><path d="M15.15 14.04h-.66c-1.74 0-5.5.24-4.97 4.7.6 4.9 1.35 9.56 2.15 10.6.6.8 2.04.9 2.75.9h.77c.72 0 2.16-.1 2.75-.9.8-1.04 1.57-5.7 2.16-10.6.55-4.46-3.22-4.7-4.95-4.7zM33.1 16.3h-1.2V8.44c.73-3.93.8-3.95.8-4.46 0-.54-.42-.97-.95-.97-.23 0-.44.1-.6.23-.17-.14-.4-.23-.62-.23-.23 0-.44.1-.6.23-.18-.14-.4-.23-.62-.23-.52 0-.95.43-.95.97 0 .5.08.53.8 4.45v7.9h-1.18c-.63 0-1.14.5-1.14 1.14V32.4c0 .65.5 1.16 1.14 1.16h5.12c.62 0 1.13-.5 1.13-1.15V17.47c0-.63-.5-1.15-1.14-1.15z"/></g></svg><br><p>Salud y Belleza</p></span></li>
<li role="presentation" class=""><span><svg width="41" height="36" viewBox="0 0 41 36" xmlns="http://www.w3.org/2000/svg"><title>41x36</title><path d="M38.2 14.54L36.53 12l-.24.17c-1.42.87-3.32.44-4.23-.96-.9-1.4-.5-3.23.93-4.1l.26-.14-1.65-2.53c-.47-.73-1.46-.95-2.2-.5l-6.96 4.25c.57.13 1 .62 1 1.23 0 .7-.6 1.26-1.3 1.25-.7 0-1.24-.58-1.24-1.28 0-.1.04-.2.07-.3l-17.5 10.7c-.76.47-.98 1.43-.5 2.16l1.66 2.55c.1-.1.23-.18.35-.26 1.43-.87 3.32-.44 4.23.96.92 1.4.5 3.24-.92 4.1-.12.08-.26.15-.4.2l1.67 2.55c.48.73 1.47.96 2.2.5L29.33 21.8c-.4-.2-.7-.63-.7-1.13 0-.7.6-1.26 1.3-1.25.68 0 1.23.57 1.23 1.27l6.55-4.02c.75-.45.97-1.4.5-2.14m-12.84-2.3c0 .7-.58 1.25-1.28 1.24-.7 0-1.25-.6-1.25-1.28 0-.7.6-1.26 1.3-1.25.68 0 1.24.58 1.23 1.28m1.93 2.82c0 .7-.6 1.26-1.3 1.25-.7 0-1.25-.58-1.24-1.28 0-.7.6-1.26 1.3-1.25.68 0 1.24.58 1.23 1.28m1.92 2.83c0 .7-.58 1.25-1.28 1.25-.7 0-1.26-.6-1.25-1.3 0-.68.58-1.24 1.28-1.23.7 0 1.25.58 1.24 1.28" fill="" fill-rule="evenodd"/></svg><br><p>Panoramas</p></span></li>
<li role="presentation" class=""><span><svg width="41" height="36" viewBox="0 0 41 36" xmlns="http://www.w3.org/2000/svg"><title>41x36</title><path d="M33.48 10.4c-.2-.33-.63-.44-1-.26l-1.45.78c-.36.18-.48.57-.28.9.12.2.4.3.63.3.12 0 .24-.03.36-.06l1.46-.8c.36-.16.48-.55.28-.87zm-6.9 10.7c.97-1.33 1.85-3 1.85-5.1 0-2.1-.94-4-2.42-5.4-1.47-1.4-3.5-2.25-5.6-2.25h-.2c-2.12 0-4.14.86-5.62 2.25-1.48 1.4-2.42 3.3-2.42 5.4 0 2.1.88 3.77 1.85 5.1.97 1.38 2 2.27 2.32 3.25.2.76.22 1.34.3 1.65.1.3 0 .25.4.42.34.12 1.85.23 3.27.22 1.42 0 2.93-.1 3.28-.22.38-.17.3-.13.4-.42.07-.3.07-.9.3-1.65.3-.98 1.34-1.87 2.3-3.24zm1.6-14.84c.2-.32.1-.7-.26-.9-.36-.17-.8-.06-1 .26l-.86 1.32c-.2.32-.08.7.28.88.1.04.23.08.35.08.23 0 .5-.1.62-.32l.87-1.32zM21 5.73V4.2c0-.35-.3-.64-.7-.64-.4 0-.72.3-.72.64v1.53c-.04.35.28.64.7.64.4 0 .72-.28.72-.64zm-6.47 1.2l-.87-1.3c-.2-.33-.63-.44-1-.26-.34.18-.46.57-.26.9l.87 1.3c.1.22.4.33.63.33.12 0 .24-.04.35-.07.36-.18.48-.57.28-.9zm-4.7 4.88c.2-.3.08-.7-.27-.88l-1.47-.78c-.36-.18-.8-.07-1 .25-.2.3-.07.7.28.88l1.47.78c.1.07.23.07.35.07.24 0 .5-.1.63-.32zm6.8 16.83c0 .37.32.67.7.67h5.94c.37 0 .67-.3.67-.67 0-.37-.3-.67-.67-.67h-5.95c-.37 0-.68.3-.68.67zm0 2.82c0 .38.32.67.7.67h2.15c.13 0 .22.06.25.1.14.13.44.23.8.23.32 0 .6-.1.75-.22.04-.03.13-.1.28-.1h1.7c.38 0 .68-.3.68-.68 0-.37-.3-.67-.67-.67h-5.95c-.37 0-.68.3-.68.67z" fill="" fill-rule="evenodd"/></svg><br><p>Otros</p></span></li>
</ul>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 inputSearch" ng-class="mapClass" style="position: relative;">
<div class="searchIcon" ng-hide="search.length > 0">
<i class="fa fa-search" aria-hidden="true"></i>
</div>
<div class="searchIcon" ng-show="search.length > 0">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
<input class="ev-pers-search" type="text" ng-model="search" ng-model-options="{ debounce: 450 }" ng-change="searchChanged(search);" placeholder="Buscar restaurantes, cafés..." maxlength="35">
</div>
</div>
</div>
</div>
The URLs I want are under the label a, under li, under ul, and so on
As I understood, If I run response.css("ul li a::attr(href)") I should get the URLs under these labels, but what I get it´s a big list of URLs, and it doesn´t have the URLs I want
So what I am trying to understand it´s what I am actually getting when I use response.css("ul li a::attr(href)"), what is scrapy understanding?, and what would be the proper way to get what I want
The reason you got all those other links is because the footer has the same structure (links inside lists), so your initial selector will find those too.
You need to use a more specific selector. Note that the links you want are inside a div with the class beneficiosNav. This will get you all the links in that section:
response.css(".beneficiosNav ul li a::attr(href)")
Edit: Here is the output I get when opening it with scrapy shell:
scrapy shell "https://banco.santander.cl/beneficios?segmento=s-personas"
>>> response.css(".beneficiosNav ul li a::attr(href)").getall()
And the result of that:
['https://banco.santander.cl/beneficios',
'https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=shopping',
'https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=sabores',
'https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=decoracion',
'https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=salud-y-belleza',
'https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=panoramas',
'https://banco.santander.cl/beneficios/todos?segmento=s-personas&categoria=otros']

FA5 Toggle Icon on Collapse

I am in the process of transitioning from FA4 to FA5 and and some of my old code is no longer working.
I was previously using the below code to transition from a down arrow to a right arrow when the Bootstrap4 Collapse component was triggered. Now that I am using the SVG-JS FA5, it is no longer able to change the icon. I appreciate that the icon codes have changed, but this doesn't make a difference in this case.
<a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<i class="fa" style="margin-right:15px"></i>Orders <span class="badge badge-light">(9)</span>
</a>
......
[data-toggle="collapse"] i:before{
content: "\f078";
}
[data-toggle="collapse"].collapsed i:before{
content: "\f054";
}
Any ideas how I can easily change the FA5 icon automatically when the collapse component is triggered? I could brute force it with JQuery but it would be ugly, and I presume a better method is available.
Thanks
Stephen
In Fa5 there are some considerable changes, as the icons are actually swapped out for svgs you have to manipulate the dom to make your changes that you are looking for. (Not as convenient as your css classes). So in this instance Bootstrap provides methods that trigger when a menu is triggered:
If you piggy back on the event you can trigger your class change (the class change must be on the svg element)
$('a[data-toggle]').on('show.bs.collapse', '#my-main-menu-name', function(){
//this is the anchor tag you triggered
$(this).find('svg[data-fa-i2svg]')
.toggleClass('fa-angle-down')
.toggleClass('fa-angle-right');
})
Fa5 replaces the traditional icon tag with the svg tag:
<svg class="svg-inline--fa fa-thumbs-up fa-w-16" aria-hidden="true" data-prefix="far" data-icon="thumbs-up" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M466.27 286.69C475.04 271.84 480 256 480 236.85c0-44.015-37.218-85.58-85.82-85.58H357.7c4.92-12.81 8.85-28.13 8.85-46.54C366.55 31.936 328.86 0 271.28 0c-61.607 0-58.093 94.933-71.76 108.6-22.747 22.747-49.615 66.447-68.76 83.4H32c-17.673 0-32 14.327-32 32v240c0 17.673 14.327 32 32 32h64c14.893 0 27.408-10.174 30.978-23.95 44.509 1.001 75.06 39.94 177.802 39.94 7.22 0 15.22.01 22.22.01 77.117 0 111.986-39.423 112.94-95.33 13.319-18.425 20.299-43.122 17.34-66.99 9.854-18.452 13.664-40.343 8.99-62.99zm-61.75 53.83c12.56 21.13 1.26 49.41-13.94 57.57 7.7 48.78-17.608 65.9-53.12 65.9h-37.82c-71.639 0-118.029-37.82-171.64-37.82V240h10.92c28.36 0 67.98-70.89 94.54-97.46 28.36-28.36 18.91-75.63 37.82-94.54 47.27 0 47.27 32.98 47.27 56.73 0 39.17-28.36 56.72-28.36 94.54h103.99c21.11 0 37.73 18.91 37.82 37.82.09 18.9-12.82 37.81-22.27 37.81 13.489 14.555 16.371 45.236-5.21 65.62zM88 432c0 13.255-10.745 24-24 24s-24-10.745-24-24 10.745-24 24-24 24 10.745 24 24z"></path></svg>
<!-- <i class="far fa-thumbs-up"></i> -->
IF you would like to still keep the icon tag you can set the option in a script tag in the header before you load the font awesome library
<script>
FontAwesomeConfig = { autoReplaceSvg: 'nest' }
</script>
Output:
<i class="" data-fa-i2svg="">
<svg class="svg-inline--fa fa-thumbs-down fa-w-16" aria-hidden="true" data-prefix="fas" data-icon="thumbs-down" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M0 56v240c0 13.255 10.745 24 24 24h80c13.255 0 24-10.745 24-24V56c0-13.255-10.745-24-24-24H24C10.745 32 0 42.745 0 56zm40 200c0-13.255 10.745-24 24-24s24 10.745 24 24-10.745 24-24 24-24-10.745-24-24zm272 256c-20.183 0-29.485-39.293-33.931-57.795-5.206-21.666-10.589-44.07-25.393-58.902-32.469-32.524-49.503-73.967-89.117-113.111a11.98 11.98 0 0 1-3.558-8.521V59.901c0-6.541 5.243-11.878 11.783-11.998 15.831-.29 36.694-9.079 52.651-16.178C256.189 17.598 295.709.017 343.995 0h2.844c42.777 0 93.363.413 113.774 29.737 8.392 12.057 10.446 27.034 6.148 44.632 16.312 17.053 25.063 48.863 16.382 74.757 17.544 23.432 19.143 56.132 9.308 79.469l.11.11c11.893 11.949 19.523 31.259 19.439 49.197-.156 30.352-26.157 58.098-59.553 58.098H350.723C358.03 364.34 384 388.132 384 430.548 384 504 336 512 312 512z"></path></svg>
</i>
My selector is slightly different than what they recommend in the docs as it specifically locates the svg with data attribute data-fa-i2svg because if you choose to render the icon tag still the data attribute is also on the icon tag and will not trigger an icon update.
Resources:
Bootstrap Collapse
Jquery on method
font awesome changing icons : scroll up a little on this link after you get there, there wasn't a link for the changing icons but this link is the next section.