Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
khleomix committed Jan 16, 2024
1 parent 13138ce commit f3520e7
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

.DS_Store
node_modules
vendor
72 changes: 36 additions & 36 deletions assets/css/blocks/core/button.css
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
/* -- Button -- */

.wp-block-button .wp-block-button__link {
display: inline-flex;
justify-content: center;
align-items: center;
}

.wp-block-button .wp-block-button__link:disabled,
.wp-block-button .wp-block-button__link[disabled] {
cursor: not-allowed;
pointer-events: none;
opacity: 0.15;
}

.wp-block-button .wp-block-button__link {
display: inline-flex;
justify-content: center;
align-items: center;
}

.wp-block-button .wp-block-button__link::after {
background-color: currentcolor;
content: '';
display: inline-block;
height: 1rem;
mask-image: url( '../../../images/icon-circle-right.svg' );
mask-size: contain;
margin-left: 0.5rem;
position: relative;
vertical-align: middle;
width: 1rem;
}

.is-style-minimal.is-style-minimal.wp-block-button .wp-block-button__link,
.is-style-text.is-style-text.wp-block-button .wp-block-button__link {
background-color: transparent;
border: 0.063rem solid transparent;
color: var(--wp--preset--color--primary-500);
padding: 0.438rem 0.938rem;
}

.is-style-outline.is-style-outline.wp-block-button .wp-block-button__link:hover,
.is-style-minimal.is-style-minimal.wp-block-button .wp-block-button__link:hover {
background-color: var(--wp--preset--color--primary-50);
border: 0.063rem solid var(--wp--preset--color--primary-500);
}

.is-style-text.is-style-text.wp-block-button .wp-block-button__link:hover {
color: var(--wp--preset--color--primary-700);
background-color: currentcolor;
content: "";
display: inline-block;
height: 1rem;
mask-image: url(../../../images/icon-circle-right.svg);
mask-size: contain;
margin-left: 0.5rem;
position: relative;
vertical-align: middle;
width: 1rem;
}

.medium.medium.wp-block-button .wp-block-button__link {
Expand All @@ -51,7 +33,7 @@
.large.large.wp-block-button .wp-block-button__link {
padding: 0.75rem 1rem;
border-radius: 0.375rem;
border-size: 0.125rem;
border-width: 0.125rem;
font-size: 1rem;
}

Expand All @@ -63,7 +45,7 @@
.xlarge.xlarge.wp-block-button .wp-block-button__link {
padding: 1rem 1.5rem;
border-radius: 0.375rem;
border-size: 0.125rem;
border-width: 0.125rem;
font-size: 1.125rem;
}

Expand All @@ -72,3 +54,21 @@
width: 1.5rem;
}

.is-style-minimal.is-style-minimal.wp-block-button .wp-block-button__link,
.is-style-text.is-style-text.wp-block-button .wp-block-button__link {
background-color: transparent;
border: 0.063rem solid transparent;
color: var(--wp--preset--color--primary-500);
padding: 0.438rem 0.938rem;
}

.is-style-outline.is-style-outline.wp-block-button .wp-block-button__link:hover,
.is-style-minimal.is-style-minimal.wp-block-button
.wp-block-button__link:hover {
background-color: var(--wp--preset--color--primary-50);
border: 0.063rem solid var(--wp--preset--color--primary-500);
}

.is-style-text.is-style-text.wp-block-button .wp-block-button__link:hover {
color: var(--wp--preset--color--primary-700);
}
5 changes: 3 additions & 2 deletions assets/css/blocks/core/cover.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* -- Cover -- */

.wp-block-cover.is-style-gradient .has-background-dim:not([class*=-background-color]) {
.wp-block-cover.is-style-gradient
.has-background-dim:not([class*="-background-color"]) {
background-color: transparent;
background-image: linear-gradient(to top, rgba(0,0,0,0.6), rgba(0,0,0,1));
background-image: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 1));
opacity: 1;
}
41 changes: 25 additions & 16 deletions assets/css/blocks/core/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,54 @@
padding: var(--wp--custom--spacing--gap);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
.wp-block-navigation__responsive-container.is-menu-open
.wp-block-navigation__responsive-container-content {
padding-top: var(--wp--custom--spacing--gap);
}

.wp-block-navigation__responsive-container-close,
.wp-block-navigation__responsive-container-open {
border: 0.063rem solid currentColor;
border: 0.063rem solid currentcolor;
padding: 0.125rem;
}

/* -- Navigation Submenu -- */

.wp-block-navigation:not(.has-background) .wp-block-navigation__responsive-container.is-menu-open,
.wp-block-navigation:not(.has-background) .wp-block-navigation__submenu-container {
background-color: var(--wp--preset--color--white);
color: var(--wp--preset--color--primary-500);
}

.has-contrast-background-color .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open,
.has-contrast-background-color
.wp-block-navigation
.wp-block-navigation__responsive-container.is-menu-open,
.has-contrast-background-color .wp-block-navigation__submenu-container {
background-color: var(--wp--preset--color--primary-500);
color: var(--wp--preset--color--white);
}

