Skip to content

Instantly share code, notes, and snippets.

View delphinpro's full-sized avatar

Сергей delphinpro

View GitHub Profile
/*==
*== Hexagon
*== ======================================= ==*/
$hexagon-size: 184px;
$sin60: 0.86602540;
$hexagon-height: $hexagon-size / $sin60;
.hexagon {
&, * { transition: 0.3s linear; }
function hasClass(el, className) {
if (el.classList) {
return el.classList.contains(className);
} else {
return !!el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
}
}
function addClass(el, className) {
if (el.classList) {
@function em($from, $to, $dimension: true) {
@return ($from / $to) * if($dimension, 1em, 1);
}
@function rem($px, $root: 16px) {
@return ($px / $root) * 1rem;
}
@mixin font($font-size, $line-height: null) {
font-size: rem($font-size);
@delphinpro
delphinpro / Build.md
Created November 9, 2017 22:43 — forked from robertknight/Build.md
Minimal Webpack DllPlugin example

Compile with:

webpack --config vendor.webpack.config.js
webpack --config app.webpack.config.js

Use with the following index.html

@delphinpro
delphinpro / viewport.js
Created June 19, 2017 19:11
Conditional meta viewport
/*
* Paste into the end <head>
*/
(function(){
var width = screen.width;
var oldViewport = document.querySelector('meta[name="viewport"]');
var viewport = document.createElement('meta');
viewport.setAttribute('name', 'viewport');
viewport.setAttribute('content', 'width=' + (width <= 640 ? '640' : 'device-width'));
document.head.replaceChild(viewport, oldViewport);
@delphinpro
delphinpro / phone-validator.js
Created April 27, 2017 11:51
Phone numer validator for jQuery Form Validator (http://www.formvalidator.net/)
$.formUtils.addValidator({
name : 'tel',
validatorFunction: function (value, $el, config, language, $form) {
return /^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/.test(value);
},
errorMessage : 'Please enter a valid phone number',
errorMessageKey : 'badTel'
});
@delphinpro
delphinpro / _str-replace.scss
Created April 2, 2017 09:18
String replace function for SASS
/// Replace `$search` with `$replace` in `$string`
/// @author Hugo Giraudel
/// @param {String} $string - Initial string
/// @param {String} $search - Substring to replace
/// @param {String} $replace ('') - New value
/// @return {String} - Updated string
@function str-replace($string, $search, $replace: '') {
$index: str_index($string, $search);
@if $index {
@mixin webkit-scrollbar($color, $background: transparent, $size: 3px) {
&::-webkit-scrollbar {
width: $size;
height: $size;
}
&::-webkit-scrollbar-button {
display: none;
//background: none;
//size: $size;
//height: $size;
@delphinpro
delphinpro / _dev-grid.scss
Last active November 16, 2016 13:39
displays overlay with bootstrap-grid
$screen-xs-min: 480px !default;
$screen-sm-min: 768px !default;
$screen-md-min: 992px !default;
$screen-lg-min: 1200px !default;
$grid-gutter-width: 30px !default;
$dev-grid-style: guides !default;
$dev-grid-style: false !default;
$dev-grid-show-center-guides: true !default;
$dev-grid-show-label: true !default;
@delphinpro
delphinpro / bootstrap-multiple-modals.js
Created October 17, 2016 19:27
Multiple modals in bootstrap
$(document).on('hidden.bs.modal', '.modal', function () {
$('.modal:visible').length && $(document.body).addClass('modal-open');
});