Skip to content

Instantly share code, notes, and snippets.

View nikola-wd's full-sized avatar
💭
Available for full-time hire. React or Custom WordPress theme development.

Nikola Ivanov nikola-wd

💭
Available for full-time hire. React or Custom WordPress theme development.
View GitHub Profile
@nikola-wd
nikola-wd / media_queries_snippet.scss
Last active April 12, 2020 19:41
[Media Queries Scss Mixin] - SASS Mixin #sass #scss #mixin
// Define the breakpoints
$breakpoint-small: 600px;
$breakpoint-med-small: 960px;
$breakpoint-med: 1175px;
@mixin screen($size, $type: max, $pixels: $breakpoint-small) {
@if $size == 'small' {
@media screen and ($type + -width: $breakpoint-small) {
@content;
@nikola-wd
nikola-wd / _scrim-gradient.scss
Created August 5, 2019 00:08
[Scrim Gradient Mixin] - Smooth fading box-shadow #scrim #box-shadow #scss #sass
// background: linear-gradient(
// hsl(359, 100%, 100%) 0%,
// hsla(359, 100%, 100%, 0.738) 19%,
// hsla(359, 100%, 100%, 0.541) 34%,
// hsla(359, 100%, 100%, 0.382) 47%,
// hsla(359, 100%, 100%, 0.278) 56.5%,
// hsla(359, 100%, 100%, 0.194) 65%,
// hsla(359, 100%, 100%, 0.126) 73%,
// hsla(359, 100%, 100%, 0.075) 80.2%,
// hsla(359, 100%, 100%, 0.042) 86.1%,
@nikola-wd
nikola-wd / _header.js
Created August 5, 2019 00:11
[Fixed Header onScroll] - Header get's class when scrolled #ui #sass #scss #code_bundles #header
const _headerFN = () => {
const $header = document.querySelector('.header');
const scrollTop = window.scrollY,
offsetTop = 60;
if (scrollTop >= offsetTop && window.innerWidth > 767) {
$header.classList.add('jsOnScroll');
document.body.classList.add('jsOnScroll-header');
} else {
@nikola-wd
nikola-wd / _family.scss
Created August 5, 2019 00:23
[Family SCSS Mixins] - Easily use nth selectors #scss #sass #mixin
/// Select all children from the first to `$num`.
/// @group with-arguments
/// @content [Write the style you want to apply to the children, and it will be added within the @content directive]
/// @param {number} $num - id of the child
@mixin first($num) {
@if $num == 1 {
&:first-child {
@content;
}
} @else {
@nikola-wd
nikola-wd / andy.scss
Last active August 5, 2019 02:10
[Useful SCSS Mixins 1] - Selection of useful SCSS mixins #scss #sass #mixin
/// Forces browsers to use hardware acceleration for transforms
/// @access public
/// @example scss - Usage
/// .foo {
/// @include ha;
/// }
/// @example css - Result
/// .foo {
/// -webkit-transform: translate3d(0, 0, 0);
/// -moz-transform: translate3d(0, 0, 0);
@nikola-wd
nikola-wd / stripHTMLTags.js
Created October 1, 2019 00:43
[stripHtmlTags] Helper FN that strips html tags #javascript #html #helper
export function removeHTMLTags (str) {
return str.replace(/<[^>]*>?/gm, '');
}
@nikola-wd
nikola-wd / debounce.js
Last active December 6, 2020 16:17
[debounce] Useful for not making requests on every key stroke for example #havascript #helper #optimization
// send req after a few seconds have passed since user last wrote in the editor
export default function debounce(a,b,c){
let d,e;
return function(){
function h(){
d=null;
c||(e=a.apply(f,g));
}
let f=this,g=arguments;
return (clearTimeout(d),d=setTimeout(h,b),c&&!d&&(e=a.apply(f,g)),e)
@nikola-wd
nikola-wd / wordpress.md
Created October 21, 2019 00:11 — forked from jermspeaks/wordpress.md
Resources collected for understanding Wordpress

Wordpress & PHP Resources

Background

I started this markdown file as a place to collect information about Wordpress and PHP when I started programming a Wordpress plugin for the first time. I decided to put out everything I could find in this gist. I will update it occassionally with code examples so I can track my progress in developing Wordpress plugins (or just the one I'm working on at work).

Wordpress 101

Wordpress Environment

@nikola-wd
nikola-wd / asyncLoop.js
Created November 15, 2019 18:16
[async loop] Loop with setTimeout #javascript #async
const waitFor = ms => new Promise(r => setTimeout(r, ms));
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
};
(async function() {
await asyncForEach([1, 2, 3], async num => {
@nikola-wd
nikola-wd / remove-woocommerce-styles-scripts.php
Created November 25, 2019 01:55 — forked from gregrickaby/remove-woocommerce-styles-scripts.php
Remove WooCommerce styles and scripts.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below into functions.php
/**
* Manage WooCommerce styles and scripts.
*/
function grd_woocommerce_script_cleaner() {
// Remove the generator tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );