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
const focusableSelectors = [ | |
'a[href]:not([tabindex^="-"]):not([inert])', | |
'area[href]:not([tabindex^="-"]):not([inert])', | |
'input:not([disabled]):not([inert])', | |
'select:not([disabled]):not([inert])', | |
'textarea:not([disabled]):not([inert])', | |
'button:not([disabled]):not([inert])', | |
'iframe:not([tabindex^="-"]):not([inert])', | |
'audio:not([tabindex^="-"]):not([inert])', | |
'video:not([tabindex^="-"]):not([inert])', |
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
/** | |
* Copyright (c) Nicolas Gallagher. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE file in the root directory of this source tree. | |
* | |
* @flow strict-local | |
*/ | |
type Groups = { [key: number]: Array<string> }; |
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 MenuButton({ children }) { | |
let called = false | |
function getButtonProps(props) { | |
const merged = merge({ | |
onClick: () => {}, | |
role: 'button', | |
}, props) | |
called = true | |
return merged | |
} |
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
https://jsperf.com/object-assign-vs-array-merging |
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
static async getInitialProps ({ Component, router, ctx }) { | |
let page = {} | |
if (Component.getInitialProps) { | |
page = await Component.getInitialProps(ctx) | |
} | |
const basepath = typeof window === 'undefined' | |
? '' | |
: location.pathname.slice(0, location.pathname.length - router.route.length).replace(/\/$/, '') |
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
/* @flow */ | |
import React from 'react' | |
import messages from '../messages' | |
import { injectIntl } from 'react-intl' | |
import type { IntlShape } from 'react-intl' | |
type Props = {| | |
children: React.Node, | |
intl: IntlShape, |
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
// given this | |
export const styles = { | |
test: { | |
color: 'red', | |
display: props => props.visible ? 'block' : 'none' | |
} | |
} | |
// rewrite to this |
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 getCache(name) { | |
return new Promise((resolve, reject) => { | |
const version = 1; | |
const request = indexedDB.open(name, version); | |
request.onsuccess = event => { | |
const db = event.target.result; | |
/* | |
* Returns a Promise that resolves with an object |
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
/* | |
1 and 2 are hashes of | |
`p[data-jsx~="?"] { color: ${props.color}; }` | |
and | |
`div[data-jsx~="?"] { border: 1px solid ${borderStyle} }` | |
*/ | |
export default (props) => { | |
const borderStyle = props.foo ? 'solid' : 'dashed' |