Jump to content

Show a custom icon color based on light/dark theme

Recommended Posts

  • 9 months later...
On 3/30/2022 at 2:07 AM, unavolta said:

@tuanphan Also looking to do this for adding a Substack logo the social icons. I have been able to add it in in one color but I want it to shift from white to blue based on light or dark setting. & in mobile popup menu

dark theme: https://www.melinahammer.com/

light theme:  https://www.melinahammer.com/book

pw: melina

Want it as-is (White) here:

1407184594_ScreenShot2022-03-29at12_05_52PM.thumb.png.9ca82826c3969c39b548d5ed1229325c.png

687828364_ScreenShot2022-03-29at12_05_47PM.thumb.png.e576bcc2d47ed12fe4491ea171c1ba7b.png

 

Want it to be blue here:

1906405822_ScreenShot2022-03-29at12_05_41PM.thumb.png.0607a563c0f7c54b6ebe4087f9904678.png

1182463925_ScreenShot2022-03-29at12_05_28PM.thumb.png.0156bcaefc9809b94c05f6361c4b2f81.png

#1. To change it to black on Book Page Header

add this code into Book Page header

<style>
  .header-actions-action a[href*="substack"] {
    filter: invert(1);
    -webkit-filter: invert(1);
}
</style>

#2. To add substack on Mobile Menu Overlay, add this to Design > Custom CSS

header#header a.icon[href*="substack"] svg {
    display: none;
}
header#header a.icon[href*="substack"] {
    background-image: url(https://static1.squarespace.com/static/61e7443d8270c01ce2239916/t/623ba7cba0a6a72aa3882777/1648076747954/substack2.png);
    background-size: 100%;
    background-repeat: no-repeat;
}
body.header--menu-open header#header a.icon[href*="substack"] {
	filter: invert(1);
	-webkit-filter: invert(1);
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
10 hours ago, tuanphan said:

#1. To change it to black on Book Page Header

add this code into Book Page header

<style>
  .header-actions-action a[href*="substack"] {
    filter: invert(1);
    -webkit-filter: invert(1);
}
</style>

#2. To add substack on Mobile Menu Overlay, add this to Design > Custom CSS

header#header a.icon[href*="substack"] svg {
    display: none;
}
header#header a.icon[href*="substack"] {
    background-image: url(https://static1.squarespace.com/static/61e7443d8270c01ce2239916/t/623ba7cba0a6a72aa3882777/1648076747954/substack2.png);
    background-size: 100%;
    background-repeat: no-repeat;
}
body.header--menu-open header#header a.icon[href*="substack"] {
	filter: invert(1);
	-webkit-filter: invert(1);
}

 

@tuanphanThanks! Close - 

Part 1) I got it to work to #15284C on the mobile menu by removing the body.header section and changing the URL to a new .PNG of the #15284C file 

Code:

//substack color on mobile menu only//
@media screen and (max-width:767px) {
header#header a.icon[href*="substack"] svg {
    display: none;
}
header#header a.icon[href*="substack"] {
    background-image: url(https://static1.squarespace.com/static/61e7443d8270c01ce2239916/t/6240b25db51f1159dbbe011b/1648407133383/substack2_blue.png);
    background-size: 100%;
    background-repeat: no-repeat;
  }}

Part 2) but in the header on light mode on certain pages like Book I want it to be the color #15284C, not black. I tried adjusting a few filters but can't get the right color or change the direct URL of the icon like for the mobile menu.

#15284C URL: https://static1.squarespace.com/static/61e7443d8270c01ce2239916/t/6240b25db51f1159dbbe011b/1648407133383/substack2_blue.png

 

Link to comment
  • 2 weeks later...
On 4/1/2022 at 10:53 AM, unavolta said:

@tuanphanThanks! Close - 

Part 1) I got it to work to #15284C on the mobile menu by removing the body.header section and changing the URL to a new .PNG of the #15284C file 

Code:

//substack color on mobile menu only//
@media screen and (max-width:767px) {
header#header a.icon[href*="substack"] svg {
    display: none;
}
header#header a.icon[href*="substack"] {
    background-image: url(https://static1.squarespace.com/static/61e7443d8270c01ce2239916/t/6240b25db51f1159dbbe011b/1648407133383/substack2_blue.png);
    background-size: 100%;
    background-repeat: no-repeat;
  }}

Part 2) but in the header on light mode on certain pages like Book I want it to be the color #15284C, not black. I tried adjusting a few filters but can't get the right color or change the direct URL of the icon like for the mobile menu.

#15284C URL: https://static1.squarespace.com/static/61e7443d8270c01ce2239916/t/6240b25db51f1159dbbe011b/1648407133383/substack2_blue.png

 

@tuanphanI figured it out 🙂

and got it to work in header on the specific pages I wanted with this code in the page header code injection:

<style>
  .header-actions-action a[href*="substack"] {
    background-image: url(https://static1.squarespace.com/static/61e7443d8270c01ce2239916/t/6240b25db51f1159dbbe011b/1648407133383/substack2_blue.png);    
}
</style>

and on the social icon list in a specific block with this code in custom CSS:

div #block-bf044cab69af258d3349 { 
  .sqs-svg-icon--list a:nth-of-type(3){
     background-image: url(https://static1.squarespace.com/static/61e7443d8270c01ce2239916/t/6240b25db51f1159dbbe011b/1648407133383/substack2_blue.png);    
  } }

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.