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
interface RefHandles { | |
scrollToIntent: HTMLElement['scrollTo']; | |
} | |
const targetElement = document.createElement('div'); | |
const handles: RefHandles = { | |
scrollToIntent(...args: any[]) { | |
targetElement.scrollTo(...args); | |
} |
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 state = 1 | |
const update = (value) => { | |
state = value | |
document.innerHTML = Array(value % 4).fill('Hello') | |
} | |
setInterval(() => update(Date.now()), 1000) |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>My Page</title> | |
<style> | |
li { cursor: pointer } | |
</style> | |
<!-- | |
The first place JS and HTML intersect is a script tag |
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
import React from 'react' | |
import { useStable, useWatch } from '@objects/hooks' | |
import { through, map, debounce } from '@objects/operators' | |
interface Search { | |
title: string | |
} | |
interface Data { |
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
wickedElements.define('.my-counter', (element, { events, changes, values }) => { | |
const counter = element.querySelector('.count') | |
const minus = element.querySelector('.minus') | |
const plus = element.querySelector('.plus') | |
changes(values).count(count => { | |
counter.textContent = count | |
}) | |
values.count = 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
import { useInstance } from 'object-hooks'; | |
class Analytics { | |
private api = () => { | |
const raceError = new Error('handler called before loaded'); | |
bugsnagClient.notify(raceError); | |
}; | |
public log = (...args: any[]) => { | |
return this.api(...args); |
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
import { useState, useReducer, useEffect } from 'react' | |
export function useGallery( | |
collectionUrl, | |
initialTag, | |
initialPageNumber = 0 | |
) { | |
const [pageNumber, updatePageNumber] = useState( | |
initialPageNumber, | |
) |
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
import { useReducer, useEffect, useRef, useCallback } from 'react' | |
const offsets = { | |
n: [0, 1], | |
s: [0, -1], | |
e: [1, 0], | |
w: [-1, 0], | |
} | |
const equals = (a, b) => |
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
import { useReducer, useState, useEffect } from "react"; | |
const reduceCartFromOrders = (current, [id, quantity]) => { | |
if (current === null) current = {}; | |
if (quantity === null) { | |
delete current[id]; | |
return current; | |
} |
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
{ | |
"editor.tokenColorCustomizations": { | |
"textMateRules": [ | |
{ | |
"scope": [ | |
"meta.type.declaration", | |
"meta.type.declaration entity", | |
"meta.type.declaration entity.name.function", | |
"meta.type.declaration entity.name.type", | |
"meta.type.declaration keyword", |
NewerOlder