Skip to content

Commit

Permalink
Run precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
imranhsayed committed Oct 11, 2020
1 parent b33f109 commit 2e5897c
Show file tree
Hide file tree
Showing 18 changed files with 152 additions and 86 deletions.
5 changes: 1 addition & 4 deletions assets/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "stylelint-config-wordpress",
"extends": "stylelint-config-wordpress/scss",
"ignoreFiles": "",
"rules": {
"at-rule-empty-line-before": null,
Expand All @@ -17,14 +17,11 @@
"max-empty-lines": 1,
"no-missing-end-of-source-newline": true,
"number-leading-zero": "always",
"property-case": "lower",
"rule-empty-line-before": null,
"selector-combinator-space-after": "always",
"selector-list-comma-newline-after": null,
"selector-max-specificity": "0,3,1",
"selector-pseudo-element-case": "lower",
"selector-pseudo-element-colon-notation": "double",
"unit-case": "lower",
"unit-no-unknown": true
}
}
2 changes: 1 addition & 1 deletion assets/build/assets.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('js/main.js' => array('dependencies' => array('wp-polyfill'), 'version' => '73fb28ff703d908abc937ac7acfe42fa'), 'js/single.js' => array('dependencies' => array('wp-polyfill'), 'version' => 'c189330732d608ff3f48cf8c50f11401'), 'js/editor.js' => array('dependencies' => array('wp-polyfill'), 'version' => '3c891e7ba6513ceb778c1ed337bc2952'), 'js/blocks.js' => array('dependencies' => array('lodash', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-polyfill'), 'version' => 'c001b0eb0e00ad82a5f5f4ede2bbc8a9'));
<?php return array('js/main.js' => array('dependencies' => array('wp-polyfill'), 'version' => '4698e5181087a60922655b73ad40a101'), 'js/single.js' => array('dependencies' => array('wp-polyfill'), 'version' => 'c189330732d608ff3f48cf8c50f11401'), 'js/editor.js' => array('dependencies' => array('wp-polyfill'), 'version' => '12ab3e60bdb8114ca8c19cb2ab3fe043'), 'js/blocks.js' => array('dependencies' => array('lodash', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-polyfill'), 'version' => '08397384479650a051a6ec0cb1127672'));
2 changes: 1 addition & 1 deletion assets/build/js/blocks.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 35 additions & 12 deletions assets/src/js/clock/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
( function ( $ ) {
/**
* Clock Class.
*/
class Clock {
/**
* Constructor
*/
constructor() {
this.initializeClock();
}

/**
* initializeClock
*/
initializeClock() {
let t = setInterval( () => this.time(), 1000 );
setInterval( () => this.time(), 1000 );
}

/**
* Numpad
*
* @param {String} str String
*
* @return {string} String
*/
numPad( str ) {
let cStr = str.toString();
const cStr = str.toString();
if ( 2 > cStr.length ) {
str = 0 + cStr;
}
return str;
}

/**
* Time
*/
time() {
let currDate = new Date();
let currSec = currDate.getSeconds();
let currMin = currDate.getMinutes();
let curr24Hr = currDate.getHours();
let ampm = 12 <= curr24Hr ? 'pm' : 'am';
let currHr = curr24Hr % 12;
currHr = currHr ? currHr : 12;
const currDate = new Date();
const currSec = currDate.getSeconds();
const currMin = currDate.getMinutes();
const curr24Hr = currDate.getHours();
const ampm = 12 <= curr24Hr ? 'pm' : 'am';
let currHr = curr24Hr % 12;
currHr = currHr ? currHr : 12;

let stringTime = currHr + ':' + this.numPad( currMin ) + ':' + this.numPad( currSec );
const stringTime =
currHr +
':' +
this.numPad( currMin ) +
':' +
this.numPad( currSec );
const timeEmojiEl = $( '#time-emoji' );

if ( 5 <= curr24Hr && 17 >= curr24Hr ) {
Expand All @@ -40,5 +64,4 @@
}

new Clock();

} ( jQuery ) );
} )( jQuery );
8 changes: 6 additions & 2 deletions assets/src/js/gutenberg/blocks/dos-and-donts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ const INNER_BLOCKS_TEMPLATE = [
'core/group',
{
className: 'aquila-dos-and-donts__group',
backgroundColor: 'pale-cyan-blue'
backgroundColor: 'pale-cyan-blue',
},
blockColumns,
],
];

const ALLOWED_BLOCKS = [ 'core/group' ];

/**
* Edit function.
*
* @return {Object} Content.
*/
const Edit = () => {

return (
<div className="aquila-dos-and-donts">
<InnerBlocks
Expand Down
11 changes: 8 additions & 3 deletions assets/src/js/gutenberg/blocks/dos-and-donts/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Do's and don'ts block.
*
* @package Aquila
* @package
*/

/**
Expand All @@ -25,7 +25,7 @@ registerBlockType( 'aquila-blocks/dos-and-donts', {
*
* @type {string}
*/
title: __( 'Dos and dont\'s', 'aquila' ),
title: __( "Dos and dont's", 'aquila' ),

/**
* Block icon.
Expand All @@ -50,10 +50,15 @@ registerBlockType( 'aquila-blocks/dos-and-donts', {

edit: Edit,

/**
* Save
*
* @return {Object} Save content.
*/
save() {
return (
<div className="aquila-dos-and-donts">
<InnerBlocks.Content/>
<InnerBlocks.Content />
</div>
);
},
Expand Down
20 changes: 10 additions & 10 deletions assets/src/js/gutenberg/blocks/dos-and-donts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @param {String} optionVal Option
* @param {String} colClassName ClassName
* @param {String} heading Heading
* @returns {Array} Block column.
* @return {Array} Block column.
*/
const getBlockColumn = ( optionVal, colClassName, heading ) => {
return [
Expand All @@ -16,14 +16,11 @@ const getBlockColumn = ( optionVal, colClassName, heading ) => {
{
className: 'aquila-dos-and-donts__heading',
option: optionVal,
content: `<strong><span>${heading}</span></strong>`
content: `<strong><span>${ heading }</span></strong>`,
},
],
[
'core/list',
{ className: 'aquila-dos-and-donts__list' },
]
]
[ 'core/list', { className: 'aquila-dos-and-donts__list' } ],
],
];
};

Expand All @@ -32,11 +29,14 @@ export const blockColumns = [
'core/columns',
{
className: 'aquila-dos-and-donts__cols',
width: 49
},
[
getBlockColumn( 'dos', 'aquila-dos-and-donts__col-one', 'Dos' ),
getBlockColumn( 'donts', 'aquila-dos-and-donts__col-two', 'Dont\'s' )
]
getBlockColumn(
'donts',
'aquila-dos-and-donts__col-two',
"Dont's"
),
],
],
];
50 changes: 23 additions & 27 deletions assets/src/js/gutenberg/blocks/heading-with-icon/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,52 @@
* Internal Dependencies.
*/
import { getIconComponent } from './icons-map';
import { RichText } from '@wordpress/block-editor';

/**
* WordPress Dependencies.
*/
import {
PanelBody,
RadioControl,
} from '@wordpress/components';
import { PanelBody, RadioControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
import { RichText, InspectorControls } from '@wordpress/block-editor';

const Edit = ( { className, attributes, setAttributes } ) => {
/**
* Edit
*
* @param {Object} props Props.
*
* @return {Object} Content.
*/
const Edit = ( props ) => {
const { className, attributes, setAttributes } = props;
const { option, content } = attributes;

const HeadingIcon = getIconComponent( option );

return (
<div className="aquila-icon-heading">
<span className="aquila-icon-heading__heading">
<HeadingIcon/>
</span>
{/* You can also pass formattingControls={ [ 'bold', 'italic' ] } to allow the content to be made bold or italic, but do not allow other formatting options */}
<span className="aquila-icon-heading__heading">
<HeadingIcon />
</span>
{ /* You can also pass formattingControls={ [ 'bold', 'italic' ] } to allow the content to be made bold or italic, but do not allow other formatting options */ }
<RichText
tagName="h4" // The tag here is the element output and editable in the admin
className={ className }
value={ content } // Any existing content, either from the database or an attribute default
onChange={ ( content ) => setAttributes( { content } ) } // Store updated content as a block attribute
placeholder={ __( 'Heading...', 'aquila' ) } // Display this text before any content has been added by the user
onChange={ ( contentVal ) => setAttributes( { contentVal } ) } // Store updated content as a block attribute
placeholder={ __( 'Heading', 'aquila' ) } // Display this text before any content has been added by the user
/>
<InspectorControls>
<PanelBody
title={ __( 'Block Settings', 'aquila' ) }
>
<PanelBody title={ __( 'Block Settings', 'aquila' ) }>
<RadioControl
label={ __(
'Select the icon',
'aquila'
) }
help={ __(
'Controls icon selection',
'aquila'
) }
label={ __( 'Select the icon', 'aquila' ) }
help={ __( 'Controls icon selection', 'aquila' ) }
selected={ option }
options={ [
{ label: 'Dos', value: 'dos' },
{ label: 'Dont\'s', value: 'donts' },
{ label: "Dont's", value: 'donts' },
] }
onChange={ ( option ) => {
setAttributes( { option } );
onChange={ ( optionVal ) => {
setAttributes( { optionVal } );
} }
/>
</PanelBody>
Expand Down
13 changes: 11 additions & 2 deletions assets/src/js/gutenberg/blocks/heading-with-icon/icons-map.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import * as SvgIcons from '../../../icons';
import { isEmpty } from 'lodash';

/**
* Get icon component.
*
* @param {String} option Option.
*
* @return {*|SvgCheck} SVG Component.
*/
export const getIconComponent = ( option ) => {
const IconsMap = {
dos: SvgIcons.Check,
donts: SvgIcons.Cross
donts: SvgIcons.Cross,
};

return ( ! isEmpty( option ) && ( option in IconsMap ) ) ? IconsMap[option] : IconsMap.dos;
return ! isEmpty( option ) && option in IconsMap
? IconsMap[ option ]
: IconsMap.dos;
};
Loading

0 comments on commit 2e5897c

Please sign in to comment.