├── .babelrc ├── .npmignore ├── assets └── screenshot.png ├── .storybook ├── config.js ├── addons.js └── devices.json ├── stories └── index.js ├── .gitignore ├── package.json ├── README.md └── src ├── Select.js ├── register.js └── main.css /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "stage-1", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .babelrc 2 | .storybook 3 | stories 4 | src 5 | assets 6 | .gitignore 7 | -------------------------------------------------------------------------------- /assets/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PeterPanen/storybook-addon-scissors/HEAD/assets/screenshot.png -------------------------------------------------------------------------------- /.storybook/config.js: -------------------------------------------------------------------------------- 1 | import { configure } from '@storybook/react'; 2 | 3 | function loadStories() { 4 | require('../stories/index.js'); 5 | } 6 | 7 | configure(loadStories, module); 8 | -------------------------------------------------------------------------------- /stories/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | import { action } from '@storybook/addon-actions'; 4 | 5 | storiesOf('Button', module) 6 | .add('with text', () => ( 7 | 8 | )) 9 | .add('with some emoji', () => ( 10 | 11 | )); 12 | -------------------------------------------------------------------------------- /.storybook/addons.js: -------------------------------------------------------------------------------- 1 | import "@storybook/addon-actions/register"; 2 | import registerScissors from "../src/register"; 3 | import devicesJSON from "./devices.json"; 4 | 5 | const devices = devicesJSON.extensions.map(({ device }) => ({ 6 | uid: device.title, 7 | title: device.title, 8 | width: device.screen.vertical.width, 9 | height: device.screen.vertical.height 10 | })); 11 | 12 | registerScissors(devices); 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | *.pid.lock 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # nyc test coverage 19 | .nyc_output 20 | 21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 22 | .grunt 23 | 24 | # node-waf configuration 25 | .lock-wscript 26 | 27 | # Compiled binary addons (http://nodejs.org/api/addons.html) 28 | build/Release 29 | 30 | # Dependency directories 31 | node_modules 32 | jspm_packages 33 | 34 | # Optional npm cache directory 35 | .npm 36 | 37 | # Optional eslint cache 38 | .eslintcache 39 | 40 | # Optional REPL history 41 | .node_repl_history 42 | 43 | # Output of 'npm pack' 44 | *.tgz 45 | 46 | # Yarn Integrity file 47 | .yarn-integrity 48 | 49 | # Build folder 50 | build 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "storybook-addon-scissors", 3 | "version": "4.0.2", 4 | "description": "Addon for React Storybook providing responsive containers for stories", 5 | "main": "build/register.js", 6 | "scripts": { 7 | "prepublishOnly": "npm run build", 8 | "start": "start-storybook -p 9001 -c .storybook", 9 | "prebuild": "rimraf build/*", 10 | "build": "babel src --out-dir build --copy-files" 11 | }, 12 | "keywords": [ 13 | "React", 14 | "Storybook", 15 | "Responsive", 16 | "Scissors", 17 | "Devices" 18 | ], 19 | "author": "Rasmus Knudsen", 20 | "license": "ISC", 21 | "repository": "https://github.com/PeterPanen/storybook-addon-scissors.git", 22 | "devDependencies": { 23 | "@storybook/react": "^3.4.11", 24 | "babel-cli": "^6.26.0", 25 | "babel-preset-env": "^1.7.0", 26 | "babel-preset-react": "^6.24.1", 27 | "babel-preset-stage-1": "^6.24.1", 28 | "css-loader": "^1.0.0", 29 | "react": "^16.5.1", 30 | "react-dom": "^16.5.1", 31 | "rimraf": "^2.6.2", 32 | "style-loader": "^0.23.0" 33 | }, 34 | "dependencies": { 35 | "react-toggle": "^4.0.2", 36 | "react-virtualized-select": "^3.1.3" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **:warning: WARNING: This repo is no longer maintained!:warning:** 2 | 3 | # Storybook Addon Scissors 4 | 5 |  6 | 7 | > Requires storybook version 3+ 8 | 9 | ### Install 10 | 11 | ```javascript 12 | npm i -D storybook-addon-scissors 13 | ``` 14 | 15 | ### Usage 16 | 17 | * Download and import device list from [ChromeDevTools devices](https://github.com/ChromeDevTools/devtools-frontend/blob/master/front_end/emulated_devices/module.json) (or bring your own with instructions below) 18 | * Create or open `.storybook/addons.js` and register the addon like below. 19 | 20 | ```javascript 21 | // addons.js 22 | import '@storybook/addon-actions/register'; 23 | import registerScissors from 'storybook-addon-scissors'; 24 | import devicesJSON from './devices.json'; 25 | 26 | // registerScissors() takes an array of device objects with the following signature: 27 | // [{ 28 | // uid: String (must be unique) 29 | // title: String 30 | // width: Number 31 | // height: Number 32 | // }] 33 | // In the case of using the device list from ChromeDevTools, 34 | // we can map them the following way. 35 | const devices = devicesJSON.extensions.map(({ device }) => ({ 36 | uid: device.title, 37 | title: device.title, 38 | width: device.screen.vertical.width, 39 | height: device.screen.vertical.height, 40 | })); 41 | 42 | registerScissors(devices); 43 | ``` 44 | -------------------------------------------------------------------------------- /src/Select.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import VirtualizedSelect from 'react-virtualized-select'; 3 | import '!style-loader!css-loader!react-select/dist/react-select.css'; 4 | 5 | const optionRenderer = ({ option, style, selectValue, focusedOption }) => { 6 | const focusedClass = focusedOption.uid === option.uid ? 'focused' : ''; 7 | return ( 8 |