Skip to content

Commit

Permalink
Use GoDaddy ESLint config (godaddy-wordpress#708)
Browse files Browse the repository at this point in the history
* Use GoDaddy ESLint config

* Remove yarn-error.log

* Remove unused packages

* Bump GoDaddy eslint package

* Add missing package

* Bump GoDaddy eslint package

* Fix lint

* Update

Co-authored-by: Jonathan Bardo <[email protected]>
  • Loading branch information
jlemay-godaddy and jbardo-godaddy authored Nov 1, 2021
1 parent 993bc05 commit 76a7653
Show file tree
Hide file tree
Showing 22 changed files with 1,020 additions and 348 deletions.
11 changes: 6 additions & 5 deletions .dev/assets/admin/js/block-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ wp.domReady( function() {
/**
* Adds an 'Hide Page Title' toggle to the block editor 'Status & Visibility' section.
*
* @param {*} root0
* @param {*} root0.isEnabled
* @param {*} root0.onChange
* @return {Object} GoPageTitleToggle component.
*/
function GoPageTitleToggle( { isEnabled, onChange } ) {
Expand All @@ -31,10 +34,8 @@ function GoPageTitleToggle( { isEnabled, onChange } ) {
} );
} );

if ( 'page' !== wp.data.select('core/editor').getCurrentPostType() || ! GoBlockFilters.showPageTitles ) {

if ( 'page' !== wp.data.select( 'core/editor' ).getCurrentPostType() || ! GoBlockFilters.showPageTitles ) {
return null;

}

return (
Expand All @@ -44,8 +45,8 @@ function GoPageTitleToggle( { isEnabled, onChange } ) {
</label>
<FormToggle
checked={ isEnabled }
onChange={ () => onChange( ! isEnabled ) }
id="hide-page-title-toggle"
onChange={ () => onChange( ! isEnabled ) }
/>
</PluginPostStatusInfo>
);
Expand All @@ -59,7 +60,7 @@ GoPageTitleToggle.propTypes = {
registerPlugin( 'go-page-title-toggle', {
icon: 'hidden',
render: compose(
withSelect( (select) => {
withSelect( ( select ) => {
const isPageTitleHidden = () => {
const { getEditedPostAttribute } = select( 'core/editor' );
const meta = getEditedPostAttribute( 'meta' );
Expand Down
25 changes: 11 additions & 14 deletions .dev/assets/admin/js/customize-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@ import './customize/controls/set-active-color-schemes';
*/

( function() {

wp.customize.bind( 'ready', function () {

wp.customize.bind( 'ready', function() {
/**
* Function to hide/show Customizer options, based on another control.
*
* Parent option, Affected Control, Value which affects the control.
*
* @param {String} parentSetting The setting that will toggle the display of the control.
* @param {String} affectedControl The control that will be toggled.
* @param {Array} values The values the parentSetting must have for the affectedControl to be displayed.
* @param {Integer} speed The speed of the toggle animation.
* @param {string} parentSetting The setting that will toggle the display of the control.
* @param {string} affectedControl The control that will be toggled.
* @param {Array} values The values the parentSetting must have for the affectedControl to be displayed.
* @param {number} speed The speed of the toggle animation.
*/
function customizerOptionDisplay( parentSetting, affectedControl, values, speed = 100 ) {
wp.customize( parentSetting, function( setting ) {
wp.customize.control( affectedControl, function ( control ) {
wp.customize.control( affectedControl, function( control ) {
/**
* Toggle the visibility of a control.
*/
Expand All @@ -47,13 +45,13 @@ import './customize/controls/set-active-color-schemes';
*
* Parent option, Affected Control, Value which affects the control.
*
* @param {String} parentSetting The setting that will toggle the display of the control.
* @param {String} affectedControl The control that will be toggled.
* @param {Integer} speed The speed of the toggle animation.
* @param {string} parentSetting The setting that will toggle the display of the control.
* @param {string} affectedControl The control that will be toggled.
* @param {number} speed The speed of the toggle animation.
*/
function customizerImageOptionDisplay( parentSetting, affectedControl, speed = 100 ) {
wp.customize( parentSetting, function( setting ) {
wp.customize.control( affectedControl, function ( control ) {
wp.customize.control( affectedControl, function( control ) {
/**
* Toggle the visibility of a control.
*/
Expand Down Expand Up @@ -83,5 +81,4 @@ import './customize/controls/set-active-color-schemes';
customizerImageOptionDisplay( 'custom_logo', 'logo_width' );
customizerImageOptionDisplay( 'custom_logo', 'logo_width_mobile' );
} );

} )( jQuery );
}( jQuery ) );
4 changes: 2 additions & 2 deletions .dev/assets/admin/js/customize-preview.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ColorSchemePreview from './customize/preview/color-schemes';
import DesignStylePreview from './customize/preview/design-style';
import HeaderColorsPreview from './customize/preview/header';
import FooterColorsPreview from './customize/preview/footer';
import ColorSchemePreview from './customize/preview/color-schemes';
import HeaderColorsPreview from './customize/preview/header';
import LogoSizingPreview from './customize/preview/logo-sizing';
import PageTitlesPreview from './customize/preview/page-titles';

Expand Down
12 changes: 5 additions & 7 deletions .dev/assets/admin/js/customize/controls/range-control.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
( function ( $, api ) {

api.bind( 'ready', function () {
$( '.range_control__reset' ).on( 'click', function () {
( function( $, api ) {
api.bind( 'ready', function() {
$( '.range_control__reset' ).on( 'click', function() {
const rangeContainer = $( this ).parent();

const rangeInput = rangeContainer.find( 'input[data-input-type="range"]' );
const rangeInput = rangeContainer.find( 'input[data-input-type="range"]' );
const controlValue = rangeContainer.find( '.range_control__value' );

const defaultValue = rangeInput.data( 'default-value' );
Expand All @@ -17,5 +16,4 @@
wp.customize.control( customizeSetting ).setting.set( defaultValue );
} );
} );

} )( jQuery, wp.customize );
}( jQuery, wp.customize ) );
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
( function ( $ ) {

/* eslint-disable-next-line no-unused-vars */
( function( $ ) {
jQuery.wp.wpColorPicker.prototype.options.palettes = goCustomizerControls.activeColorScheme;

wp.customize( 'color_scheme', ( value ) => {
value.bind( ( to ) => {
// 0: design style (eg: modern)
// 1: color scheme (eg: one, two, three, four etc.)
let colorSchemeData = to.split( '-' );
if ( colorSchemeData.legnth < 2 || ! goCustomizerControls.availableDesignStyles.hasOwnProperty( colorSchemeData[0] ) || ! goCustomizerControls.availableDesignStyles[ colorSchemeData[0] ]['color_schemes'].hasOwnProperty( colorSchemeData[1] ) ) {
const colorSchemeData = to.split( '-' );
if ( colorSchemeData.legnth < 2 || ! goCustomizerControls.availableDesignStyles.hasOwnProperty( colorSchemeData[ 0 ] ) || ! goCustomizerControls.availableDesignStyles[ colorSchemeData[ 0 ] ].color_schemes.hasOwnProperty( colorSchemeData[ 1 ] ) ) {
return;
}
let colorScheme = goCustomizerControls.availableDesignStyles[ colorSchemeData[0] ]['color_schemes'][ colorSchemeData[1] ];
const colorScheme = goCustomizerControls.availableDesignStyles[ colorSchemeData[ 0 ] ].color_schemes[ colorSchemeData[ 1 ] ];
if ( colorScheme.hasOwnProperty( 'label' ) ) {
delete( colorScheme['label'] );
delete ( colorScheme.label );
}
jQuery.wp.wpColorPicker.prototype.options.palettes = Object.values( colorScheme );
} );
} );

} )( jQuery );
}( jQuery ) );
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const SwitcherControl = wp.customize.Control.extend( {
this.container.on( 'change', 'input:radio', function() {
control.setting.set( this.value );
} );
}
},
} );

export default SwitcherControl;
24 changes: 15 additions & 9 deletions .dev/assets/admin/js/customize/preview/color-schemes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { hexToHSL } from '../util';

const $ = jQuery; // eslint-disable-line
const $ = jQuery;

export default () => {
let selectedDesignStyle = GoPreviewData.selectedDesignStyle;
Expand All @@ -9,18 +9,21 @@ export default () => {
* Set color
*
* @param {*} color
* @param {*} cssVar
*/
const setColor = ( color, cssVar ) => {
const hsl = hexToHSL( color );
document.querySelector( ':root' ).style.setProperty( `${cssVar}`, `hsl(${hsl[ 0 ]}, ${hsl[ 1 ]}%, ${hsl[ 2 ]}%)` );
document.querySelector( ':root' ).style.setProperty( `${ cssVar }`, `hsl(${ hsl[ 0 ] }, ${ hsl[ 1 ] }%, ${ hsl[ 2 ] }%)` );
};

/**
* Load the color schemes for the selected design style.
*
* @param {*} colorScheme
*/
const loadColorSchemes = ( colorScheme ) => {
const designStyle = getDesignStyle( selectedDesignStyle );
colorScheme = colorScheme.replace( `${selectedDesignStyle}-`, '' );
colorScheme = colorScheme.replace( `${ selectedDesignStyle }-`, '' );

if ( 'undefined' !== typeof designStyle.color_schemes[ colorScheme ] && 'undefined' !== typeof wp.customize.settings.controls ) {
const colors = designStyle.color_schemes[ colorScheme ];
Expand All @@ -31,6 +34,7 @@ export default () => {
}, 200 );

Object.entries( wp.customize.settings.controls )
// eslint-disable-next-line no-unused-vars
.filter( ( [ _control, config ] ) => config.type === 'color' )
.forEach( ( [ customizerControl, config ] ) => {
const customizerSetting = wp.customize( config.settings.default );
Expand All @@ -51,14 +55,16 @@ export default () => {
*/
const toggleColorSchemes = () => {
$( 'label[for^=color_scheme_control]' ).hide();
$( `label[for^=color_scheme_control-${selectedDesignStyle}-]` ).show();
$( `label[for^=color_scheme_control-${ selectedDesignStyle }-]` ).show();
};

/**
* Update the viewport basis for the selected design style.
*
* @param {*} designStyle
*/
const updateViewportBasis = ( designStyle ) => {
let viewportBasis = ( 'undefined'!== typeof designStyle.viewport_basis ) ? designStyle.viewport_basis : '950';
const viewportBasis = ( 'undefined' !== typeof designStyle.viewport_basis ) ? designStyle.viewport_basis : '950';
wp.customize.control( 'viewport_basis' ).setting( viewportBasis );
};

Expand All @@ -69,10 +75,10 @@ export default () => {
*/
const getDesignStyle = ( designStyle ) => {
if (
'undefined' !== typeof GoPreviewData['design_styles'] &&
'undefined' !== GoPreviewData['design_styles'][ designStyle ]
'undefined' !== typeof GoPreviewData.design_styles &&
'undefined' !== GoPreviewData.design_styles[ designStyle ]
) {
return GoPreviewData['design_styles'][ designStyle ];
return GoPreviewData.design_styles[ designStyle ];
}

return false;
Expand All @@ -85,7 +91,7 @@ export default () => {
value.bind( ( to ) => {
selectedDesignStyle = to;
loadColorSchemes( 'one' );
$( `#color_scheme_control-${selectedDesignStyle}-one` ).prop( 'checked', true );
$( `#color_scheme_control-${ selectedDesignStyle }-one` ).prop( 'checked', true );
} );
} );

Expand Down
12 changes: 5 additions & 7 deletions .dev/assets/admin/js/customize/preview/design-style.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
const $ = jQuery; // eslint-disable-line
const $ = jQuery;

export default () => {
wp.customize( 'design_style', ( value ) => {
value.bind( ( to ) => {

$( '#customize-preview' ).addClass( 'is-loading' );

if (
'undefined' !== typeof GoPreviewData['design_styles'] &&
'undefined' !== GoPreviewData['design_styles'][ to ]
'undefined' !== typeof GoPreviewData.design_styles &&
'undefined' !== GoPreviewData.design_styles[ to ]
) {

setTimeout( function() {
const designStyle = GoPreviewData['design_styles'][ to ];
$( 'link[id*="design-style"]' ).attr( 'href', designStyle['url'] );
const designStyle = GoPreviewData.design_styles[ to ];
$( 'link[id*="design-style"]' ).attr( 'href', designStyle.url );

setTimeout( function() {
$( '#customize-preview' ).removeClass( 'is-loading' );
Expand Down
33 changes: 17 additions & 16 deletions .dev/assets/admin/js/customize/preview/footer.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { hexToHSL } from '../util';

const $ = jQuery; // eslint-disable-line
const $ = jQuery;

$( document ).ready( setMenuLocationDescription );

export default () => {
wp.customize( 'footer_variation', ( value ) => {
value.bind( ( to ) => {
$( 'body' ).removeClass( 'has-footer-1 has-footer-2 has-footer-3 has-footer-4' )
.addClass( 'has-' + to );
$( 'body' )
.removeClass( 'has-footer-1 has-footer-2 has-footer-3 has-footer-4' )
.addClass( 'has-' + to );
setMenuLocationDescription();
} );
} );
Expand All @@ -22,7 +23,7 @@ export default () => {
wp.customize( 'footer_background_color', ( value ) => {
value.bind( ( to ) => {
const hsl = hexToHSL( to );
const setTo = to ? `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)` : undefined;
const setTo = to ? `hsl(${ hsl[ 0 ] }, ${ hsl[ 1 ] }%, ${ hsl[ 2 ] }%)` : undefined;
document.querySelector( ':root' ).style.setProperty( '--go-footer--color--background', setTo );

// Add class if a background color is applied.
Expand All @@ -39,15 +40,15 @@ export default () => {
wp.customize( 'social_icon_color', ( value ) => {
value.bind( ( to ) => {
const hsl = hexToHSL( to );
const setTo = to ? `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)` : undefined;
const setTo = to ? `hsl(${ hsl[ 0 ] }, ${ hsl[ 1 ] }%, ${ hsl[ 2 ] }%)` : undefined;
document.querySelector( ':root' ).style.setProperty( '--go-social--color--text', setTo );
} );
} );

wp.customize( 'footer_text_color', ( value ) => {
value.bind( ( to ) => {
const hsl = hexToHSL( to );
const setTo = to ? `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)` : undefined;
const setTo = to ? `hsl(${ hsl[ 0 ] }, ${ hsl[ 1 ] }%, ${ hsl[ 2 ] }%)` : undefined;
document.querySelector( ':root' ).style.setProperty( '--go-footer--color--text', setTo );
document.querySelector( ':root' ).style.setProperty( '--go-footer-navigation--color--text', setTo );
} );
Expand All @@ -56,7 +57,7 @@ export default () => {
wp.customize( 'footer_heading_color', ( value ) => {
value.bind( ( to ) => {
const hsl = hexToHSL( to );
const setTo = to ? `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)` : null;
const setTo = to ? `hsl(${ hsl[ 0 ] }, ${ hsl[ 1 ] }%, ${ hsl[ 2 ] }%)` : null;
document.querySelector( ':root' ).style.setProperty( '--go-footer-heading--color--text', setTo );
} );
} );
Expand Down Expand Up @@ -101,15 +102,15 @@ export default () => {
} );
} );

wp.customize('social_icon_xing', function (value) {
value.bind(function (to) {
if (to) {
$('.social-icon-xing').removeClass('display-none');
wp.customize( 'social_icon_xing', function( value ) {
value.bind( function( to ) {
if ( to ) {
$( '.social-icon-xing' ).removeClass( 'display-none' );
} else {
$('.social-icon-xing').addClass('display-none');
$( '.social-icon-xing' ).addClass( 'display-none' );
}
});
});
} );
} );

wp.customize( 'social_icon_pinterest', ( value ) => {
value.bind( ( to ) => {
Expand Down Expand Up @@ -153,7 +154,7 @@ export default () => {
};

function setMenuLocationDescription() {
var menuLocationsDescription = $( '.customize-section-title-menu_locations-description' ).text(),
menuLocationCount = [ 'footer-1', 'footer-2' ].includes( wp.customize( 'footer_variation' ).get() ) ? '2' : '4';
const menuLocationsDescription = $( '.customize-section-title-menu_locations-description' ).text();
const menuLocationCount = [ 'footer-1', 'footer-2' ].includes( wp.customize( 'footer_variation' ).get() ) ? '2' : '4';
$( '.customize-section-title-menu_locations-description' ).text( menuLocationsDescription.replace( /[0-9]/g, menuLocationCount ) );
}
11 changes: 6 additions & 5 deletions .dev/assets/admin/js/customize/preview/header.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { hexToHSL } from '../util';

const $ = jQuery; // eslint-disable-line
const $ = jQuery;

export default () => {
wp.customize( 'header_variation', ( value ) => {
value.bind( ( to ) => {
$( 'body' ).removeClass( 'has-header-1 has-header-2 has-header-3 has-header-4 has-header-5 has-header-6 has-header-7' )
.addClass( 'has-' + to );
$( 'body' )
.removeClass( 'has-header-1 has-header-2 has-header-3 has-header-4 has-header-5 has-header-6 has-header-7' )
.addClass( 'has-' + to );
} );
} );

wp.customize( 'header_background_color', ( value ) => {
value.bind( ( to ) => {
const hsl = hexToHSL( to );
const setTo = to ? `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)` : undefined ;
const setTo = to ? `hsl(${ hsl[ 0 ] }, ${ hsl[ 1 ] }%, ${ hsl[ 2 ] }%)` : undefined;
document.querySelector( ':root' ).style.setProperty( '--go-header--color--background', setTo );

// Add class if a background color is applied.
Expand All @@ -28,7 +29,7 @@ export default () => {
wp.customize( 'header_text_color', ( value ) => {
value.bind( ( to ) => {
const hsl = hexToHSL( to );
const setTo = to ? `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)` : undefined ;
const setTo = to ? `hsl(${ hsl[ 0 ] }, ${ hsl[ 1 ] }%, ${ hsl[ 2 ] }%)` : undefined;
document.querySelector( ':root' ).style.setProperty( '--go-navigation--color--text', setTo );
document.querySelector( ':root' ).style.setProperty( '--go-site-description--color--text', setTo );
document.querySelector( ':root' ).style.setProperty( '--go-search-button--color--text', setTo );
Expand Down
Loading

0 comments on commit 76a7653

Please sign in to comment.