Skip to content

Instantly share code, notes, and snippets.

View jossmac's full-sized avatar
🎨
Design Tokens

Joss Mackison jossmac

🎨
Design Tokens
View GitHub Profile
@jossmac
jossmac / with-context-as-props.js
Last active November 13, 2017 03:30
A HOC for moving props to context. Used as a conduit to maintain context when rendering to a different subtree.
import React, { Component } from 'react';
import PropTypes from 'prop-types';
const DefaultBaseComponent = props => <div {...props} />;
const withContextFromProps = (
propTypes: PropTypes.object,
BaseComponent: PropTypes.func = DefaultBaseComponent
) => {
class ContextProps extends Component {
@jossmac
jossmac / withPseudoState.jsx
Last active July 6, 2017 00:22
A higher order component to replace pseudo-states when working with a CSS in JS solution
import React, { Component } from 'react';
export default function withPseudoState(WrappedComponent) {
return class ComponentWithPseudoState extends Component {
actionKeys = ['Enter', ' ']
state = {
isActive: false,
isFocus: false,
isHover: false,
}
@jossmac
jossmac / renderImageSelect.js
Created August 2, 2016 09:20
Temporarily removed the CloudinaryImageField.js renderImageSelect method
renderImageSelect () {
var selectPrefix = this.props.selectPrefix;
var self = this;
var getOptions = function (input, callback) {
// build our url, accounting for selectPrefix
var uri = Keystone.adminPath + '/api/cloudinary/autocomplete';
if (selectPrefix) {
uri = uri + '?prefix=' + selectPrefix;
}