Skip to content

Instantly share code, notes, and snippets.

Dialog Components

The purpose of this document is to help define the components that comprise Instructure UI's dialog components. Dialog components typically render outside the context of the application and are the primary focal point when rendered.

This represents the current state of things.

Building Blocks

These are the low-level components needed for dialogs.

Portal Component Refactor

Proposal for how to refactor InstUI's use of <Portal />.

The Problem

There are several issues with how <Portal /> is currently being used.

  1. We have two versions of <Portal /> in our code base. A version that we wrote ourselves and a version packaged with react-overlays. This causes unecessary overhead.
  2. There are inconsistencies with the developer facing API for how to specify the trigger and the content for components that use a ``. This makes it confusing as the usage of these components is not predictable.
@mzabriskie
mzabriskie / webpack.config.js
Last active October 14, 2016 17:07
Webpack externals for React
// Which is the best practice for React?
// This needs to be compatible with RequireJS.
module.exports = {
externals: {
'react': 'React',
'react-dom': 'ReactDOM'
},
// - OR -
@mzabriskie
mzabriskie / index.js
Last active June 23, 2016 18:13
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
'use strict';
/*
Pre Babel
import axios from 'axios'

Example use of <FormField/>:

<FormField label="Username" errors={['Cannot be left blank']}>
  <input type="text" name="username" value=""/>
</FormField>

This renders something like:

@mzabriskie
mzabriskie / custom-axios.js
Created March 2, 2016 20:18
Auto detect Greasemonkey and use custom axios adapter if available
import axios from 'axios';
if (typeof GM_xmlhttpRequest === 'function') {
import GMAdapter from './GMAdapter';
axios.defaults.adapter = GMAdapter;
}
export default axios;
import axios from 'axios';
axios.defaults.adapter = (resolve, reject, config) => {
let data = null;
let status = 200;
let headers = {};
// Here you would check some registry of request URLs for response
// This would allow you to determine resolve/reject
// Also what is the actual data for the response
function duration(timeInMillis) {
var intervals = {
'h': 3600000,
'm': 60000,
's': 1000,
'ms': 1
},
sb = '';
for (var k in intervals) {