From 0aba834f11f91c3907803e8f4f6a460f3237c523 Mon Sep 17 00:00:00 2001 From: Collin Miller Date: Mon, 16 May 2016 15:19:18 -0500 Subject: [PATCH] some enhancements to example runner for designing at multiple breakpoints inside iframes --- .eslintignore | 1 + examples/component.js | 277 ++++++++++++++++++++++++++++++++++++++++-- examples/examples.js | 5 +- examples/index.html | 3 + examples/index.js | 46 ++++--- examples/routes.js | 21 +++- examples/style.scss | 9 ++ 7 files changed, 320 insertions(+), 42 deletions(-) diff --git a/.eslintignore b/.eslintignore index 2db218e1..f01dc4e7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ scripts/* bower_components/* generator-bulbs-elements +examples/* diff --git a/examples/component.js b/examples/component.js index fec9a925..9746488e 100644 --- a/examples/component.js +++ b/examples/component.js @@ -1,24 +1,279 @@ -/* eslint react/no-unknown-property: "off" */ -/* eslint-disable react/prop-types, react/no-danger */ - import React from 'react'; +import { browserHistory } from 'react-router'; import examples from './element-examples'; -class Component extends React.Component { +const DEVICES = { + desktop: { + width: '1000px', + }, + tablet: { + width: '600px', + }, + mobile: { + width: '320px', + }, +}; + +function Checkerboard () { + let gridSize = 8; + let gridColor = '#fafafa'; + return ( + + + + + + + + + + ); +} + +class ExampleViewport extends React.Component { + constructor (props) { + super(props); + this.state = { + scale: 1, + workspace: 1, + }; + } + + setDevice (device) { + let segments = [ + 'example', + this.props.params.element, + this.props.params.example, + device, + ]; + + console.log('/' + segments.join('/'), {}); + browserHistory.push('/' + segments.join('/'), {}); + } + + setScale(event) { + this.setState({ + scale: event.target.value, + }); + } + + setWorkspace(event) { + this.setState({ + workspace: event.target.value, + }); + } + + render () { + return ( +
+
+ + + + + + + + + + +
+
+ +
+ { + this.props.params.device.split(',').map((device) => { + return ( +