Created
February 21, 2023 08:08
-
-
Save thetwopct/646e8b627f81961575fa74b55c5ab04d to your computer and use it in GitHub Desktop.
iOS-style Toggle for Tax Toggle for WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Custom styling for Tax Toggle for WooCommerce (iOS Toggle Style) | |
* | |
* https://www.taxtoggle.com?ref=gist | |
* | |
* Created for Tax Toggle v1.3.6 | |
* | |
* PostCSS: v8.4.14, | |
* Autoprefixer: v10.4.7 | |
* Browsers: last 4 version | |
*/ | |
:root { | |
--tax-toggle-text-color: #333333; | |
--tax-toggle-text-size: 13px; | |
--tax-toggle-off-background: #fdfdfd; | |
--tax-toggle-on-background: #4cd863; | |
--tax-toggle-off-knob: #e5e5e5; | |
--tax-toggle-on-knob: #ffffff; | |
--tax-toggle-off-border: #e5e5e5; | |
--tax-toggle-on-border: #ededee; | |
} | |
html .wc-vat-toggle-wrapper { | |
display: -webkit-box; | |
display: -ms-flexbox; | |
display: flex; | |
-webkit-box-align: center; | |
-ms-flex-align: center; | |
align-items: center; | |
gap: 10px; | |
font-size: var(--tax-toggle-text-size); | |
color: var(--tax-toggle-text-color); | |
} | |
html #wcvat-toggle { | |
height: 100%; | |
left: unset; | |
top: unset; | |
z-index: unset; | |
cursor: pointer; | |
position: relative; | |
border: none; | |
border-radius: unset; | |
background-color: transparent; | |
padding: unset; | |
color: unset; | |
display: block; | |
text-align: unset; | |
font-size: unset; | |
border-color: unset; | |
} | |
html #wcvat-toggle:before { | |
background-image: unset; | |
background-size: unset; | |
margin-right: unset; | |
padding-left: unset; | |
background-position: unset; | |
background-repeat: unset; | |
-webkit-transition-property: unset; | |
-o-transition-property: unset; | |
transition-property: unset; | |
} | |
html #wcvat-toggle.on { | |
background: transparent; | |
} | |
html #wcvat-toggle.on:hover { | |
background: transparent; | |
} | |
html #wcvat-toggle.on:before { | |
background-image: unset; | |
background-size: unset; | |
padding-left: 0; | |
} | |
html .knob, | |
html .layer { | |
position: absolute; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
} | |
html .toggle { | |
position: relative; | |
top: 50%; | |
width: 74px; | |
height: 36px; | |
margin-left: auto; | |
margin-right: auto; | |
overflow: hidden; | |
border-radius: 100px; | |
border: 1px solid var(--tax-toggle-off-border); | |
} | |
html .toggle .layer { | |
border-radius: 100px; | |
} | |
html .knob { | |
z-index: 2; | |
} | |
html .knob:before { | |
content: ""; | |
position: absolute; | |
top: 50%; | |
-webkit-transform: translateY(-50%); | |
-ms-transform: translateY(-50%); | |
transform: translateY(-50%); | |
left: 4px; | |
width: 20px; | |
height: 10px; | |
color: #fff; | |
font-size: 10px; | |
font-weight: bold; | |
text-align: center; | |
line-height: 1; | |
padding: 9px 4px; | |
background-color: var(--tax-toggle-off-knob); | |
border-radius: 50%; | |
-webkit-transition: 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15) all; | |
-o-transition: 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15) all; | |
transition: 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15) all; | |
} | |
html .layer { | |
width: 100%; | |
background-color: var(--tax-toggle-off-background); | |
-webkit-transition: 0.3s ease all; | |
-o-transition: 0.3s ease all; | |
transition: 0.3s ease all; | |
z-index: 1; | |
} | |
html .wcvat-toggle-product.on .toggle { | |
border: 1px solid var(--tax-toggle-on-border); | |
} | |
html .wcvat-toggle-product.on .knob:before { | |
left: 42px; | |
background-color: var(--tax-toggle-on-knob); | |
} | |
html .wcvat-toggle-product.on .layer { | |
background-color: var(--tax-toggle-on-background); | |
} | |
html .knob, | |
html .knob:before, | |
html .layer { | |
-webkit-transition: 0.3s ease all; | |
-o-transition: 0.3s ease all; | |
transition: 0.3s ease all; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a modification for Tax Toggle for WooCommerce (see https://www.taxtoggle.com?ref=gist) | |
It creates a iOS-style "toggle" button which can be inserted in your theme showing status of the tax toggle - either inclusive or exclusive or any other wording you wish to use. | |
How to use: | |
1. Go to WP Admin > WooCommerce > Settings > Tax and turn off the floating tax toggle. | |
2. Add the custom CSS to your theme. | |
3. Add the custom Tax Toggle to your theme (i.e. in the header.php file). You can change the wording (Excludes Tax / Includes Tax) to anything you want to describe the on/off tax function. | |
4. You can customise the toggle formatting with the simple CSS variables specified. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment