<sp-widget widget="widgetData"></sp-widget>
function(spUtil) {
const debounce = (callback, wait) => { | |
let timeout; | |
return (...args) => { | |
const context = this; | |
clearTimeout(timeout); | |
timeout = setTimeout(() => callback.apply(context, args), wait); | |
}; | |
}; | |
export default debounce; |
const objetToQueryString = params => Object.keys(params) | |
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k])) | |
.join('&'); | |
export default objetToQueryString; |
export default ({ validateUser, userRepository }) => async (userData, { onSuccess, onError, onValidationError }) => { | |
if(!validateUser(userData)) { | |
return onValidationError(new Error('Invalid user')); | |
} | |
try { | |
const user = await userRepository.add(userData); | |
onSuccess(user); | |
} catch(error) { |
const lazies = Array.from(document.querySelectorAll('.lazy')); | |
function isInViewport(elem) { | |
const rect = elem.getBoundingClientRect(); | |
return ( | |
rect.bottom >= 0 && | |
rect.right >= 0 && | |
rect.top <= ( |
// exemplo de async await com multiplas promises | |
async function getUsers(users) { | |
const promises = users | |
.map(user => fetch(`https://api.github.com/users/${user}`).then(response => response.json())); | |
const people = await Promise.all(promises); | |
console.log(people); | |
} |
html {font-size: 62.5%;} | |
@media screen and (max-width: 1024px) { | |
html {font-size: 55%;} | |
} | |
@media screen and (max-width: 940px) { | |
html {font-size: 50%;} | |
} |
root = true | |
[*] | |
indent_style = space | |
indent_size = 2 | |
end_of_line = lf | |
charset = utf-8 | |
trim_trailing_whitespace = true | |
insert_final_newline = true |
export class ObjectFitPolyfill { | |
constructor() { | |
throw new Error('Não é possivel instanciar ObjectFitolyfill'); | |
} | |
static init () { | |
let html = document.querySelector('html'); | |
let noObjectFit = html.classList.contains('ie') || html.classList.contains('edge'); |