This file contains hidden or 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
* { | |
box-sizing: border-box; | |
} | |
.ldPmWA { | |
position: relative; | |
margin: auto; | |
width: 370px; | |
border-radius: 30px; | |
box-shadow: rgb(85 85 85) 0px 0px 2.4em inset; |
This file contains hidden or 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
import axios, { AxiosResponse } from 'axios'; | |
import { PostType } from '../models/post.interface'; | |
const instance = axios.create({ | |
baseURL: 'http://jsonplaceholder.typicode.com/', | |
timeout: 15000, | |
}); | |
const responseBody = (response: AxiosResponse) => response.data; |
This file contains hidden or 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
export function orderListByBooleanProperty({ list = [], propertyName = '', asc = true }) { | |
const immutableList = [...list]; | |
const sortedList = [...immutableList].sort(function (a, b) { | |
return asc ? a[propertyName] - b[propertyName] : b[propertyName] - a[propertyName]; | |
}); | |
return sortedList; | |
} |
This file contains hidden or 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
// here is an array of 120 items | |
const items = Array.from({length: 120}, (_, index) => index); | |
console.log("items ->", items); | |
function createPagination(items, itemsPerPage) { | |
const numberOfPages = Math.ceil(items.length / itemsPerPage); | |
return Array.from({length: numberOfPages}, (_, index) => { | |
const startIndex = index * itemsPerPage; | |
return items.slice(startIndex, startIndex + itemsPerPage); |
This file contains hidden or 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 timestamp( | |
{ | |
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep','Oct', 'Nov', 'Dec'], | |
timePad = 2} = {} | |
) { | |
const pad = (n) => n.toString().padStart(timePad, '0'); | |
const d = new Date(); | |
const time = [pad(d.getHours()), | |
pad(d.getMinutes()), |
This file contains hidden or 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
const compose = (...fns) => x => fns.reduceRight((y, f) => f(y), x) | |
// example | |
const upperFirst = (srt) => srt.charAt(0).toUpperCase() + srt.slice(1); | |
const users = [ | |
{ id: 1, name: 'aitor', lastName: 'alejandro' } | |
]; | |
const first = x => x[0]; |
This file contains hidden or 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
const indexBy = (key, xs) => xs.reduce(acc, el) => ({ | |
...acc, | |
[el[key]]: el, | |
}); | |
/* | |
example: | |
// const users = [ | |
{id: 'id1', name: 'Aritz'}, | |
{id: 'id2', name: 'Asier'}, |
This file contains hidden or 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
const uid = () => performance.now().toString(36) + Math.random().toString(36).substr(2); |
This file contains hidden or 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
const isBrowserTabFocused = () => !document.hidden; | |
// Example | |
isBrowserTabFocused(); // true |
This file contains hidden or 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
const copyToClipboard = str => { | |
const el = document.createElement('textarea'); | |
el.value = str; | |
el.setAttribute('readonly', ''); | |
el.style.position = 'absolute'; | |
el.style.left = '-9999px'; | |
document.body.appendChild(el); | |
const selected = | |
document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; | |
el.select(); |