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
/* | |
* Generates a universally unique identifier based on random values and timestamp. | |
* Random length can be increased to get even more unique values. | |
*/ | |
function uuid() { | |
if (!window.crypto) throw new Error('crypto not available') | |
const randomLength = 8 | |
const uuidUint8Array = new Uint8Array(randomLength) | |
window.crypto.getRandomValues(uuidUint8Array) | |
return `${uuidUint8Array.join('')}${Date.now()}` |
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 isAtMaxWidth = screen.availWidth - window.innerWidth === 0 | |
const screenPixelRatio = (window.outerWidth - 8) / window.innerWidth | |
const isAtDefaultZoom = screenPixelRatio > 0.92 && screenPixelRatio <= 1.10 | |
const isMaximizedAndDefaultZoom = isAtMaxWidth && isAtDefaultZoom | |
const isFullscreen = window.outerWidth == screen.width && window.outerHeight == screen.height |
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 Transition from 'react-transition-group/Transition' | |
<Transition in={isVisible} timeout={200}> | |
{(state) => ( | |
<StyledComponent transitionState={state} /> | |
)} | |
</Transition> | |
const StyledComponent = styled.div` | |
transition: opacity 0.2s; |
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
export function getViewportDimensions () { | |
const w = window | |
const d = document | |
const e = d.documentElement | |
const g = d.getElementsByTagName('body')[0] | |
const x = w.innerWidth || e.clientWidth || g.clientWidth | |
const y = w.innerHeight || e.clientHeight || g.clientHeight | |
return { x, y } | |
} |
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
/** | |
* Splits a string in half by tag name | |
* i.e. '<p>' or 'p' | |
* returns array of 2 strings | |
* | |
*/ | |
export const splitTextByTag = (text, tag) => { | |
let closingTag = ''; | |
// clean text from line breaks | |
let cleanText = text.replace(/\r?\n|\r/g, ''); |
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
export function keyboardHandler (event, keys, callback) { | |
if (typeof event === 'undefined') { | |
return | |
} | |
const key = event.key || event.keyCode | |
if (keys.includes(key)) { | |
event.preventDefault() | |
event.stopPropagation() | |
callback() | |
} |
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
var id=window.setTimeout(function(){},0); | |
while(id--){window.clearTimeout(id);} |
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 throttle from 'lodash/throttle' | |
export class Wheel { | |
constructor ({ id, wheelEndCallback }) { | |
this.initialPointerY = -1 | |
this.pointerY = 0 | |
this.currentItemIndex = -1 | |
this.elementHeight = -1 | |
this.childrenHeight = -1 | |
this.isDragging = false |
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, { Component } from 'react' | |
import { string } from 'prop-types' | |
import { connect } from 'react-redux' | |
import { openModal } from 'actions/modal' | |
import SimpleModal from './index.js' | |
export class SimpleModalContainer extends Component { | |
constructor (props) { | |
super(props) | |
} |
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 { string } from 'prop-types' | |
import './_SimpleModal.css' | |
export function SimpleModal ({ className }) { | |
return ( | |
<div className="SimpleModal__Container"> | |
Modal | |
</div> | |
) |
NewerOlder