View .babelrc
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
Show hidden characters
{ | |
"presets": [ | |
[ | |
"@babel/preset-env", | |
{ | |
"useBuiltIns": "entry", | |
"corejs": 3 | |
} | |
] | |
], |
View client.js
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 loadPolyfills from './load-polyfills'; | |
import mountApp from './app'; // the entry point for the rest of my app | |
loadPolyfills().then(mountApp); |
View string-trim-to-sentence.js
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 trimByCharToSentence = (text = "", chars = 0) => { | |
// string is broken down into sentences; | |
// this is done by splitting it into array between | |
// the most common sentence-ending punctuation marks: | |
// period, exclaimation, ellipsis and question mark; | |
// if string consists of a single statement, make an array | |
// anyways | |
const sentences = text.match(/[^\.!…\?]+[\.!…\?]+/g) || [text] | |
// store | |
let result = "" |
View Dots.js
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
// tools | |
import React from "react" | |
import styled from "styled-components" | |
// styles | |
const Dots = styled.span` | |
&::after { | |
display: inline-block; | |
animation: ellipsis 1.25s infinite; | |
content: "."; |
View Ajax.js
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 Ajax(url, fn) { | |
var request = new XMLHttpRequest(); | |
request.open('GET', url, true); | |
request.onload = function() { | |
if (request.status >= 200 && request.status < 400) { | |
var data = JSON.parse(request.responseText); | |
fn(data); | |
} else { | |
console.log("Error. Server connection OK.", request.responseText); | |
} |
View Slate Placeholder
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 wrapperStyle = { | |
position: 'relative' | |
} | |
const PlaceHolder = React.createClass({ | |
renderPlaceholder(){ | |
const { node, state, parent } = this.props; | |
const placeholderText = node.data.get('placeholderText'); | |
return ( |
View plugins.js
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 const plugins = [ | |
AutoReplace({ | |
trigger: "*", | |
before: /(\*)(.*)/, | |
ignoreIn: "heading", | |
transform: (transform, e, data, matches) => { | |
return transform | |
.addMark({ type: "bold" }) | |
.insertText(matches.before[2]) | |
.removeMark({ type: "bold" }) |