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 { Head, withSiteData } from 'react-static'; | |
// Reference URL | |
// https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications | |
// https://github.com/googleanalytics/autotrack#urlchangetracker | |
class GoogleAnalytics extends Component { | |
componentDidMount() { | |
// Ignore if not running on browser. |
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 thinkProc = () => { | |
self.addEventListener( | |
'message', | |
function(e) { | |
console.log('Worker called: ', e.data); | |
const board: BoardState = e.data.board; | |
let result = { row: -1, col: -1 }; | |
const placeableCells: CellState[] = []; | |
board.cells.forEach((row) => { |
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 ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import createWorker from './createWorker'; | |
import myWorkerFunc from './myWorker'; | |
ReactDOM.render(<App />, document.getElementById('root')); |
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
/* eslint no-restricted-globals: ["error"] */ | |
export default () => { | |
let count = 0; | |
self.addEventListener( | |
'message', | |
function(e) { | |
if (e.data.action === 'count') { | |
count++; |
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 default (workerFunc: () => void) => { | |
let code = workerFunc.toString(); | |
code = code.substring(code.indexOf('{') + 1, code.lastIndexOf('}')); | |
const blob = new Blob([code], { type: 'application/javascript' }); | |
return new Worker(URL.createObjectURL(blob)); | |
}; |
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
class App extends React.Component<Props, State> { | |
state = { page: 'menu' }; | |
onChangeStore = () => { | |
const { page } = store.getState(); | |
this.setState({ page }); | |
}; | |
componentDidMount() { | |
store.on('page_changed', this.onChangeStore); |
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 * as React from 'react'; | |
import * as moment from 'moment'; | |
import { WorkItem } from './WorkItem'; | |
import './Report.css'; | |
interface Props { | |
items: WorkItem[]; | |
} | |
export const Report = (props: 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 * as moment from 'moment'; | |
export interface WorkItem { | |
user: string; | |
client: string; | |
project: string; | |
description: string; | |
startDate: Date; | |
endDate: Date; | |
duration: number; |
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 mapCSVToArray(csv: string): string[][] { | |
return csv.split('\n').map((row) => row.split(',')); | |
} |
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 readFileAsText(file: Blob): Promise<string> { | |
return new Promise<string>((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.onerror = () => reject(reader.error); | |
reader.onload = () => resolve((reader.result as string) || ''); | |
reader.readAsText(file); | |
}); | |
} |