This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* for mocking api with a timeout to test loadings | |
* | |
* @example | |
* | |
* const someEvent = async () => { | |
* try { | |
* await mock({mockedKey: '' } ,true, 1000); | |
* await mock({mockedKey: '' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@function strip-unit($num) { | |
@return $num / ($num * 0 + 1); | |
} | |
@function convert-to-rem($value, $base-value: $rem-base) { | |
$value: strip-unit($value) / strip-unit($base-value) * 1rem; | |
@if ($value == 0rem) { $value: 0; } // Turn 0rem into 0 | |
@return $value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts pixel size to rem and accepts the base as second argument. default base is 16px | |
* | |
* @param {number|string} px | |
* @param {number} base | |
* @return {string} | |
*/ | |
const remCalc = (px: number | string, base: number = 16) => { | |
const tempPx = `${px}`.replace('px', '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Smooth scroll to element (just modern browsers) | |
* @param {HTMLElement|String} elm | |
* @param options | |
* | |
* @example scrollTo('.element img'); | |
* @example scrollTo(document.getElementById('element')) | |
*/ | |
const scrollTo = (elm, options = { | |
offset: 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mounthList = ['فروردین','اردیبهشت','خرداد','تیر','مرداد','شهریور','مهر','آبان','آذر','دی','بهمن','اسفند'] | |
let mounthListCollection = [ | |
{value: 1,label: 'فروردین'}, | |
{value: 2,label: 'اردیبهشت'}, | |
{value: 3,label: 'خرداد'}, | |
{value: 4,label: 'تیر'}, | |
{value: 5,label: 'مرداد'}, | |
{value: 6,label: 'شهریور'}, | |
{value: 7,label: 'مهر'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get local storage item and return parsed object or array | |
* | |
* @param name | |
* @returns {any} | |
*/ | |
function getStorage(name) { | |
try { | |
if (localStorage.getItem(name)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get most repeated item in an array with help of this article | |
* https://stackoverflow.com/questions/1053843/ | |
* | |
* @param {Array} array | |
* @returns {*} | |
*/ | |
var getMostRepeatedItem: function (array) { | |
if(array.length === 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts a Latin number to its Persian numeral representation. | |
* | |
* @param {string|number} v - The input number or string to convert. | |
* @returns {string} - The Persian numeral representation of the input. | |
*/ | |
function toPersianNumber(v) { | |
const PersianNumber = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; | |
const vString = v.toString(); | |
const chars = vString.split('').map(char => /\d/.test(char) ? PersianNumber[char] : char); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
this snippet is handy when u need to use font sizes in em | |
this will compile to css like this | |
.fz-0-1em { | |
font-size: 0.1em; | |
} | |
and it will loop through to |