Skip to content

Instantly share code, notes, and snippets.

View vadimbogomazov's full-sized avatar

Vadim Bogomazov vadimbogomazov

View GitHub Profile
@vadimbogomazov
vadimbogomazov / decl-of-num.js
Last active September 2, 2020 14:48
Get declination of number
/**
* Get declination of number
* @param {Number} number – current number
* @param {Array} words – words array
* @return {String}
*/
export const declOfNum = (number, words) => words[(number % 100 > 4 && number % 100 < 20) ? 2 : [2, 0, 1, 1, 1, 2][(number % 10 < 5) ? number % 10 : 5]];
@vadimbogomazov
vadimbogomazov / iphone-media-queries.scss
Created November 29, 2019 13:31
iPhone media queries
@mixin iphoneXR() {
@media only screen
and (device-width: 414px)
and (device-height: 896px)
and (-webkit-device-pixel-ratio: 2) {
@content;
}
}
@mixin iphoneXS() {
@vadimbogomazov
vadimbogomazov / random-integer.js
Created October 18, 2019 04:28
Get random integer
/**
* Get random integer
* @param {Number} min – min integer number
* @param {Number} max – max integer number
* @return {Number}
*/
export const randomInteger = (min, max) => {
const rand = min - 0.5 + Math.random() * (max - min + 1);
return Math.round(rand);
@vadimbogomazov
vadimbogomazov / visually-hidden.css
Last active November 29, 2019 13:32
Visuallyhidden css class
.visually-hidden:not(:focus):not(:active) {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
clip-path: inset(100%);
clip: rect(0 0 0 0);
@vadimbogomazov
vadimbogomazov / font-face.scss
Last active October 11, 2019 11:15
Font face SCSS mixin
@mixin font-face($family, $src, $style: normal, $weight: 400, $display: swap) {
@font-face {
font-family: $family;
src: url('#{$src}.woff2') format('woff2'),
url('#{$src}.woff') format('woff');
font-style: $style;
font-weight: $weight;
font-display: $display;
}
}
@vadimbogomazov
vadimbogomazov / disable-convert-phone-to-links-mobile.html
Last active October 17, 2019 17:57
Disable convert phone to links in mobiles
@vadimbogomazov
vadimbogomazov / is-object.js
Last active October 17, 2019 17:57
Check object function
/**
* Check object function
* @param {val}
* @return {Boolean}
*/
export const isObject = val => {
if (val === null) {
return false;
}
@vadimbogomazov
vadimbogomazov / scrollbar-width.js
Last active October 17, 2019 17:56
Get browser scrollbar width
/**
* Get browser scrollbar width
* @return {Number}
*/
export const getScrollbarWidth = () => {
const div = document.createElement('div');
div.style.cssText = `
height: 100px;
overflow: scroll;