• Resolved nmballa

    (@nmballa)


    I know often plugin will disable pseudo code such as ::before, ::after, and hover::before/::after. I found a workaround for mega-menus-max by using display: block !important; What is a similar solution for fibosearch? Below is a snippet I have been playing with to try to create a border around the exterior when the element is hovered.

    #search-circle::before {
        content: '';
        box-sizing: inherit;
        position: absolute;
        display: block !important;
        border: 2px solid transparent;
        border-radius: 100%;
        top: 0;
        left: 0;
        width: 0;
        height: 0;
    }
    
    #search-circle:hover::before {
        visibility: visible !important;
        display: block !important;
        width: 100%;
        height: 100% !important;
        cursor: pointer;
    }
    
    #search-circle:hover::before {
        visibility: visible !important;
        display: block !important;
        width: 100%;
        height: 100% !important;
        box-shadow: 0 2px 10px rgb(0 0 0 / 25%) !important;
        border-top: 2px solid #78a300 !important;
        border-right: 2px solid #78a300 !important;
        border-bottom: 2px solid #78a300 !important;
        border-left: 2px solid #78a300 !important;
        right: -2px !important;
        top: -2px !important;
        transition:
            border-top 0.20s linear,
            border-right 0.20s linear 0.15s,
            border-bottom 0.20s linear 0.25s,
            border-left 0.20s linear 0.35s;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nmballa

    (@nmballa)

    Also, to clarify, as I realized I am not giving the full picture here. I am applying the #search-circle id via js to the fibosearch icon in my functions.php. What I actually did was create a svg circle that I then placed behind the icon and then append the icon in to the svg circle.

    add_action( 'wp_footer', 'search_icon_append');
    
    function search_icon_append (){
        
    
    ?>
        <script>
        
        document.addEventListener("DOMContentLoaded", function(event) {
            
        var cir2 = document.getElementById("account-circle");
        var cir2_clone = cir2.cloneNode(true);
        var icon = document.getElementsByClassName('dgwt-wcas-ico-magnifier')[0];
        document.getElementsByClassName("site-search")[0].appendChild(cir2_clone);
        cir2_clone.id = "search-circle";
        
        icon.setAttribute("viewBox", "0 0 100 100");
        icon.setAttribute("x", "12.5px");
        icon.setAttribute("y", "12.5px");
    
    	var fragment = document.createDocumentFragment();
    	
    	fragment.appendChild(icon);
    
    	cir2_clone.appendChild(fragment);
    
        });
        
        
        </script>
    
        <?php
        
    }

    I then apply the class to the svg circle when my cart is not triggered. I can scrap the scripts and just use the standard icon but still looking to understand how fibosearch hides the before and after pseudo.

    /*********** Show Overlay On Search Icon Click ************/
    
    add_action( 'wp_footer', 'search_icon_overlay');
    
    function search_icon_overlay (){
        
         ?>
    	
            <script>
    
            document.addEventListener("click", function(event) {
                
                var form = document.getElementsByClassName("dgwt-wcas-search-form")[0];
                var searchBox = document.getElementsByClassName("dgwt-wcas-search-input")[0];
                var prime = document.getElementsByClassName('storefront-primary-navigation')[0];
                
                var cartIcon = document.getElementsByClassName("vi-wcaio-sidebar-cart-icon-wrap")[0];
                var head = document.getElementById("masthead");
                var body = document.getElementsByTagName("body")[0];
    
                var target = event.target.className;
                var overlay = document.getElementsByClassName("vi-wcaio-sidebar-cart-overlay")[0];
                var triggered = false;
                if (overlay.className == "vi-wcaio-sidebar-cart-overlay") {
                    triggered = true;
                }
                else {
                    triggered = false;
                }
                
                if(target == "vi-wcaio-sidebar-cart-overlay" && triggered || target == "search-circle" && triggered) {
                     overlay.className = "vi-wcaio-sidebar-cart-overlay vi-wcaio-disabled";
                     
                    prime.style.display = "block"; 
                    form.style.display = "none"; 
                    cartIcon.classList.remove("site-search-on-click-others");
                    searchIcon.classList.remove('site-search-on-click');
                    head.classList.remove("site-search-on-click-head");
                    body.classList.remove("site-search-lock-scroll");
    
                    
                }
    
                else if (target == "[object SVGAnimatedString]") {
    
                    overlay.className = "vi-wcaio-sidebar-cart-overlay";
                    
                    
                    prime.style.display = "none";
                    form.style.display = "block";
                    cartIcon.classList.add("site-search-on-click-others");
                    searchBox.classList.add("site-search-on-click-box");
                    head.classList.add("site-search-on-click-head");
                    head.classList.add("scrolled");
                    body.classList.add("site-search-lock-scroll");
    
                }
            });
            
            </script>
        <?php
    }
    Thread Starter nmballa

    (@nmballa)

    Here is what I currently have but this obviously makes the border animation quite jumpy. That is why being able to use a before and then left, top, bottom, right would be ideal.

    }

    #search-circle {
    border: 3px solid transparent;

    }

    #search-circle:hover {
    background-color: white;
    border-radius: 100% !important;
    box-sizing: initial !important;
    box-shadow: 0 2px 10px rgb(0 0 0 / 25%) !important;
    cursor: pointer;
    border-top: 3px solid #78a300 !important;
    border-right: 3px solid #78a300 !important;
    border-bottom: 3px solid #78a300 !important;
    border-left: 3px solid #78a300 !important;
    right: -3px !important;
    top: -3px !important;
    transition:
    border-color 0s ease-out 0.5s,
    border-top 0.2s ease-out,
    border-right 0.2s ease-out 0.1s,
    border-bottom 0.2s ease-out 0.225s,
    border-left 0.2s ease-out 0.36s;
    }

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘fibosearch and using ::before in css’ is closed to new replies.