.wp-block-navigation:not(.has-background) .wp-block-navigation__submenu-container {
.has-contrast-background-color .wp-block-navigation__submenu-container {
border-color: var(--wp--preset--color--white);
}

.wp-block-navigation:not(.has-background)
.wp-block-navigation__responsive-container.is-menu-open,
.wp-block-navigation:not(.has-background)
.wp-block-navigation__submenu-container {
background-color: var(--wp--preset--color--white);
color: var(--wp--preset--color--primary-500);
}

.wp-block-navigation:not(.has-background)
.wp-block-navigation__submenu-container {
border-color: var(--wp--preset--color--primary-500);
min-width: 180px !important;
padding: 0.625rem;
}

.has-contrast-background-color .wp-block-navigation__submenu-container {
border-color: var(--wp--preset--color--white);
}

.wp-block-navigation :where(.wp-block-navigation__submenu-container) .wp-block-navigation-item__content {
.wp-block-navigation
:where(.wp-block-navigation__submenu-container)
.wp-block-navigation-item__content {
padding: 0.125rem 0.625rem;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-container {
.wp-block-navigation__responsive-container.is-menu-open
.wp-block-navigation__submenu-container {
padding-left: 0.625rem !important;
padding-right: 0.625rem !important;
padding-top: 0.313rem !important;
Expand Down
12 changes: 6 additions & 6 deletions assets/css/global/forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ textarea {
width: 100%;
}

input:focus,
textarea:focus {
filter: brightness(95%);
outline: none;
}

input[type="checkbox"],
input[type="image"],
input[type="radio"] {
Expand All @@ -36,6 +30,12 @@ textarea {
-webkit-appearance: none;
}

input:focus,
textarea:focus {
filter: brightness(95%);
outline: none;
}

::placeholder {
color: var(--wp--preset--color--primary-500);
font-size: var(--wp--preset--font-size--small);
Expand Down
2 changes: 0 additions & 2 deletions assets/css/global/utility.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
.is-style-hidden-mobile {
display: none !important;
}

}

@media only screen and (max-width: 782px) {
Expand All @@ -75,5 +74,4 @@
.wp-block-columns.is-style-column-reverse {
flex-direction: column-reverse;
}

}
6 changes: 3 additions & 3 deletions assets/css/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* -- Global site styles -- */

@import 'global/global.css';
@import 'global/forms.css';
@import 'global/utility.css';
@import "global/global.css";
@import "global/forms.css";
@import "global/utility.css";
30 changes: 16 additions & 14 deletions assets/js/header.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
// Add the .js-enabled class to the <body> when JavaScript is detected
document.addEventListener('DOMContentLoaded', () => {
document.body.classList.add('js-enabled');
});
document.addEventListener( 'DOMContentLoaded', () => {
document.body.classList.add( 'js-enabled' );
} );

// Cache the header element to avoid re-querying the DOM on each scroll
const powderHeader = document.querySelector(".site-header");
const powderHeader = document.querySelector( '.site-header' );

// Initialize the last scroll top position
let powderLastScrollTop = 0;

// Function to handle the scroll event
function handleScroll() {
if (powderHeader) { // Only proceed if the header exists
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if ( powderHeader ) {
// Only proceed if the header exists
const scrollTop =
window.pageYOffset || document.documentElement.scrollTop;

// Compare the new scroll position with the last scroll position
if (scrollTop > powderLastScrollTop) {
if ( scrollTop > powderLastScrollTop ) {
// If scrolling down, hide the header
powderHeader.style.top = "-100%";
powderHeader.style.top = '-100%';
} else {
// If scrolling up, show the header
powderHeader.style.top = "0";
powderHeader.style.top = '0';
}

// Update the last scroll position
Expand All @@ -32,14 +34,14 @@ function handleScroll() {
let isThrottled = false;
const powderThrottleDuration = 100; // milliseconds

window.addEventListener("scroll", () => {
if (!isThrottled) {
window.addEventListener( 'scroll', () => {
if ( ! isThrottled ) {
handleScroll();
isThrottled = true;

// Set a timeout to un-throttle after a certain duration
setTimeout(() => {
setTimeout( () => {
isThrottled = false;
}, powderThrottleDuration);
}, powderThrottleDuration );
}
});
} );
1 change: 0 additions & 1 deletion assets/js/variations.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Add Block Variations.
* Example:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "webdevstudios/powder",
"name": "webdevstudios/wds-bt",
"type": "wordpress-theme"
}
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Text Domain: powder
Tags: block-patterns, block-styles, custom-colors, custom-logo, custom-menu, e-commerce, editor-style, full-site-editing, one-column, style-variations, translation-ready, wide-blocks
*/

@import './assets/css/index.css';
@import "./assets/css/index.css";
8 changes: 4 additions & 4 deletions theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
"blocks": {
"core/button": {
"variations": {
"outline" : {
"outline": {
"border": {
"color": "var(--wp--preset--color--primary-500)",
"style": "solid",
Expand Down Expand Up @@ -608,7 +608,7 @@
}
},
"variations": {
"plain" : {
"plain": {
"border": {
"style": "none"
},
Expand Down Expand Up @@ -827,12 +827,12 @@
"customTemplates": [
{
"name": "page-blank",
"postTypes": ["page"],
"postTypes": [ "page" ],
"title": "Page: Blank"
},
{
"name": "page-no-title",
"postTypes": ["page"],
"postTypes": [ "page" ],
"title": "Page: No Title"
}
]
Expand Down

0 comments on commit f3520e7

Please sign in to comment.