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 CommentButtons({ user }) { | |
return ( | |
<div> | |
<Button disabled={user?.can?.edit}>edit</Button> | |
<Button disabled={user?.can?.delete}>delete</Button> | |
<Button disabled={user?.can?.reply}>reply</Button> | |
</div> | |
) | |
} |
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
componentDidUpdate(prevProps) { | |
if ( | |
this.props.image?.type !== prevProps.image?.type || | |
this.props.image?.orientation !== prevProps.image?.orientation | |
) { | |
// ... | |
} | |
} |
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 bodyParser from 'body-parser'; | |
import url from 'url'; | |
const handleRequest = (method, path, cb) => { | |
WebApp.rawConnectHandlers.use(path, (req, res, next) => { | |
if (req.method !== method) { | |
next(); | |
return; | |
} |
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
/* | |
First run npm install topojson --save and then link "node_modules/topojson/build/topojson.min.js" | |
above this snippet in your html. | |
Usage: http://leafletjs.com/reference.html#geojson | |
*/ | |
L.TopoJSON = L.GeoJSON.extend({ | |
addData: function (data) { | |
var geojson, key; |
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, { PropTypes } from 'react'; | |
import Lightbox from 'react-images'; | |
import styled from 'styled-components'; | |
const Container = styled.div` | |
display: flex; | |
justify-content: flex-start; | |
flex-flow: row wrap; | |
width: ${p => p.width}px; | |
`; |
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 get(path, obj, fb = `$\{${path}}`) { | |
return path.split('.').reduce((res, key) => res[key] || fb, obj); | |
} | |
function parseTpl(template, map, fallback) { | |
return template.replace(/\$\{.+?}/g, (match) => { | |
const path = match.substr(2, match.length - 3).trim(); | |
return get(path, map, fallback); | |
}); | |
} |
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 actionTypeBuilder(prefix) { | |
return { | |
type: actionType => `${prefix}/${actionType}`, | |
loading: actionType => `${actionType}/loading`, | |
ready: actionType => `${actionType}/ready`, | |
stopped: actionType => `${actionType}/stopped`, | |
changed: actionType => `${actionType}/changed`, | |
error: actionType => `${actionType}/error`, | |
success: actionType => `${actionType}/success` | |
}; |
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
test snippet |
NewerOlder