Skip to content

Instantly share code, notes, and snippets.

@AlexanderChev
AlexanderChev / close.scss
Created April 12, 2018 19:46
стили для блока close
$size: 30px !default;
$toggler-part-height: 3px !default;
$toggler-part-bg-color: #000 !default;
.close {
$block-name: &; // #{$block-name}__element
position: relative;
z-index: 1;
@AlexanderChev
AlexanderChev / !readme.md
Created March 24, 2018 18:42
ST3 sync settings

Синхронизация настроек Sublime Text 3

%container {
display: block;
width: 960px;
margin: 0 auto;
padding: 0 10px;
}
%block-center {
position: absolute;
top: 50%;
@AlexanderChev
AlexanderChev / px2.scss
Created January 10, 2018 17:49
px2(rem,em) scss functions
$browser-context: $font-size--root;
@function rem($pixels, $context: $browser-context) {
@if (unitless($pixels)) {
$pixels: $pixels * 1px;
}
@if (unitless($context)) {
$context: $context * 1px;
}
@AlexanderChev
AlexanderChev / wp_bem_menu.php
Created January 7, 2018 13:08
wordpress BEM menu
<?php
/**
* Walker Texas Ranger
* Inserts some BEM naming sensibility into Wordpress menus
*/
class walker_texas_ranger extends Walker_Nav_Menu {
function __construct($css_class_prefix) {
$this->css_class_prefix = $css_class_prefix;
// Define menu item names appropriately
@AlexanderChev
AlexanderChev / animate.js
Created December 1, 2017 09:23
animation native js
function animate(from, to, speed) {
// if not an animation, just reposition
if (!speed) {
element.style.left = to + 'px';
return;
}
var start = +new Date();
@AlexanderChev
AlexanderChev / main.js
Created November 20, 2017 19:50
importAll
// Modules
var cache = {};
function importAll(r) {
r.keys().forEach(function(key) {
cache[ key ] = r(key);
});
}
importAll(require.context('../../modules/', true, /^[^\_]*\.js/));
@AlexanderChev
AlexanderChev / startjs
Created November 9, 2017 20:42
start-js
// Если на проекте jQuery
// $( document ).ready(function() {
// // code
// });
// Изоляция без jQuery
// (function(){
// // code
// }());
@AlexanderChev
AlexanderChev / _svg.pug
Created November 5, 2017 21:39
svg-mixin
//-
Include mixin to file:
include ../mixins/_svg
Syntax:
+icon(name, src, attrs)
Call:
+icon("cat") -> <svg ..class="icon-cat"><use xlink:href="#icon-cat"></use></svg>
+icon("cat", "../sprite.svg") -> <svg ..class="icon-dog"><use xlink:href="../sprite.svg#icon-dog"></use></svg>
@AlexanderChev
AlexanderChev / isMobile.js
Created November 5, 2017 10:56
isMobile runs quickly during initial page load to detect mobile devices
function isMobile() {
mobile = ['iphone', 'ipad', 'android', 'blackberry', 'nokia', 'opera mini', 'windows mobile'];
for (var i in mobile) if (navigator.userAgent.toLowerCase().indexOf(mobile[i]) > 0) return true;
return false;
}