diff --git a/README.md b/README.md index 3579e8765..a3bbd3e48 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,12 @@ Crio is a WordPress SuperTheme that allows front-end designers, developers and o ## Changelog ## +### 2.20.0 ### +* Enhancement: Improve Color Palettes by using color variables instead of SCSS compilation during runtime [#50](https://github.com/BoldGrid/crio/issues/50) +* New Feature: Add notice to Design > Footer > Colors to help users [#48](https://github.com/BoldGrid/crio/issues/48) +* New Feature: If I add a logo but my header isn't setup to show it, show a warning [#49](https://github.com/BoldGrid/crio/issues/49) +* Accessibility: Hidden Tagline = Empty Heading Tag = Bad for Accessibility [#52](https://github.com/BoldGrid/crio/issues/52) + ### 2.19.2 ### * Bug Fix: If the first menu item has a dropdown there are padding issues in the dropdown [#39](https://github.com/BoldGrid/crio/issues/39) * Bug Fix: Cannot get even spacing between posts and header/footer on Blog Page [#38](https://github.com/BoldGrid/crio/issues/38) diff --git a/gulpfile.js b/gulpfile.js index 41cf7ba4b..10c836dfc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -429,6 +429,18 @@ gulp.task('bootstrapCompile', function () { // .pipe( notify( { message: 'SCSS compile complete', onLast: true } ) ); }); +// Bootstrap Compile +gulp.task('colorPalettesCompile', function () { + gulp.src(config.dist + '/assets/scss/custom-color/color-palettes.scss') + .pipe(sass()) + .pipe(sass.sync().on('error', sass.logError)) + .pipe(gulp.dest(config.prime_dest + '/css' ) ) + .pipe(cssnano({ discardComments: { removeAll: true }, safe: true })) + .pipe(rename({ suffix: '.min' })) + .pipe(gulp.dest( config.prime_dest + '/css' ) ) + // .pipe( notify( { message: 'SCSS compile complete', onLast: true } ) ); +}); + // Watch for changes and recompile scss gulp.task('sass:watch', function () { gulp.watch( 'src/assets/scss/**/*.scss', function () { @@ -554,7 +566,7 @@ gulp.task( 'build', function( cb ) { ['jsHint', 'jscs', 'frameworkJs', 'svgs', 'tgm'], ['scssDeps', 'jsDeps', 'modernizr', 'fontDeps', 'phpDeps', 'frameworkFiles', 'copyScss'], 'images', - ['scssCompile', 'bootstrapCompile'], + ['scssCompile', 'bootstrapCompile', 'colorPalettesCompile' ], ['fontFamilyCss', 'patterns'], 'hovers', 'hoverColors', diff --git a/package.json b/package.json index 7329dfddb..8bff5c6ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "boldgrid-theme-framework", - "version": "2.19.2", + "version": "2.20.0", "description": "BoldGrid Theme Framework", "main": "index.js", "engines": { diff --git a/prime/inc/boldgrid-theme-framework-config/config.php b/prime/inc/boldgrid-theme-framework-config/config.php index ec9198a4c..33f55774e 100755 --- a/prime/inc/boldgrid-theme-framework-config/config.php +++ b/prime/inc/boldgrid-theme-framework-config/config.php @@ -219,8 +219,8 @@ function boldgrid_prime_framework_config( $config ) { $config['customizer']['controls']['bgtfw_header_color']['default'] = 'color-5'; // Footer specific colors for background, headings, and links. - $config['customizer']['controls']['bgtfw_footer_color']['default'] = 'color-5'; - $config['customizer']['controls']['bgtfw_footer_links']['default'] = 'color-1'; + $config['customizer']['controls']['bgtfw_footer_color']['default'] = 'color-5'; + $config['customizer']['controls']['bgtfw_footer_link_color']['default'] = get_theme_mod( 'bgtfw_footer_links', 'color-1' ); // Page title display settings, show by default. $config['customizer']['controls']['bgtfw_pages_title_display']['default'] = 'show'; diff --git a/readme.txt b/readme.txt index c124444e9..c58a43624 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: news, blog, e-commerce, sticky-post, theme-options, threaded-comments, ful Requires PHP: 5.6 Requires at least: 4.8 Tested up to: 6.2 -Stable tag: 2.19.2 +Stable tag: 2.20.0 License: GPL-3.0-or-later License URI: https://www.gnu.org/licenses/gpl-3.0-standalone.html @@ -14,13 +14,20 @@ Crio is a WordPress SuperTheme that allows designers, developers and other web p Crio is a WordPress SuperTheme that allows designers, developers and other web professionals to create without bounds or restrictions. Crio’s advanced customization options are completely integrated with the WordPress Customizer API, providing you with a powerful, but familiar interface to customize your website. Our integration gives you granular control over many elements straight from the Customizer, and even device previews so you can see how your site looks on different devices. Crio’s unique color palette system keeps colors consistent across your site. Drag and drop colors in your palette to increase or decrease the usage of that color throughout your website. Use the advanced controls to create a custom Header, Footer, or Blog Page layout. Be Bold and stand above the rest with Crio by BoldGrid! == Upgrade Notice == -= 2.10.0 = -This version includes CSS fixes for incorrect margin / padding issues. If you are using the Custom CSS as a temporary fix for these issues, this update may possibly conflict with your custom CSS. + += 2.20.0 = +This version changes the way the color palette CSS is generated. If you are using custom CSS to override color palettes, this may cause some conflicts. == Changelog == ## Changelog ## +== 2.20.0 == +* Enhancement: Improve Color Palettes by using color variables instead of SCSS compilation during runtime [#50](https://github.com/BoldGrid/crio/issues/50) +* New Feature: Add notice to Design > Footer > Colors to help users [#48](https://github.com/BoldGrid/crio/issues/48) +* New Feature: If I add a logo but my header isn't setup to show it, show a warning [#49](https://github.com/BoldGrid/crio/issues/49) +* Accessibility: Hidden Tagline = Empty Heading Tag = Bad for Accessibility [#52](https://github.com/BoldGrid/crio/issues/52) + == 2.19.2 == * Bug Fix: If the first menu item has a dropdown there are padding issues in the dropdown [#39](https://github.com/BoldGrid/crio/issues/39) * Bug Fix: Cannot get even spacing between posts and header/footer on Blog Page [#38](https://github.com/BoldGrid/crio/issues/38) diff --git a/src/assets/js/customizer/color-palette-generate.js b/src/assets/js/customizer/color-palette-generate.js index 65f9945fd..408b67590 100644 --- a/src/assets/js/customizer/color-palette-generate.js +++ b/src/assets/js/customizer/color-palette-generate.js @@ -93,6 +93,138 @@ BOLDGRID.COLOR_PALETTE.Generate = BOLDGRID.COLOR_PALETTE.Generate || {}; '#1a1a1a' ]; + /** + * Css Variables. + * + * Generate CSS Variables for a color palette. + * + * @ since 2.20.0 + * + * @param {object} colorPalette The Color Palette Object. + * + * @returns string CSS Variables string. + */ + self.cssVariables = function( colorPalette ) { + var css = '', + formattedPalette = {}; + + $.each( colorPalette.colors, function( index, color ) { + var colorIndex = index + 1; + + formattedPalette['color-' + colorIndex ] = color; + } ); + + formattedPalette['color-neutral'] = colorPalette['neutral-color']; + + $.each( formattedPalette, function( variable, color ) { + css += `--${variable}: ${color};`; + css += `--${variable}-raw: ` + color.replace( 'rgb(', '' ).replace( ')', '' ) + ';'; + css += `--${variable}-light:` + net.brehaut.Color( color ).lightenByAmount( 0.1 ).toCSS() + ';'; + css += self.generateHoverVars( formattedPalette, variable, color ); + } ); + + return css; + }; + + /** + * Generates CSS Variables for hover colors. + * + * @since 2.20.0 + * + * @param {object} formattedPalette Formatted colors object. + * @param {string} textVariable Text color variable. + * @param {string} textColor Text color value. + * + * @returns {string} CSS Variables string. + */ + self.generateHoverVars = function( formattedPalette, textVariable, textColor ) { + var textIndex = textVariable.replace( 'color-', '' ), + hoverVars = ''; + + $.each( formattedPalette, function( bgVariable, bgColor ) { + var bgIndex = bgVariable.replace( 'color-', '' ), + hoverColor = self.getHoverColor( + net.brehaut.Color( bgColor ), + net.brehaut.Color( textColor ) + ); + + hoverVars += `--bg-${bgIndex}-text-${textIndex}-hover: ${hoverColor};`; + } ); + + return hoverVars; + }; + + /** + * Get Hover Color. + * + * All the logic for determining the hover color was + * derived from the SCSS functions defined prior to the + * 2.2.0 release in the following file: + * + * src/assets/scss/custom-color/color-palettes.scss + * + * @since 2.20.0 + * + * @param {Color} BgColor Background Color object. + * @param {Color} TextColor Text Color object. + * + * @returns {string} RGB Color value. + */ + self.getHoverColor = function( BgColor, TextColor ) { + var textLightness = TextColor.getLightness(), + bgLightness = BgColor.getLightness(), + hoverColor; + + // White Text + if ( 1 === textLightness ) { + + // Dark Background + if ( 0.9 <= bgLightness ) { + hoverColor = BgColor.darkenByAmount( 0.15 ); + + // Light Background + } else { + hoverColor = BgColor.blend( TextColor, 0.8 ); + } + + // Black Text + } else if ( 0 === textLightness ) { + + // Dark Background + if ( 0.10 > bgLightness ) { + hoverColor = BgColor.lightenByAmount( 0.2 ); + + // Light Background + } else { + hoverColor = BgColor.blend( TextColor, 0.6 ); + } + + // Light Text on Dark Background. + } else if ( bgLightness < textLightness ) { + + // Color is too light to lighten. + if ( 0.9 < textLightness ) { + hoverColor = TextColor.darkenByAmount( 0.2 ); + } else { + hoverColor = TextColor.lightenByAmount( 0.2 ); + } + + // Dark Text on Light Background. + } else { + + // Color is too dark to darken. + if ( 0.15 > textLightness ) { + hoverColor = TextColor.lightenByAmount( 0.2 ); + } else { + hoverColor = TextColor.darkenByAmount( 0.2 ); + } + } + + hoverColor = hoverColor.toRGB(); + + return 'rgb(' + Math.floor( hoverColor.red * 255 ) + ',' + Math.floor( hoverColor.green * 255 ) + ',' + Math.floor( hoverColor.blue * 255 ) + ')'; + }; + /** * Get a random color * Not Used ATM diff --git a/src/assets/js/customizer/color-palette-preview.js b/src/assets/js/customizer/color-palette-preview.js index 3fc25f70a..599f9d540 100644 --- a/src/assets/js/customizer/color-palette-preview.js +++ b/src/assets/js/customizer/color-palette-preview.js @@ -22,6 +22,117 @@ BOLDGRID.COLOR_PALETTE.Preview = BOLDGRID.COLOR_PALETTE.Preview || {}; } }); + /** + * Update CSS overlay colors. + * + * CSS Overlay colors are translucent background colors + * added to elements using PPB. These are currently added using head inline CSS + * since the PPB added this feature before we added the --color-x-raw variables. + * + * This method will update the inline CSS to use the --color-x-raw variables when + * the palette is changed. However, in the future, we should update PPB to use + * the --color-x-raw variables instead of inline CSS. + * + * @since 2.20.0 + */ + self.updateOverlayColors = function() { + var $bgColorElements = $( '[class*="-background-color"]' ), + $imgOverlayElements = $( '[data-bg-overlaycolor-class]' ), + $fwrElements = $( '[class*="fwr-"]' ), + rawColorValues = { + 'color-1-raw': $( ':root' ).css( '--color-1-raw' ), + 'color-2-raw': $( ':root' ).css( '--color-2-raw' ), + 'color-3-raw': $( ':root' ).css( '--color-3-raw' ), + 'color-4-raw': $( ':root' ).css( '--color-4-raw' ), + 'color-5-raw': $( ':root' ).css( '--color-5-raw' ), + 'color-neutral-raw': $( ':root' ).css( '--color-neutral-raw' ), + }; + + $bgColorElements.each( ( _, el ) => { + var $bgColorEl = $( el ), + bgUuid = $bgColorEl.attr( 'data-bg-uuid' ), + $fwrInlineStyle = $( `#${bgUuid}-inline-css` ); + + $fwrInlineStyle.each( ( _, el ) => { + self.updateBgColorOverlays( el, rawColorValues ); + } ); + } ); + + $imgOverlayElements.each( ( _, el ) => { + self.updateImageOverlays( el, rawColorValues ); + } ); + + $fwrElements.each( ( _, el ) => { + var $fwr = $( el ), + classList = $fwr.attr( 'class' ), + fwrId = 'fwr-' + classList.match( /fwr-?(\d+)/ )[1], + $fwrInlineStyle = $( `#${fwrId}-inline-css` ); + + $fwrInlineStyle.each( ( _, el ) => { + self.updateBgColorOverlays( el, rawColorValues ); + } ); + } ); + }; + + /** + * Updage Image Overlay colors. + * + * Elements that have a translucent color overlaying the + * background image that uses a color from the palette, + * has the background-image property set in the elements' + * inline styles. + * + * @since 2.20.0 + * + * @param {object} el Image overlay element. + * @param {object} rawColorValues Raw color values. + */ + self.updateImageOverlays = function( el, rawColorValues ) { + var $el = $( el ), + elStyle = $el.attr( 'style' ), + colorIndex = $el.attr( 'data-bg-overlaycolor-class' ), + overlayValue = rawColorValues[`color-${colorIndex}-raw`], + overlayVariable = `var(--color-${colorIndex}-raw)`, + colorMatches = elStyle.match( new RegExp( overlayValue, 'g' ) ); + + // If the color value is not found, try removing the spaces. + if ( ! colorMatches ) { + overlayValue = overlayValue.replace( /\s/g, '' ); + colorMatches = elStyle.match( new RegExp( overlayValue, 'g' ) ); + } + + $el.attr( + 'style', + elStyle.replace( new RegExp( overlayValue, 'g' ), overlayVariable ) + ); + }; + + + /** + * Update BG Color Overlays. + * + * Elements with a translucent background color + * that uses a color from the palette, and does not + * have a background image, has the background properties + * set in the inline style element. This handles + * Full Width Rows as well. + * + * @since 2.20.0 + * + * @param {object} inlineStyleEl inline style element. + * @param {object} rawColorValues Raw color values. + */ + self.updateBgColorOverlays = function( inlineStyleEl, rawColorValues ) { + var $inlineStyleEl = $( inlineStyleEl ), + styleString = $inlineStyleEl.html(); + + _.each( rawColorValues, ( colorRawValue, colorRawVariable ) => { + styleString = styleString.replace( new RegExp( colorRawValue, 'g' ), `var(--${colorRawVariable})` ); + } ); + + $inlineStyleEl.html( styleString ); + }; + /** * Main responsibility of this file * The to parameter, is a json string that is inside of a textarea in the parent window @@ -44,7 +155,11 @@ BOLDGRID.COLOR_PALETTE.Preview = BOLDGRID.COLOR_PALETTE.Preview || {}; // Update styles. style = document.getElementById( 'boldgrid-color-palettes-inline-css' ); - style.innerHTML = modify.compiled_css; + if ( style ) { + style.innerHTML = ':root{' + modify.css_variables + '}'; + } else { + $( 'head' ).append( '' ); + } }; /** @@ -59,6 +174,9 @@ BOLDGRID.COLOR_PALETTE.Preview = BOLDGRID.COLOR_PALETTE.Preview || {}; .val( parent.BOLDGRID.COLOR_PALETTE.Modify.compiled_css ) .change(); } ); + + // Update overlay colors. + self.updateOverlayColors(); } ); wp.customize( 'boldgrid_compiled_css', function( value ) { diff --git a/src/assets/js/customizer/color-palette.js b/src/assets/js/customizer/color-palette.js index 2645abdb0..888c8c60a 100644 --- a/src/assets/js/customizer/color-palette.js +++ b/src/assets/js/customizer/color-palette.js @@ -1045,6 +1045,9 @@ BOLDGRID.COLOR_PALETTE.Modify = BOLDGRID.COLOR_PALETTE.Modify || {}; * Change the palette settings */ colorPalette.update_palette_settings = function() { + colorPalette.css_variables = BOLDGRID.COLOR_PALETTE.Generate.cssVariables( colorPalette.state.palettes['palette-primary'] ); + colorPalette.state.css_variables = colorPalette.css_variables; + colorPalette.text_area_val = JSON.stringify({ 'state': colorPalette.state }); wp.customize( 'boldgrid_color_palette' ).set( '' ).set( colorPalette.text_area_val ); }; diff --git a/src/assets/js/customizer/color/preview.js b/src/assets/js/customizer/color/preview.js index 86e6274c8..d51768d5f 100644 --- a/src/assets/js/customizer/color/preview.js +++ b/src/assets/js/customizer/color/preview.js @@ -49,9 +49,9 @@ export class Preview { properties: [ 'color', 'color-hover' ] }, { - name: 'bgtfw_footer_links', - selector: '.footer-content:not(.template-footer)', - properties: [ 'link-color' ] + name: 'bgtfw_footer_link_color', + selector: '#colophon .bgtfw-footer.footer-content:not(.template-footer) .attribution-theme-mods > .link > a:not( .btn ):hover', + properties: [ 'color' ] } ]; } diff --git a/src/assets/js/customizer/customizer.js b/src/assets/js/customizer/customizer.js index d4ff571dc..7baf2d56a 100644 --- a/src/assets/js/customizer/customizer.js +++ b/src/assets/js/customizer/customizer.js @@ -547,6 +547,10 @@ BOLDGRID.Customizer.Util.getInitialPalettes = function( option ) { value.bind( function( to ) { var palettes, colors; + if ( ! to ) { + to = parent.BOLDGRID.COLOR_PALETTE.Modify.text_area_val; + } + palettes = parent.jQuery( '.colors-wrapper' ); colors = BOLDGRID.Customizer.Util.getInitialPalettes( to ); diff --git a/src/assets/js/customizer/header-layout/header-layout.js b/src/assets/js/customizer/header-layout/header-layout.js index 2ba12e16e..0eef17887 100644 --- a/src/assets/js/customizer/header-layout/header-layout.js +++ b/src/assets/js/customizer/header-layout/header-layout.js @@ -562,6 +562,18 @@ export class HeaderLayout { } } ); + controlApi.section( 'title_tagline' ).expanded.bind( ( isExpanded ) => { + if ( isExpanded ) { + this.brandingNotices( controlApi( 'bgtfw_header_preset_branding' )(), controlApi.control( 'custom_logo' ) ); + } + } ); + + controlApi( 'custom_logo', ( control ) => { + control.bind( () => { + this.brandingNotices( controlApi( 'bgtfw_header_preset_branding' )(), controlApi.control( 'custom_logo' ) ); + } ); + } ); + /* * bgtfw_header_presets * @@ -1059,7 +1071,9 @@ export class HeaderLayout { * @param {wp.customize.control} control Customizer Control object. */ brandingNotices( value, control ) { - var container = control.container; + var container = control.container, + controlId = control.id; + container.find( '.branding_notice' ).hide(); if ( value.includes( 'logo' ) && ! controlApi( 'custom_logo' )() ) { @@ -1085,6 +1099,15 @@ export class HeaderLayout { controlApi.control( 'blogdescription' ).focus(); } ); } + + if ( 'custom_logo' === controlId && ! value.includes( 'logo' ) && controlApi( 'custom_logo' )() ) { + container.find( '.branding_notice.logo_set' ).show(); + container.find( '.branding_notice.logo_set a' ).off( 'click' ); + container.find( '.branding_notice.logo_set a' ).on( 'click', ( e ) => { + e.preventDefault(); + controlApi.control( 'bgtfw_header_preset_branding' ).focus(); + } ); + } } /** diff --git a/src/assets/js/customizer/typography/link-preview.js b/src/assets/js/customizer/typography/link-preview.js index 59b625d1c..927c4a70a 100644 --- a/src/assets/js/customizer/typography/link-preview.js +++ b/src/assets/js/customizer/typography/link-preview.js @@ -14,6 +14,7 @@ export class LinkPreview { this.paletteSelector = new PaletteSelector(); this.prefixes = [ 'bgtfw_body', + 'bgtfw_footer', 'bgtfw_posts_date', 'bgtfw_posts_byline', 'bgtfw_posts_tags', @@ -52,6 +53,10 @@ export class LinkPreview { controls.push( `${prefix}_link_color_display` ); } + if ( 'bgtfw_footer' === prefix ) { + controls = [ `${prefix}_link_color` ]; + } + api( ...controls, ( ...args ) => { args.map( control => control.bind( () => this.updateStyles( prefix ) ) ); } ); @@ -83,13 +88,24 @@ export class LinkPreview { updateStyles( prefix ) { let css = ''; if ( false === _.isFunction( api( `${prefix}_link_color_display` ) ) || 'inherit' !== api( `${prefix}_link_color_display` )() ) { - let linkColor = this._getColor( `${prefix}_link_color`, true ), - linkColorHover = api( `${prefix}_link_color_hover` )() || 0, - decoration = this._getDecoration( `${prefix}_link_decoration` ), + let linkColor, linkColorHover, decoration, decorationHover, excludes, selectors, shiftedColorVal; + if ( 'bgtfw_footer' === prefix ) { + linkColor = this._getColor( `${prefix}_link_color`, true ), + linkColorHover = api( 'bgtfw_body_link_color_hover' )() || 0, + decoration = this._getDecoration( 'bgtfw_body_link_decoration' ), + decorationHover = this._getDecoration( 'bgtfw_body_link_decoration_hover' ), + excludes = '', + selectors = this.selectors[ prefix ], + shiftedColorVal; + } else { + linkColor = this._getColor( `${prefix}_link_color`, true ), + linkColorHover = api( `${prefix}_link_color_hover` )() || 0, + decoration = this._getDecoration( `${prefix}_link_decoration` ), decorationHover = this._getDecoration( `${prefix}_link_decoration_hover` ), - excludes = '', - selectors = this.selectors[ prefix ], + excludes = '', + selectors = this.selectors[ prefix ], shiftedColorVal; + } linkColorHover = parseInt( linkColorHover, 10 ) / 100; @@ -104,7 +120,7 @@ export class LinkPreview { } ${selector}:hover, ${selector}:focus { - color: ${shiftedColorVal}; + color: ${shiftedColorVal} !important; text-decoration: ${decorationHover}; } `; @@ -115,14 +131,13 @@ export class LinkPreview { * controlled by the Site Content Link typography controls. */ if ( 'bgtfw_body' === prefix ) { - let footerLinkColor = this._getColor( 'bgtfw_footer_links', true ), - footerLinkColorHover = api( `${prefix}_link_color_hover` )() || 0, - footerShiftedColorVal; - - footerLinkColorHover = parseInt( footerLinkColorHover, 10 ) / 100, - footerShiftedColorVal = colorLib.Color( footerLinkColor ).lightenByAmount( footerLinkColorHover ).toCSS(); + let colorPaletteOption = api( 'boldgrid_color_palette' )(); - let colorPaletteOption = JSON.parse( api( 'boldgrid_color_palette' )() ); + if ( colorPaletteOption ) { + colorPaletteOption = JSON.parse( api( 'boldgrid_color_palette' )() ); + } else { + colorPaletteOption = parent.BOLDGRID.COLOR_PALETTE.Modify; + } let paletteColors = colorPaletteOption.state.palettes['palette-primary'].colors; let paletteNeutral = colorPaletteOption.state.palettes['palette-primary']['neutral-color']; @@ -138,19 +153,8 @@ export class LinkPreview { css += `.sidebar.color-${sidebarColorClass}-link-color a:not( .btn ):hover, .sidebar.color-${sidebarColorClass}-link-color a:not( .btn ):focus { color: ${sidebarAriColor} !important; }`; } ); - css += ` - #colophon .bgtfw-footer.footer-content > a:not( .btn ), - #colophon .bgtfw-footer.footer-content *:not( .menu-item ) > a:not( .btn ) { - text-decoration: ${decoration}; - } - #colophon .bgtfw-footer.footer-content > a:not( .btn ):hover, - #colophon .bgtfw-footer.footer-content > a:not( .btn ):focus, - #colophon .bgtfw-footer.footer-content *:not( .menu-item ) > a:not( .btn ):hover, - #colophon .bgtfw-footer.footer-content *:not( .menu-item ) > a:not( .btn ):focus { - color: ${footerShiftedColorVal}; - text-decoration: ${decorationHover}; - } - `; + // footer Link Color. + this.updateStyles( 'bgtfw_footer' ); } } diff --git a/src/assets/scss/boldgrid/_elements.scss b/src/assets/scss/boldgrid/_elements.scss index 00cff63b1..aa715667a 100644 --- a/src/assets/scss/boldgrid/_elements.scss +++ b/src/assets/scss/boldgrid/_elements.scss @@ -366,3 +366,21 @@ body.bgtfw-edit-links-hidden .bgtfw-edit-link a { transform: scale3d(.3, .3, .3); } } + +.palette-primary { + .color1-background-alpha { + background-color: rgba( var(--color-1-raw), 0.7 ); + } + .color2-background-alpha { + background-color: rgba( var(--color-2-raw), 0.7 ); + } + .color3-background-alpha { + background-color: rgba( var(--color-3-raw), 0.7 ); + } + .color4-background-alpha { + background-color: rgba( var(--color-4-raw), 0.7 ); + } + .color5-background-alpha { + background-color: rgba( var(--color-5-raw), 0.7 ); + } +} diff --git a/src/assets/scss/custom-color/color-classes.scss b/src/assets/scss/custom-color/color-palettes.scss similarity index 50% rename from src/assets/scss/custom-color/color-classes.scss rename to src/assets/scss/custom-color/color-palettes.scss index 2953a2b19..be78ec25e 100644 --- a/src/assets/scss/custom-color/color-classes.scss +++ b/src/assets/scss/custom-color/color-palettes.scss @@ -1,127 +1,54 @@ -@function hover($background, $color) { - $style: ''; - $hover-color: ''; - $color-lightness: abs(lightness($color)); - $background-lightness: abs(lightness($background)); +$colors: ( var(--color-1), var(--color-2), var(--color-3), var(--color-4), var(--color-5) ); - @if $color-lightness == 100 { - /* White */ - @if $background-lightness >= 90 { - $hover-color: darken($background, 15); - } @else { - $hover-color: mix($color, $background, 80); - } - } @else if $color-lightness == 0 { - /* Black */ - @if $background-lightness < 10 { - $hover-color: lighten($background, 20); - } @else { - $hover-color: mix($color, $background, 60); - } - } @else if $background-lightness < $color-lightness { - /* Light text on dark background */ - $style: 'lighten'; - @if $color-lightness > 90 { - /* Color too light to lighten */ - $hover-color: darken($color, 20); - $style: 'darken'; - } @else { - $hover-color: lighten($color, 20); - } - } @else { - /* Dark text on light background */ - $style: 'darken'; - @if $color-lightness < 15 { - /* Color is too dark to further darken */ - $hover-color: lighten($color, 20); - $style: 'lighten'; - } @else { - $hover-color: darken($color, 20); - } - } - - @return $hover-color; -} +$palette-primary_1: var(--color-1); +$palette-primary_2: var(--color-2); +$palette-primary_3: var(--color-3); +$palette-primary_4: var(--color-4); +$palette-primary_5: var(--color-5); +$palette-primary-neutral-color: var(--color-neutral); $ubtn-colors: (); -@if variable-exists( palette-primary_1 ) { - $ubtn-colors: append($ubtn-colors,('color-1' $palette-primary_1 var(--color-1-text-contrast))); - @if $ubtn-theme-color == 'palette-primary_1' { - $ubtn-bgcolor: $palette-primary_1; - $ubtn-font-color: var(--color-1-text-contrast); - } -} -@if variable-exists( palette-primary_2 ) { - $ubtn-colors: append($ubtn-colors,('color-2' $palette-primary_2 var(--color-2-text-contrast))); - @if $ubtn-theme-color == 'palette-primary_2' { - $ubtn-bgcolor: $palette-primary_2; - $ubtn-font-color: var(--color-2-text-contrast); - } -} -@if variable-exists( palette-primary_3 ) { - $ubtn-colors: append($ubtn-colors,('color-3' $palette-primary_3 var(--color-3-text-contrast))); - @if $ubtn-theme-color == 'palette-primary_3' { - $ubtn-bgcolor: $palette-primary_3; - $ubtn-font-color: var(--color-3-text-contrast); - } -} -@if variable-exists( palette-primary_4 ) { - $ubtn-colors: append($ubtn-colors,('color-4' $palette-primary_4 var(--color-4-text-contrast))); - @if $ubtn-theme-color == 'palette-primary_4' { - $ubtn-bgcolor: $palette-primary_4; - $ubtn-font-color: var(--color-4-text-contrast); - } -} -@if variable-exists( palette-primary_5 ) { - $ubtn-colors: append($ubtn-colors,('color-5' $palette-primary_5 var(--color-5-text-contrast))); - @if $ubtn-theme-color == 'palette-primary_5' { - $ubtn-bgcolor: $palette-primary_5; - $ubtn-font-color: var(--color-5-text-contrast); - } -} -@if variable-exists( palette-primary-neutral-color ) { - $ubtn-colors: append($ubtn-colors,('neutral-color' $palette-primary-neutral-color var(--color-neutral-text-contrast))); - @if $ubtn-theme-color == 'palette-primary-neutral-color' { - $ubtn-bgcolor: $palette-primary-neutral-color; - $ubtn-font-color: var(--color-neutral-text-contrast); - } -} -@if variable-exists( palette-primary-transparent-color ) { - $ubtn-colors: append($ubtn-colors,('transparent-color' $palette-primary-transparent-color var(--color-neutral-text-contrast))); - @if $ubtn-theme-color == 'palette-primary-transparent-color' { - $ubtn-bgcolor: $palette-primary-transparent-color; - $ubtn-font-color: var(--color-neutral-text-contrast); - } -} +$ubtn-colors: append($ubtn-colors,('color-1' var( --color-1 ) var(--color-1-text-contrast) var( --color-1-light ) var( --color-1-dark ) )); + +$ubtn-colors: append($ubtn-colors,('color-2' var( --color-2 ) var(--color-2-text-contrast) var( --color-2-light ) var( --color-2-dark ))); + +$ubtn-colors: append($ubtn-colors,('color-3' var( --color-3 ) var(--color-3-text-contrast) var( --color-3-light ) var( --color-3-dark ))); + +$ubtn-colors: append($ubtn-colors,('color-4' var( --color-4 ) var(--color-4-text-contrast) var( --color-4-light ) var( --color-4-dark ))); + +$ubtn-colors: append($ubtn-colors,('color-5' var( --color-5 ) var(--color-5-text-contrast) var( --color-5-light ) var( --color-5-dark ))); + +$ubtn-colors: append($ubtn-colors,('neutral-color' var( --color-neutral ) var(--color-neutral-text-contrast) var( --color-neutral-light ) var( --color-neutral-dark ))); + /* Create single css classes to apply palettes on universal elements. */ $names: background background-color; .sidebar.transparent-background-color { @for $color from 1 through length( $colors ) { @for $each from 1 through length( $colors ) { - $reference: nth($colors, $color); + $reference: var(--color-#{$color}); &.color-#{$each}-link-color { a:not( .btn ) { - color: #{nth($colors, $each)}; + color: var(--color-#{$each}); } } } @if variable-exists( palette-primary-neutral-color ) { &.color-neutral-link-color { a:not( .btn ) { - color: $palette-primary-neutral-color; + color: var(--color-neutral); } } &.color-neutral-sub-link-color.sm { ul.sub-menu:not( .custom-sub-menu ) { li.menu-item { > a:not(.btn) { - color: $palette-primary-neutral-color; + color: var(--color-neutral); } > a:not(.btn) { &:hover, &:focus, &:active, &.highlighted { - color: hover( nth($colors, $color), $palette-primary-neutral-color ); + color: var(--bg-#{$color}-text-neutral-hover); } } } @@ -130,25 +57,25 @@ $names: background background-color; } &-hover { &:focus, &:hover { - background-color: nth($colors, $color) ! important; + background-color: var(--color-#{$color}) ! important; } } } } @for $i from 1 through length( $names ) { @for $color from 1 through length( $colors ) { - $reference: nth($colors, $color); + $reference: var(--color-#{$color}); .color#{$color}-#{nth( $names, $i )} { @for $each from 1 through length( $colors ) { &.color-#{$each}-link-color { li.menu-item:not( .custom-sub-menu ), .attribution-theme-mods .link { > a:not( .btn ) { - color: #{nth($colors, $each)}; + color: var(--color-#{$each}); } > a:not( .btn ) { &:hover, &:focus, &:active, &.highlighted { - color: hover( nth($colors, $color), nth($colors, $each) ); + color: var(--bg-#{$color}-text-#{$each}-hover); } } } @@ -159,11 +86,11 @@ $names: background background-color; &.panel-footer { &.color-#{$each}-link-color { a:not( .btn ) { - color: #{nth($colors, $each)}; + color: var(--color-#{$each}); } > a:not( .btn ) { &:hover, &:focus, &:active, &.highlighted { - color: hover( nth($colors, $color), nth($colors, $each) ); + color: var(--bg-#{$color}-text-#{$each}-hover); } } } @@ -171,7 +98,7 @@ $names: background background-color; &.sidebar { &.color-#{$each}-link-color { a:not( .btn ) { - color: #{nth($colors, $each)}; + color: var(--color-#{$each}); } } } @@ -189,11 +116,11 @@ $names: background background-color; } li.menu-item:not( .custom-sub-menu ) { > a:not(.btn) { - color: #{nth($colors, $each)}; + color: var(--color-#{$each}); } > a:not(.btn) { &:hover, &:focus, &:active, &.highlighted { - color: hover( nth($colors, $color), nth($colors, $each) ); + color: var(--bg-#{$color}-text-#{$each}-hover); } } } @@ -201,9 +128,9 @@ $names: background background-color; &.color-#{$subeach}-sub-link-color { li.menu-item:not( .custom-sub-menu ) { ul.sub-menu:not( .custom-sub-menu ) > a:not(.btn) { - color: #{nth($colors, $subeach)}; + color: var(--color-#{$subeach}); &:hover, &:focus, &:active, &.highlighted { - color: hover( nth($colors, $subeach), nth($colors, $subeach) ); + color: var(--bg-#{$color}-text-#{$subeach}-hover); } } } @@ -216,9 +143,9 @@ $names: background background-color; &.color-neutral-link-color { a { &:not( .in-mega ):not( .btn ) { - color: $palette-primary-neutral-color; + color: var(--color-neutral); &:hover, &:focus, &:active, &.highlighted { - color: hover( nth($colors, $color), $palette-primary-neutral-color ); + color: var(--bg-#{$color}-text-neutral-hover); } } } @@ -227,9 +154,9 @@ $names: background background-color; ul.sub-menu:not( .custom-sub-menu ) { li.menu-item:not( .custom-sub-menu ) { > a:not(.btn) { - color: $palette-primary-neutral-color; + color: var(--color-neutral); &:hover, &:focus, &:active, &.highlighted { - color: hover( nth($colors, $color), $palette-primary-neutral-color ); + color: var(--bg-#{$color}-text-neutral-hover); } } } @@ -240,9 +167,9 @@ $names: background background-color; ul.sub-menu:not( .custom-sub-menu ) { li.menu-item:not( .custom-sub-menu ) { > a:not(.btn) { - color: #{nth($colors, $subEach)}; + color: var(--color-#{$subEach}); &:hover, &:focus, &:active, &.highlighted { - color: hover( nth($colors, $color), nth($colors, $subEach) ); + color: var(--bg-#{$color}-text-#{$subEach}-hover); } } } @@ -262,11 +189,11 @@ $names: background background-color; @for $each from 1 through length( $colors) { &.color-#{$each}-link-color { a { - color: #{nth($colors, $each)}; + color: var(--color-#{$each}); } &:not( .sidebar ) { a:hover, a:focus, a:active, a.highlighted { - color: hover( $palette-primary-neutral-color, nth($colors, $each) ); + color: var(--bg-neutral-text-#{$each}-hover); } } } @@ -274,9 +201,9 @@ $names: background background-color; ul.sub-menu:not( .custom-sub-menu ) { li.menu-item:not( .custom-sub-menu ) { > a:not(.btn) { - color: #{nth($colors, $each)}; + color: var(--color-#{$each}); &:hover, &:focus, &:active, &.highlighted { - color: hover( $palette-primary-neutral-color, nth($colors, $each) ); + color: var(--bg-neutral-text-#{$each}-hover); } } } @@ -285,19 +212,19 @@ $names: background background-color; } &.color-neutral-link-color { a { - color: $palette-primary-neutral-color; + color: var(--color-neutral); } a:hover, a:focus, a:active, a.highlighted { - color: hover( $palette-primary-neutral-color, $palette-primary-neutral-color ); + color: var(--bg-neutral-text-neutral-hover); } } &.color-neutral-sub-link-color.sm { ul.sub-menu:not( .custom-sub-menu ) { li.menu-item:not( .custom-sub-menu ) { > a:not(.btn) { - color: $palette-primary-neutral-color; + color: var(--color-neutral); &:hover, &:focus, &:active, &.highlighted { - color: hover( $palette-primary-neutral-color, $palette-primary-neutral-color ); + color: var(--bg-neutral-text-neutral-hover); } } } @@ -317,8 +244,11 @@ $names: background background-color; @each $ubtn-color in $ubtn-colors { $ubtn-name: nth($ubtn-color, 1); $ubtn-background: nth($ubtn-color, 2); + $ubtn-bg-light: nth($ubtn-color, 4); + $ubtn-bg-dark: nth($ubtn-color, 5); $ubtn-color: nth($ubtn-color, 3); + // Crete class for .button-primary // and legacy flat .button-primary-flat .btn-#{$ubtn-name}, @@ -328,6 +258,12 @@ $names: background background-color; background-color: $ubtn-background !important; border-color: $ubtn-background; color: $ubtn-color; + &.btn-raised { + background: linear-gradient( $ubtn-background, $ubtn-bg-light ) !important; + &:hover, &:focus { + background: linear-gradient( $ubtn-bg-light, $ubtn-background ) !important; + } + } a { color: $ubtn-color; } @@ -341,8 +277,8 @@ $names: background background-color; &:hover, &:focus { - background-color: lighten($ubtn-background, 10%) !important; - border-color: lighten($ubtn-background, 10%); + background-color: $ubtn-bg-light !important; + border-color: $ubtn-bg-light; color: $ubtn-color; a { color: $ubtn-color; @@ -352,9 +288,9 @@ $names: background background-color; &:active, &.active, &.is-active { - background-color: desaturate($ubtn-background, 10%) !important; - border-color: desaturate($ubtn-background, 10%); - color: darken($ubtn-background, 10%); + background-color: $ubtn-bg-light !important; + border-color: $ubtn-bg-light; + color: $ubtn-color; a { color: $ubtn-color; } @@ -373,13 +309,13 @@ $names: background background-color; &:hover, &:focus { &.btn-transparent{ - background-color: lighten($ubtn-background, 10%) !important; + background-color: $ubtn-bg-light !important; color: $ubtn-color; a { color: $ubtn-color; } } - border-color: lighten($ubtn-background, 10%) !important; + border-color: $ubtn-bg-light !important; } @@ -387,13 +323,13 @@ $names: background background-color; &.active, &.is-active { &.btn-transparent{ - background-color: lighten($ubtn-background, 10%) !important; - color: darken($ubtn-background, 10%); + background-color: $ubtn-bg-light !important; + color: $ubtn-color; a { color: $ubtn-color; } } - border-color: desaturate($ubtn-background, 10%) !important; + border-color: $ubtn-bg-light !important; } } } diff --git a/src/assets/scss/customizer/controls/_link-colors.scss b/src/assets/scss/customizer/controls/_link-colors.scss index 9ae72f800..bbc39ce5f 100644 --- a/src/assets/scss/customizer/controls/_link-colors.scss +++ b/src/assets/scss/customizer/controls/_link-colors.scss @@ -1,7 +1,7 @@ [id^="customize-control-bgtfw_"] { &[id$="_link_color"], &[id$="_link_color_display"] { - &:not( [id$="_link_color_display"] ), + &:not( [id$="_link_color_display"] ):not( [id$="_footer_link_color"] ), ~ [id$="_link_color"], ~ [id$="_link_color_hover"], ~ [id$="_link_decoration"], @@ -22,7 +22,7 @@ padding-bottom: 12px; border-bottom: 1px solid rgba(0, 0, 0, 0.1); } - &[id$="_link_color"] { + &[id$="_link_color"]:not( [id$="_footer_link_color"] ) { border-top: 1px solid rgba(0, 0, 0, 0.1); } &[id$="_link_color_display"] + &[id$="_link_color"] { diff --git a/src/boldgrid-theme-framework.php b/src/boldgrid-theme-framework.php index e99288423..4a55edcf0 100644 --- a/src/boldgrid-theme-framework.php +++ b/src/boldgrid-theme-framework.php @@ -3,7 +3,7 @@ * Plugin Name: BoldGrid Theme Framework * Plugin URI: https://www.boldgrid.com/docs/configuration-file * Description: BoldGrid Theme Framework is a library that allows you to easily make BoldGrid themes. Please see our reference guide for more information: https://www.boldgrid.com/docs/configuration-file - * Version: 2.19.2 + * Version: 2.20.0 * Author: BoldGrid.com * Author URI: https://www.boldgrid.com/ * Text Domain: bgtfw diff --git a/src/includes/class-boldgrid-framework-api.php b/src/includes/class-boldgrid-framework-api.php index 366845a13..6ef900109 100644 --- a/src/includes/class-boldgrid-framework-api.php +++ b/src/includes/class-boldgrid-framework-api.php @@ -108,8 +108,9 @@ public function site_logo_or_title() { */ public function print_tagline() { // Retrieve blog tagline. - $blog_info = get_bloginfo( 'description' ); - $display = get_theme_mod( 'bgtfw_tagline_display' ) === 'hide' ? ' screen-reader-text' : ''; + $blog_info = get_bloginfo( 'description' ); + $display = get_theme_mod( 'bgtfw_tagline_display' ) === 'hide' ? ' screen-reader-text' : ''; + $aria_hidden = ! in_array( 'description', get_theme_mod( 'bgtfw_header_preset_branding' ) ) ? 'true' : 'false'; if ( $blog_info ) { $classes = $this->configs['template']['tagline-classes'] . $display; @@ -117,7 +118,12 @@ public function print_tagline() { $classes = $this->configs['template']['tagline-classes'] . ' site-description invisible'; } - printf( wp_kses_post( $this->configs['template']['tagline'] ), esc_attr( $classes ), esc_html( $blog_info ) ); + printf( + '

%3$s

', + esc_attr( $classes ), + esc_attr( $aria_hidden ), + esc_html( $blog_info ) + ); } /** @@ -365,7 +371,7 @@ public function inner_footer_classes( $classes ) { $classes = array_merge( $classes, $this->get_background_color( 'bgtfw_footer_color' ), - $this->get_link_color( 'bgtfw_footer_links' ) + $this->get_link_color( 'bgtfw_footer_link_color' ) ); } diff --git a/src/includes/class-boldgrid-framework-compile-colors.php b/src/includes/class-boldgrid-framework-compile-colors.php index 718b11f99..23d9ac83f 100644 --- a/src/includes/class-boldgrid-framework-compile-colors.php +++ b/src/includes/class-boldgrid-framework-compile-colors.php @@ -172,9 +172,189 @@ public function get_scss_variables() { $color_variables['ubtn-font-color'] = '$text-contrast-' . get_theme_mod( 'boldgrid_palette_class', 'palette-primary' ) . '_' . $this->get_button_default_color() . ';'; $color_variables['ubtn-theme-color'] = get_theme_mod( 'boldgrid_palette_class', 'palette-primary' ) . '_' . $this->get_button_default_color() . ';'; } + return $color_variables; } + /** + * Generate SCSS variables for Hover Colors. + * + * @since 2.20.0 + * + * @param array $formatted_palette Array of formatted palette colors. + * @param string $text_color_name Property to generate hover colors for. + * @param string $text_color_value Value of color. + * + * @return string $scss_variables SCSS variables for hover colors. + */ + public function generate_hover_variables( $formatted_palette, $text_color_name, $text_color_value ) { + $hover_variables = ''; + $text_index = str_replace( 'color-', '', $text_color_name ); + $text_rgba_array = $this->get_rgb_array( $text_color_value ); + $light_hsla_array = $this->rgba_to_hsla( $text_rgba_array, 10 ); + $lighter_hsla_array = $this->rgba_to_hsla( $text_rgba_array, 20 ); + $dark_hsla_array = $this->rgba_to_hsla( $text_rgba_array, -10 ); + $darker_hsla_array = $this->rgba_to_hsla( $text_rgba_array, -20 ); + + foreach ( $formatted_palette as $bg_color_name => $bg_color_value ) { + $bg_index = str_replace( 'color-', '', $bg_color_name ); + $hover_color = $this->get_hover_color( + $this->normalize( $bg_color_value ), + $this->normalize( $text_color_value ) + ); + $hover_variables .= "--bg-$bg_index-text-$text_index-hover: $hover_color;"; + } + + return $hover_variables; + } + + /** + * Get the hover color for a given background and text color. + * + * All the logic for determining the hover color was + * derived from the SCSS functions defined prior to the + * 2.2.0 release in the following file: + * + * src/assets/scss/custom-color/color-palettes.scss + * + * @since 2.20.0 + * + * @param string $bg_color_value Background color value. + * @param string $text_color_value Text color value. + * + * @return string $hover_color Hover color. + */ + public function get_hover_color( $bg_color_value, $text_color_value ) { + $text_lightness = intval( $this->get_luminance( $text_color_value ) ); + $bg_lightness = intval( $this->get_luminance( $bg_color_value ) ); + $bg_rgb_array = $this->get_rgb_array( $bg_color_value ); + $text_rgb_array = $this->get_rgb_array( $text_color_value ); + + if ( 100 === $text_lightness ) { + // White text. + if ( 90 <= $bg_lightness ) { + // Light background. + $hover_color = $this->hsla_array_to_string( + $this->rgba_to_hsla( $bg_rgb_array, -15 ) + ); + } else { + // Dark background. + $hover_color = $this->rgba_array_to_string( + $this->mix_rbg_colors( $text_rgb_array, $bg_rgb_array, 0.8 ) + ); + } + } elseif ( 0 === $text_lightness ) { + // Black text. + if ( 10 > $bg_lightness ) { + // Dark background. + $hover_color = $this->hsla_array_to_string( + $this->rgba_to_hsla( $bg_rgb_array, 20 ) + ); + } else { + // Light background. + $hover_color = $this->rgba_array_to_string( + $this->mix_rbg_colors( $text_rgb_array, $bg_rgb_array, 0.6 ) + ); + } + } elseif ( $bg_lightness < $text_lightness ) { + // Light text on dark background. + if ( 90 < $text_lightness ) { + // Color to light to lighten. + $hover_color = $this->hsla_array_to_string( + $this->rgba_to_hsla( $text_rgb_array, -20 ) + ); + } else { + // Dark background. + $hover_color = $this->hsla_array_to_string( + $this->rgba_to_hsla( $text_rgb_array, 20 ) + ); + } + } else { + // Dark text on light background. + if ( 15 > $text_lightness ) { + // Color is too dark to darken. + $hover_color = $this->hsla_array_to_string( + $this->rgba_to_hsla( $text_rgb_array, 20 ) + ); + } else { + $hover_color = $this->hsla_array_to_string( + $this->rgba_to_hsla( $text_rgb_array, -20 ) + ); + } + } + + return $hover_color; + } + + /** + * RGBA array to string. + * + * Convert an RGBA array to a formatted string. + * + * @since 2.20.0 + * + * @param array $rgba_array RGBA array. + * + * @return string $rgba_string RGBA string. + */ + public function rgba_array_to_string( $rgba_array ) { + $r = $rgba_array[0]; + $g = $rgba_array[1]; + $b = $rgba_array[2]; + $a = isset( $rgba_array[3] ) ? $rgba_array[3] : 1; + + $rgba_string = 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $a . ')'; + return $rgba_string; + } + + /** + * HSLA array to string. + * + * Convert an HSLA array to a formatted string. + * + * @since 2.20.0 + * + * @param array $hsla_array HSLA array. + * + * @return string $hsla_string HSLA string. + */ + public function hsla_array_to_string( $hsla_array ) { + $h = $hsla_array[0]; + $s = $hsla_array[1]; + $l = $hsla_array[2]; + $a = isset( $hsla_array[3] ) ? $hsla_array[3] : 1; + + $hsla_string = 'hsla(' . $h . ',' . $s . ',' . $l . ',' . $a . ')'; + return $hsla_string; + } + + /** + * Mix Two RGB Colors. + * + * @since 2.20.0 + * + * @param array $color_1 RGB Color 1. + * @param array $color_2 RGB Color 2. + * @param float $weight Mix Weight. + * + * @return array $mixed_color Mixed Color. + */ + public function mix_rbg_colors( $color_1 = array( 0, 0, 0 ), $color_2 = array( 0, 0, 0 ), $weight = 0.5 ) { + $f = function ( $x ) use ( $weight ) { + return $weight * $x; + }; + + $g = function ( $x ) use ( $weight ) { + return ( 1 - $weight ) * $x; + }; + + $h = function ( $x, $y ) { + return round( $x + $y ); + }; + + return array_map( $h, array_map( $f, $color_1 ), array_map( $g, $color_2 ) ); + } + /** * Converts a hex color into an array of RGB. * @@ -334,7 +514,7 @@ public function get_button_default_color() { */ public function get_button_color_files( $files ) { $s = $this->configs['components']['buttons']['variables']; - $path = $this->configs['customizer-options']['colors']['settings']['scss_directory']['framework_dir'] . '/buttons/'; + $path = $this->configs['framework']['asset_dir'] . 'scss/custom-color/buttons/'; $configs = array(); // Build an array of button-classes that are needed. if ( ! empty( $s['button-primary-classes'] ) ) { @@ -424,6 +604,82 @@ public function normalize( $color ) { return $normalized; } + /** + * Get RGB(A) Array from rgb or rgba string. + * + * Returns an array of R,G,B,A values from a string. + * + * @since 2.20.0 + */ + public function get_rgb_array( $color ) { + $rgba_string = $this->normalize( $color ); + $rgba_string = str_replace( 'rgba(', '', $rgba_string ); + $rgba_string = str_replace( ')', '', $rgba_string ); + + $rgba = explode( ',', $rgba_string ); + return $rgba; + } + + /** + * Convert RGBA to HSLA. + * + * @since 2.20.0 + * + * @param array $rgba_array Array of RGBA values. + * @param int $luminosity_adjust Luminosity to adjust (optional). + * + * @return array $hsla_array HSLA array. + */ + public function rgba_to_hsla( $rgba_array, $luminosity_adjust = 0 ) { + $r = intval( $rgba_array[0] ); + $g = intval( $rgba_array[1] ); + $b = intval( $rgba_array[2] ); + $a = isset( $rgba_array[3] ) ? intval( $rgba_array[3] ) : 1; + + $r /= 255; + $g /= 255; + $b /= 255; + + $max = max( $r, $g, $b ); + $min = min( $r, $g, $b ); + + $h; + $s; + $l = ( $max + $min ) / 2; + $d = $max - $min; + + // If difference is 0, then it's a shade of grey. + if ( 0 == $d ) { + $h = 0; + $s = 0; + } else { + $s = $d / ( 1 - abs( 2 * $l - 1 ) ); + switch ( $max ) { + case $r: + $h = 60 * fmod( ( ( $g - $b ) / $d ), 6 ); + if ( $b > $g ) { + $h += 360; + } + break; + + case $g: + $h = 60 * ( ( $b - $r ) / $d + 2 ); + break; + + case $b: + $h = 60 * ( ( $r - $g ) / $d + 4 ); + break; + } + } + + return array( + round( $h, 2 ), + round( $s, 2 ) * 100 . '%', + ( round( $l, 2 ) * 100 ) + $luminosity_adjust . '%', + $a, + ); + } + /** * Get color class associated with a color passed in. * diff --git a/src/includes/class-boldgrid-framework-links.php b/src/includes/class-boldgrid-framework-links.php index 84d677ff6..084fd4e4a 100644 --- a/src/includes/class-boldgrid-framework-links.php +++ b/src/includes/class-boldgrid-framework-links.php @@ -51,11 +51,20 @@ public function __construct( $configs ) { '.custom-sub-menu a:not(.btn)', '.page-header-wrapper a:not(.btn)', '.mce-content-body *:not( .menu-item ) > a:not(.btn)', - '.template-header a:not(.btn)', + '.template-header *:not( .menu-item ) > a:not(.btn)', '.template-footer a:not(.btn)', '.template-sticky-header a:not(.btn)', ); + /** + * Footer Link Selectors. + * + * @var array + */ + public static $footer_link_selectors = array( + '#colophon .bgtfw-footer.footer-content .attribution-theme-mods > .link > a:not( .btn )', + ); + /** * Selectors to use for edit vars. * @@ -162,8 +171,19 @@ public function get_styles( $prefix ) { } if ( 'bgtfw_body' === $prefix ) { - $footer_link_color = explode( ':', get_theme_mod( 'bgtfw_footer_links' ) )[1]; - $footer_ari_color = ariColor::newColor( $color ); + /** + * The footer link theme mod name was changed from + * 'bgtfw_footer_links' to 'bgtfw_footer_link_color' in + * 2.20.0, so we need to check for both to ensure backwards compatibility. + */ + $footer_link_color = explode( + ':', + get_theme_mod( + 'bgtfw_footer_link_color', + get_theme_mod( 'bgtfw_footer_links' ) + ) + )[1]; + $footer_ari_color = ariColor::newColor( $footer_link_color ); $footer_color_hover = get_theme_mod( "${prefix}_link_color_hover" ) ?: 0; $footer_lightness = min( $footer_ari_color->lightness + $footer_color_hover, 100 ); $footer_lightness = max( $footer_lightness, 0 ); @@ -180,8 +200,8 @@ public function get_styles( $prefix ) { $css .= ".sidebar.color-${sidebar_color_class}-link-color a:not( .btn ):hover, .sidebar.color-${sidebar_color_class}-link-color a:not( .btn ):focus { color: ${sidebar_color_hover} !important; }"; } - $css .= "#colophon .bgtfw-footer.footer-content *:not( .menu-item ) > a:not( .btn ) { text-decoration: ${decoration};}"; - $css .= "#colophon .bgtfw-footer.footer-content *:not( .menu-item ) > a:not( .btn ):hover, .bgtfw-footer.footer-content *:not( .menu-item ) > a:not( .btn ):focus {color: ${footer_color_hover};text-decoration: ${decoration_hover};}"; + $css .= "#colophon .bgtfw-footer.footer-content .attribution-theme-mods > .link > a:not( .btn ) { text-decoration: ${decoration};}"; + $css .= "#colophon .bgtfw-footer.footer-content .attribution-theme-mods > .link > a:not( .btn ):hover, .bgtfw-footer.footer-content .attribution-theme-mods > .link > a:not( .btn ):focus {color: ${footer_color_hover};text-decoration: ${decoration_hover};}"; } } } diff --git a/src/includes/class-boldgrid-framework-styles.php b/src/includes/class-boldgrid-framework-styles.php index 7acb485bb..cbeb138ad 100644 --- a/src/includes/class-boldgrid-framework-styles.php +++ b/src/includes/class-boldgrid-framework-styles.php @@ -303,20 +303,13 @@ public function enqueue_colors( $deps = array() ) { $inline_override = true === $this->configs['framework']['inline_styles']; $is_changeset = ! empty( $_REQUEST['customize_changeset_uuid'] ) && ! is_customize_preview(); - if ( $inline_override || $is_changeset || is_customize_preview() ) { - wp_register_style( $handle, false ); - wp_enqueue_style( $handle ); - $css = get_theme_mod( 'boldgrid_compiled_css', '' ); - wp_add_inline_style( $handle, $css ); - } else { - wp_register_style( - $handle, - Boldgrid_Framework_Customizer_Colors::get_colors_uri( $this->configs ), - $deps, - $last_mod - ); - wp_enqueue_style( $handle ); - } + wp_register_style( + $handle, + Boldgrid_Framework_Customizer_Colors::get_colors_uri( $this->configs ), + $deps, + $last_mod + ); + wp_enqueue_style( $handle ); } if ( true === $this->configs['edit-post-links']['enabled'] ) { @@ -618,15 +611,35 @@ public function get_css_vars( $inline_css = '' ) { $inline_css .= "--light-text:{$light};"; $inline_css .= "--dark-text:{$dark};"; $additional_css = ''; + foreach ( $formatted_palette as $property => $value ) { + $value_rgba_array = $helper->get_rgb_array( $value ); + $light_hsla_array = $helper->rgba_to_hsla( $value_rgba_array, 10 ); + $lighter_hsla_array = $helper->rgba_to_hsla( $value_rgba_array, 20 ); + $dark_hsla_array = $helper->rgba_to_hsla( $value_rgba_array, -10 ); + $darker_hsla_array = $helper->rgba_to_hsla( $value_rgba_array, -20 ); + + $value_raw = str_replace( array( 'rgb(', ')' ), array( '', '' ), $value ); + $value_light = 'hsla(' . implode( ',', $light_hsla_array ) . ')'; + $value_lighter = 'hsla(' . implode( ',', $lighter_hsla_array ) . ')'; + $value_dark = 'hsla(' . implode( ',', $dark_hsla_array ) . ')'; + $value_darker = 'hsla(' . implode( ',', $darker_hsla_array ) . ')'; $contrast_color = $helper->get_luminance( $value ); - $lightness = abs( $contrast_color - $helper->get_luminance( $light ) ); - $darkness = abs( $contrast_color - $helper->get_luminance( $dark ) ); + $lightness = abs( $contrast_color - $helper->get_luminance( $light ) ); + $darkness = abs( $contrast_color - $helper->get_luminance( $dark ) ); $contrast_color = $lightness > $darkness ? 'light' : 'dark'; $contrast_color = "var(--{$contrast_color}-text)"; $inline_css .= "--{$property}:{$value};"; + $inline_css .= "--{$property}-light:{$value_light};"; + $inline_css .= "--{$property}-lighter:{$value_lighter};"; + $inline_css .= "--{$property}-dark:{$value_dark};"; + $inline_css .= "--{$property}-darker:{$value_darker};"; + $inline_css .= "--{$property}-raw:{$value_raw};"; $inline_css .= "--{$property}-text-contrast:{$contrast_color};"; + + $inline_css .= $helper->generate_hover_variables( $formatted_palette, $property, $value ); + $property2 = str_replace( '-', '', $property ); $additional_css .= ".{$property}-text-default, .{$property2}-text-default{color: var(--{$property}-text-contrast);}"; $additional_css .= ".{$property}-text-contrast, .{$property2}-text-contrast, .{$property}-text-contrast-hover:hover, .{$property2}-text-contrast-hover:hover, .{$property}-text-contrast-hover:focus, .{$property2}-text-contrast-hover:focus { color: var(--{$property}-text-contrast) !important;}"; diff --git a/src/includes/configs/customizer-options/colors.config.php b/src/includes/configs/customizer-options/colors.config.php index 249e5434c..71743e3c4 100644 --- a/src/includes/configs/customizer-options/colors.config.php +++ b/src/includes/configs/customizer-options/colors.config.php @@ -18,12 +18,6 @@ 'light_text' => '#ffffff', 'dark_text' => '#4d4d4d', 'settings' => array( - // Directory that contains SCSS files to be compiled. - 'scss_directory' => array( - 'framework_dir' => $bgtfw_configs['framework']['asset_dir'] . 'scss/custom-color', - 'default' => '/inc/boldgrid-theme-framework-config/scss', - ), - // After the helper compiles the css, where should the css be stored? 'output_css_name' => $bgtfw_configs['framework']['config_directory']['template'] . '/css/color-palettes.css', diff --git a/src/includes/configs/customizer/controls/dropdown.controls.php b/src/includes/configs/customizer/controls/dropdown.controls.php index 53dd901cb..7ec98d0d7 100644 --- a/src/includes/configs/customizer/controls/dropdown.controls.php +++ b/src/includes/configs/customizer/controls/dropdown.controls.php @@ -395,24 +395,24 @@ 'bgtfw_dropdown_footer_colors' => array( 'type' => 'bgtfw-dropdown-menu', 'transport' => 'postMessage', - 'label' => __( 'Background', 'crio' ), - 'active_label' => __( 'Footer Background', 'crio' ), + 'label' => __( 'Link Color', 'crio' ), + 'active_label' => __( 'Footer Links', 'crio' ), 'default' => false, 'settings' => 'bgtfw_dropdown_footer_colors', 'section' => 'bgtfw_footer_colors', 'priority' => -1, - 'help_label' => __( 'Tip - Changing Backgrounds', 'crio' ), + 'help_label' => __( 'Tip - Footer Link Colors', 'crio' ), 'help_text' => sprintf( - /* translators: %1$s = site name, %2$s = site tagline */ __( - 'After changing your Footer Colors, you may need to adjust your %2$sWidget%1$s colors. If you don’t see the color you want to use, please update your %3$sColor Palette%1$s. You may also want to change the %4$sFooter Design%1$s or %5$sSite Background%1$s.', + /* translators: %1$s = closing anchor, %2$s = Widgets link tags, %3$s = Menu link tags */ + 'The color of the links in your footer depend on their location inside your footer. + Attribution links can be changed here, however if the links are inside of a widget, + you will have to change them in the %2$sWidget%1$s panel. If the links are inside a menu, you will have to change them in the %3$sMenu%1$s panel.', 'crio' ), '', '', - '', - '', - '' + '', ), 'additional_controls' => array( array( @@ -421,29 +421,19 @@ 'focus_id' => 'widgets', ), array( - 'label' => __( 'Color Palette', 'crio' ), - 'focus_type' => 'section', - 'focus_id' => 'colors', - ), - array( - 'label' => __( 'Header Background', 'crio' ), - 'focus_type' => 'section', - 'focus_id' => 'header_image', - ), - array( - 'label' => __( 'Site Background', 'crio' ), - 'focus_type' => 'section', - 'focus_id' => 'background_image', + 'label' => __( 'Menu Design', 'crio' ), + 'focus_type' => 'panel', + 'focus_id' => 'bgtfw_menus_panel', ), ), 'faq_links' => array( array( - 'label' => __( 'Change the Site Background', 'crio' ), - 'url' => esc_url( 'https://www.boldgrid.com/support/boldgrid-crio-supertheme-product-guide/changing-your-site-background-in-boldgrid-crio/' ), + 'label' => __( 'Working With Widgets', 'crio' ), + 'url' => esc_url( 'https://www.boldgrid.com/support/boldgrid-crio-supertheme-product-guide/working-with-header-and-footer-widgets-in-boldgrid-crio/' ), ), array( - 'label' => __( 'Choose the Color Palette', 'crio' ), - 'url' => esc_url( 'https://www.boldgrid.com/support/boldgrid-crio-supertheme-product-guide/customizing-the-color-palette/' ), + 'label' => __( 'Changing the Menu Link Colors', 'crio' ), + 'url' => esc_url( 'https://www.boldgrid.com/support/boldgrid-crio-supertheme-product-guide/changing-the-menu-link-styles/' ), ), ), ), diff --git a/src/includes/configs/customizer/controls/footer-layout.controls.php b/src/includes/configs/customizer/controls/footer-layout.controls.php index 11795ca30..b2ba07d29 100644 --- a/src/includes/configs/customizer/controls/footer-layout.controls.php +++ b/src/includes/configs/customizer/controls/footer-layout.controls.php @@ -128,17 +128,19 @@ ), ), ), - 'bgtfw_footer_links' => array( + 'bgtfw_footer_link_color' => array( 'type' => 'bgtfw-palette-selector', 'transport' => 'postMessage', - 'settings' => 'bgtfw_footer_links', - 'label' => esc_attr__( 'Link Color', 'crio' ), + 'settings' => 'bgtfw_footer_link_color', + 'label' => esc_attr__( 'Attribution Link Colors', 'crio' ), + 'description' => esc_attr__( 'Change the color of your attribution links if shown.', 'crio' ), 'section' => 'bgtfw_footer_colors', 'priority' => 30, - 'default' => '', + 'default' => get_theme_mod( 'bgtfw_footer_links', '' ), 'choices' => array( - 'colors' => $bgtfw_formatted_palette, - 'size' => $bgtfw_palette->get_palette_size( $bgtfw_formatted_palette ), + 'selectors' => Boldgrid_Framework_Links::$footer_link_selectors, + 'colors' => $bgtfw_formatted_palette, + 'size' => $bgtfw_palette->get_palette_size( $bgtfw_formatted_palette ), ), 'sanitize_callback' => array( $bgtfw_color_sanitize, 'sanitize_palette_selector' ), ), diff --git a/src/includes/customizer/class-boldgrid-framework-customizer-colors.php b/src/includes/customizer/class-boldgrid-framework-customizer-colors.php index a1413b69f..0c21d751f 100644 --- a/src/includes/customizer/class-boldgrid-framework-customizer-colors.php +++ b/src/includes/customizer/class-boldgrid-framework-customizer-colors.php @@ -185,7 +185,7 @@ public function add_palette_controls() { 'default' => '', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', - 'transport' => 'refresh', + 'transport' => 'postMessage', ) ); $this->wp_customize->add_control( diff --git a/src/includes/customizer/class-boldgrid-framework-customizer-presets.php b/src/includes/customizer/class-boldgrid-framework-customizer-presets.php index 8fd9750bc..3a5d9bb0c 100644 --- a/src/includes/customizer/class-boldgrid-framework-customizer-presets.php +++ b/src/includes/customizer/class-boldgrid-framework-customizer-presets.php @@ -110,6 +110,21 @@ public function starter_content_defaults( $wp_customize ) { } } + /** + * Get logo notice + * + * @since 2.20.0 + * + * @return string Markup of notice + */ + public function get_logo_notice() { + return '

' + . esc_html__( 'Your header layout does not display a logo. ', 'crio' ) + . '' . esc_html__( 'Click Here', 'crio' ) + . ' ' . esc_html__( ' to display your logo.', 'crio' ) + . '

'; + } + /** * Get Branding Notices. * @@ -123,6 +138,11 @@ public function get_branding_notices() { . '' . esc_html__( 'Click Here', 'crio' ) . ' ' . esc_html__( ' to set your logo.', 'crio' ) . '

'; + $markup .= '

' + . esc_html__( 'Your header layout does not display a logo. ', 'crio' ) + . '' . esc_html__( 'Click Here', 'crio' ) + . ' ' . esc_html__( ' to display your logo.', 'crio' ) + . '

'; $markup .= '

' . esc_html__( 'You do not have a site title set. ', 'crio' ) . '' . esc_html__( 'Click Here', 'crio' ) diff --git a/src/includes/customizer/class-boldgrid-framework-customizer-widget-meta.php b/src/includes/customizer/class-boldgrid-framework-customizer-widget-meta.php index 022a485d6..814877703 100644 --- a/src/includes/customizer/class-boldgrid-framework-customizer-widget-meta.php +++ b/src/includes/customizer/class-boldgrid-framework-customizer-widget-meta.php @@ -445,7 +445,7 @@ public function get_sidebar_defaults( $sidebar_id, $type = false ) { $settings[ $sidebar_id ]['background_color'] = get_theme_mod( 'bgtfw_footer_color', $this->get_control_default( 'bgtfw_footer_color' ) ); } if ( empty( $settings[ $sidebar_id ]['links_color'] ) ) { - $settings[ $sidebar_id ]['links_color'] = get_theme_mod( 'bgtfw_footer_links', $this->get_control_default( 'bgtfw_footer_links' ) ); + $settings[ $sidebar_id ]['links_color'] = get_theme_mod( 'bgtfw_footer_link_color', $this->get_control_default( 'bgtfw_footer_link_color' ) ); } } diff --git a/src/includes/customizer/class-boldgrid-framework-customizer.php b/src/includes/customizer/class-boldgrid-framework-customizer.php index 82ab200b9..82b8225ab 100644 --- a/src/includes/customizer/class-boldgrid-framework-customizer.php +++ b/src/includes/customizer/class-boldgrid-framework-customizer.php @@ -838,6 +838,8 @@ public function customizer_reorganization( $wp_customize ) { if ( $wp_customize->get_setting( 'custom_logo' ) ) { $setting = $wp_customize->get_setting( 'custom_logo' ); + $control = $wp_customize->get_control( 'custom_logo' ); + $control->description = $this->presets->get_logo_notice(); $setting->transport = 'refresh'; } diff --git a/style.css b/style.css index e689d0407..53f87a20d 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Author: BoldGrid Theme URI: https://www.boldgrid.com/themes/crio/ Author URI: https://www.boldgrid.com/ Description: Crio is a WordPress SuperTheme that allows front-end designers, developers and other web professionals to create without bounds or restrictions. Crio's advanced customization options are completely integrated with the WordPress Customizer API, providing you with a powerful, but familiar interface to customize your website. Our integration gives you granular control over many elements straight from the Customizer, and even device previews so you can see how your site looks on different devices. Crio’s unique color palette system keeps colors consistent across your site. Drag and drop colors in your palette to increase or decrease the usage of that color throughout your website. Use the advanced controls to create a custom Header, Footer, or Blog Page layout. Be Bold and stand above the rest with Prime by BoldGrid! -Version: 2.19.2 +Version: 2.20.0 Requires at least: 5.5 Tested up to: 6.2 Requires PHP: 5.6