├── .babelrc ├── .editorconfig ├── .eslintrc ├── .github └── FUNDING.yml ├── .gitignore ├── .stylelintrc ├── .travis.yml ├── LICENSE ├── README.md ├── app ├── assets │ ├── fonts │ │ └── OpenSans │ │ │ ├── OpenSans-Bold.eot │ │ │ ├── OpenSans-Bold.svg │ │ │ ├── OpenSans-Bold.ttf │ │ │ ├── OpenSans-Bold.woff │ │ │ ├── OpenSans-Bold.woff2 │ │ │ ├── OpenSans-Light.eot │ │ │ ├── OpenSans-Light.svg │ │ │ ├── OpenSans-Light.ttf │ │ │ ├── OpenSans-Light.woff │ │ │ ├── OpenSans-Light.woff2 │ │ │ ├── OpenSans-Regular.eot │ │ │ ├── OpenSans-Regular.svg │ │ │ ├── OpenSans-Regular.ttf │ │ │ ├── OpenSans-Regular.woff │ │ │ └── OpenSans-Regular.woff2 │ └── images │ │ └── example.jpg ├── index.html ├── scripts │ ├── app.js │ ├── app.test.js │ ├── bus.js │ ├── file-picker.js │ ├── image-processor.js │ ├── post-processors │ │ ├── empty-array.js │ │ ├── index.js │ │ └── template-string.js │ ├── sandbox.js │ └── vendor.js └── styles │ ├── app.scss │ ├── base │ ├── _fonts.scss │ ├── _globals.scss │ ├── _icons.scss │ ├── _states.scss │ ├── _utilities.scss │ ├── _variables-definitions.scss │ ├── _variables.scss │ └── mixins │ │ ├── _fonts.scss │ │ ├── _generic-get.scss │ │ ├── _icomoon.scss │ │ ├── _map-utilities.scss │ │ └── _media-suffixes.scss │ ├── components │ └── _conversor.scss │ └── vendor │ ├── _bootstrap.scss │ ├── _filepond.scss │ └── _normalize.scss ├── cypress.json ├── dist ├── CNAME ├── app.js ├── fonts │ ├── 05d1a99a91a5552d048ca2f15505fdb7.woff │ ├── 1bf71be111189e76987a4bb9b3115cb7.ttf │ ├── 50145685042b4df07a1fd19957275b81.ttf │ ├── 55bfb3e43457ec893f128c2d73f76457.eot │ ├── 629a55a7e793da068dc580d184cc0e31.ttf │ ├── 7d814dede71df420083cb66cf23a540c.svg │ ├── 87051a9d79eb9fc8c317b5777320f78d.woff │ ├── 885e3d6f49fb6783494654e69793e802.eot │ ├── 90327f5ac43d0fbc708f3653ffc0a043.woff │ ├── 9d9891110e9658a143a51dd555a1b63c.svg │ ├── df9defacb2739cc8bca43df8a656867f.svg │ └── e1d396939867c493f06f2bbc071993d9.eot ├── index.html └── vendor.js ├── jest.config.js ├── package-lock.json ├── package.json ├── tasks ├── plugins │ ├── extract-styles.js │ ├── globals.js │ ├── html.js │ └── uglify.js └── rules │ ├── files.js │ ├── scripts.js │ └── styles.js ├── tests └── e2e │ ├── plugins │ └── index.js │ ├── specs │ └── app.spec.js │ └── videos │ └── app.spec.js.mp4 └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "presets": [ 4 | ["@babel/preset-env", { 5 | "useBuiltIns": "usage", 6 | "debug": true, 7 | "targets": { 8 | "browsers": ["last 2 versions"], 9 | } 10 | }] 11 | ], 12 | "plugins": [ 13 | "@babel/plugin-syntax-dynamic-import" 14 | ] 15 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "cypress" 4 | ], 5 | "env": { 6 | "cypress/globals": true, 7 | "browser": true, 8 | "es6": true, 9 | "node": false 10 | }, 11 | "parserOptions": { 12 | "ecmaVersion": 6, 13 | "sourceType": "module" 14 | }, 15 | "rules": { 16 | "comma-dangle": [ 17 | 2, 18 | "never" 19 | ], 20 | "no-cond-assign": 2, 21 | "no-console": 0, 22 | "no-constant-condition": 2, 23 | "no-control-regex": 2, 24 | "no-debugger": 2, 25 | "no-dupe-args": 2, 26 | "no-dupe-keys": 2, 27 | "no-duplicate-case": 2, 28 | "no-empty-character-class": 2, 29 | "no-empty": 2, 30 | "no-ex-assign": 2, 31 | "no-extra-boolean-cast": 2, 32 | "no-extra-parens": 0, 33 | "no-extra-semi": 2, 34 | "no-func-assign": 2, 35 | "no-inner-declarations": [ 36 | 2, 37 | "functions" 38 | ], 39 | "no-invalid-regexp": 2, 40 | "no-irregular-whitespace": 2, 41 | "no-negated-in-lhs": 2, 42 | "no-obj-calls": 2, 43 | "no-regex-spaces": 2, 44 | "no-reserved-keys": 0, 45 | "no-sparse-arrays": 2, 46 | "no-unreachable": 2, 47 | "use-isnan": 2, 48 | "valid-jsdoc": 0, 49 | "valid-typeof": 2, 50 | "block-scoped-var": 0, 51 | "complexity": [ 52 | 0, 53 | 11 54 | ], 55 | "consistent-return": 2, 56 | "curly": [ 57 | 2, 58 | "all" 59 | ], 60 | "default-case": 0, 61 | "dot-notation": [ 62 | 2, 63 | { 64 | "allowKeywords": true 65 | } 66 | ], 67 | "eqeqeq": 2, 68 | "guard-for-in": 0, 69 | "no-alert": 2, 70 | "no-caller": 2, 71 | "no-div-regex": 0, 72 | "no-else-return": 0, 73 | "no-eq-null": 0, 74 | "no-eval": 2, 75 | "no-extend-native": 2, 76 | "no-extra-bind": 2, 77 | "no-fallthrough": 2, 78 | "no-floating-decimal": 0, 79 | "no-implied-eval": 2, 80 | "no-iterator": 2, 81 | "no-labels": 2, 82 | "no-lone-blocks": 2, 83 | "no-loop-func": 2, 84 | "no-multi-spaces": 2, 85 | "no-multi-str": 2, 86 | "no-native-reassign": 2, 87 | "no-new-func": 2, 88 | "no-new-wrappers": 2, 89 | "no-new": 0, 90 | "no-octal-escape": 2, 91 | "no-octal": 2, 92 | "no-param-reassign": 0, 93 | "no-process-env": 0, 94 | "no-proto": 2, 95 | "no-redeclare": 2, 96 | "no-return-assign": 2, 97 | "no-script-url": 2, 98 | "no-self-compare": 0, 99 | "no-sequences": 2, 100 | "no-throw-literal": 0, 101 | "no-unused-expressions": 2, 102 | "no-void": 0, 103 | "no-warning-comments": [ 104 | 0, 105 | { 106 | "terms": [ 107 | "todo", 108 | "fixme" 109 | ], 110 | "location": "start" 111 | } 112 | ], 113 | "no-with": 2, 114 | "radix": 0, 115 | "vars-on-top": 0, 116 | "wrap-iife": 0, 117 | "yoda": [ 118 | 2, 119 | "never" 120 | ], 121 | "strict": 2, 122 | "no-catch-shadow": 2, 123 | "no-delete-var": 2, 124 | "no-label-var": 2, 125 | "no-shadow-restricted-names": 2, 126 | "no-shadow": 2, 127 | "no-undef-init": 2, 128 | "no-undef": 2, 129 | "no-undefined": 0, 130 | "no-unused-vars": [ 131 | 2, 132 | { 133 | "vars": "all", 134 | "args": "after-used" 135 | } 136 | ], 137 | "no-use-before-define": 2, 138 | "handle-callback-err": 0, 139 | "no-mixed-requires": [ 140 | 0, 141 | false 142 | ], 143 | "no-new-require": 0, 144 | "no-path-concat": 0, 145 | "no-process-exit": 2, 146 | "no-restricted-modules": 0, 147 | "no-sync": 0, 148 | "brace-style": [ 149 | 2, 150 | "1tbs" 151 | ], 152 | "camelcase": 2, 153 | "comma-spacing": 2, 154 | "comma-style": 0, 155 | "consistent-this": [ 156 | 0, 157 | "that" 158 | ], 159 | "eol-last": 0, 160 | "func-names": 0, 161 | "func-style": [ 162 | 0, 163 | "declaration" 164 | ], 165 | "indent": 0, 166 | "key-spacing": [ 167 | 2, 168 | { 169 | "beforeColon": false, 170 | "afterColon": true 171 | } 172 | ], 173 | "keyword-spacing": 2, 174 | "linebreak-style": [ 175 | 0, 176 | "unix" 177 | ], 178 | "max-nested-callbacks": [ 179 | 0, 180 | 2 181 | ], 182 | "new-cap": 2, 183 | "new-parens": 2, 184 | "newline-after-var": 0, 185 | "no-array-constructor": 2, 186 | "no-continue": 0, 187 | "no-inline-comments": 0, 188 | "no-lonely-if": 0, 189 | "no-mixed-spaces-and-tabs": [ 190 | 2, 191 | false 192 | ], 193 | "no-multiple-empty-lines": [ 194 | 0, 195 | { 196 | "max": 2 197 | } 198 | ], 199 | "no-nested-ternary": 0, 200 | "no-new-object": 2, 201 | "no-spaced-func": 2, 202 | "no-ternary": 0, 203 | "no-trailing-spaces": 2, 204 | "no-underscore-dangle": 2, 205 | "no-unneeded-ternary": 0, 206 | "one-var": 0, 207 | "operator-assignment": [ 208 | 0, 209 | "always" 210 | ], 211 | "operator-linebreak": 0, 212 | "padded-blocks": 0, 213 | "quote-props": 0, 214 | "quotes": [ 215 | 2, 216 | "single" 217 | ], 218 | "semi-spacing": [ 219 | 2, 220 | { 221 | "before": false, 222 | "after": true 223 | } 224 | ], 225 | "semi": 2, 226 | "sort-vars": 0, 227 | "space-after-keywords": [ 228 | 0, 229 | "always" 230 | ], 231 | "space-before-blocks": [ 232 | 0, 233 | "always" 234 | ], 235 | "space-before-function-paren": [ 236 | 0, 237 | "always" 238 | ], 239 | "space-in-brackets": [ 240 | 0, 241 | "never" 242 | ], 243 | "space-in-parens": [ 244 | 0, 245 | "never" 246 | ], 247 | "space-infix-ops": 2, 248 | "space-unary-ops": [ 249 | 2, 250 | { 251 | "words": true, 252 | "nonwords": false 253 | } 254 | ], 255 | "spaced-line-comment": [ 256 | 0, 257 | "always" 258 | ], 259 | "wrap-regex": 0, 260 | "generator-star-spacing": 0, 261 | "no-var": 0, 262 | "object-shorthand": 0, 263 | "max-depth": [ 264 | 0, 265 | 4 266 | ], 267 | "max-len": [ 268 | 0, 269 | 80, 270 | 4 271 | ], 272 | "max-params": [ 273 | 0, 274 | 3 275 | ], 276 | "max-statements": [ 277 | 0, 278 | 10 279 | ], 280 | "no-bitwise": 0, 281 | "no-plusplus": 0 282 | } 283 | } -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [ckgrafico] 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Temporary folders and files 2 | .sass-cache/ 3 | .test/ 4 | .vscode/ 5 | npm-debug.log 6 | 7 | # Distribution folders 8 | #dist/ 9 | 10 | # Packages folders 11 | node_modules/ 12 | 13 | 14 | -------------------------------------------------------------------------------- /.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "processors": ["stylelint-processor-html"], 3 | "extends": "stylelint-config-standard", 4 | "plugins": [ 5 | "stylelint-scss" 6 | ], 7 | "rules": { 8 | "at-rule-no-unknown": null, 9 | "font-family-no-missing-generic-family-keyword": null, 10 | "no-missing-end-of-source-newline": null, 11 | "no-empty-source": null, 12 | "shorthand-property-no-redundant-values": null, 13 | "block-no-empty": null, 14 | "indentation": 2, 15 | "string-quotes": "single", 16 | "no-duplicate-selectors": true, 17 | "color-hex-case": "upper", 18 | "color-hex-length": "long", 19 | "color-named": "never", 20 | "selector-no-qualifying-type": true, 21 | "selector-combinator-space-after": "always", 22 | "selector-attribute-quotes": "always", 23 | "selector-attribute-operator-space-before": "never", 24 | "declaration-block-trailing-semicolon": "always", 25 | "declaration-colon-space-before": "never", 26 | "declaration-colon-space-after": "always", 27 | "property-no-vendor-prefix": true, 28 | "value-no-vendor-prefix": true, 29 | "number-leading-zero": "never", 30 | "font-weight-notation": "numeric", 31 | "at-rule-no-vendor-prefix": true, 32 | "selector-pseudo-element-colon-notation": "single", 33 | "selector-no-vendor-prefix": true, 34 | "media-feature-range-operator-space-before": "always", 35 | "media-feature-range-operator-space-after": "always", 36 | "media-feature-parentheses-space-inside": "never", 37 | "media-feature-name-no-vendor-prefix": true, 38 | "media-feature-colon-space-before": "never", 39 | "media-feature-colon-space-after": "always" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # .travis.yml 2 | language: node_js 3 | node_js: 4 | - '8' 5 | script: 6 | - npm run prod 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Quique Fdez Guerra 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # screenshotToCodeSandbox 2 | Simply convert a screen shot image to Code Sandbox project 3 | 4 | 5 | # TODO 6 | - [ ] Cool Readme 7 | - [ ] File Validators 8 | - [ ] Code Post processors 9 | - [ ] Testing 10 | - [ ] UI 11 | - [ ] Multiple Files 12 | - [ ] Beautify/linting? 13 | -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Bold.eot -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Bold.ttf -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Bold.woff -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Bold.woff2 -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Light.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Light.eot -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Light.ttf -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Light.woff -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Light.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Light.woff2 -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Regular.eot -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Regular.woff -------------------------------------------------------------------------------- /app/assets/fonts/OpenSans/OpenSans-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/fonts/OpenSans/OpenSans-Regular.woff2 -------------------------------------------------------------------------------- /app/assets/images/example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/app/assets/images/example.jpg -------------------------------------------------------------------------------- /app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Screenshot to CodeSandbox conversor 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

13 | Screenshot to CodeSandbox conversor 14 |

15 |

16 | Convert your code screenshots to Code Sandbox projects in a second. 17 |

18 |
19 | 22 | 23 | 26 |
27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /app/scripts/app.js: -------------------------------------------------------------------------------- 1 | import { createFilePicker } from './file-picker'; 2 | import { processImage } from './image-processor'; 3 | import { generateSandbox } from './sandbox'; 4 | import { bus, BusEvent } from './bus'; 5 | 6 | const $picker = document.querySelector('.js-picker'); 7 | const $result = document.querySelector('.js-result'); 8 | const $link = document.querySelector('.js-link'); 9 | const $loading = document.querySelector('.js-loading'); 10 | 11 | const HIDDEN_CLASS = 'is-hidden'; 12 | 13 | bus.on(BusEvent.ShowLoading, () => $loading.classList.remove(HIDDEN_CLASS)); 14 | bus.on(BusEvent.HideLoading, () => $loading.classList.add(HIDDEN_CLASS)); 15 | bus.on(BusEvent.ShowResults, () => $result.classList.remove(HIDDEN_CLASS)); 16 | bus.on(BusEvent.HideResults, () => $result.classList.add(HIDDEN_CLASS)); 17 | 18 | createFilePicker($picker); 19 | bus.on(BusEvent.FileAdded, processImage); 20 | bus.on(BusEvent.ImageProcessed, generateSandbox); 21 | bus.on(BusEvent.LinkGenerated, url => { 22 | $link.href = url; 23 | bus.emit(BusEvent.ShowResults); 24 | bus.emit(BusEvent.HideLoading); 25 | }); 26 | -------------------------------------------------------------------------------- /app/scripts/app.test.js: -------------------------------------------------------------------------------- 1 | describe('App', () => { 2 | test('When ____ should ___', () => { 3 | expect(true).toBe(true); 4 | }); 5 | }); -------------------------------------------------------------------------------- /app/scripts/bus.js: -------------------------------------------------------------------------------- 1 | import EventBus from 'js-event-bus'; 2 | 3 | export const bus = new EventBus(); 4 | 5 | export const BusEvent = { 6 | ShowLoading: 'ShowLoading', 7 | HideLoading: 'HideLoading', 8 | ShowResults: 'ShowResults', 9 | HideResults: 'HideResults', 10 | FileAdded: 'FileAdded', 11 | ImageProcessed: 'ImageProcessed', 12 | LinkGenerated: 'LinkGenerated' 13 | }; 14 | -------------------------------------------------------------------------------- /app/scripts/file-picker.js: -------------------------------------------------------------------------------- 1 | import * as FilePond from 'filepond'; 2 | import { bus, BusEvent } from './bus'; 3 | 4 | 5 | export function createFilePicker($container) { 6 | const file = FilePond.create({ 7 | multiple: true, 8 | name: 'file' 9 | }); 10 | 11 | $container.appendChild(file.element); 12 | 13 | $container.querySelector('.filepond--root').addEventListener('FilePond:addfile', () => { 14 | const data = file.getFile(); 15 | 16 | // TODO: Add validators here 17 | 18 | bus.emit(BusEvent.FileAdded, null, data.file); 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /app/scripts/image-processor.js: -------------------------------------------------------------------------------- 1 | import worker from 'tesseract.js'; 2 | import { bus, BusEvent } from './bus'; 3 | import { templateString, emptyArray } from './post-processors'; 4 | 5 | const postProcessors = [ 6 | templateString, 7 | emptyArray 8 | ]; 9 | 10 | function postProcessCode(code) { 11 | postProcessors.forEach(x => (code = x(code))); 12 | 13 | return code; 14 | } 15 | 16 | export function processImage(image) { 17 | bus.emit(BusEvent.HideResults); 18 | bus.emit(BusEvent.ShowLoading); 19 | 20 | worker 21 | .recognize(image) 22 | .then(result => { 23 | const processedCode = postProcessCode(result.text); 24 | 25 | bus.emit(BusEvent.ImageProcessed, null, processedCode); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /app/scripts/post-processors/empty-array.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Description: When the code have an empty array returns [1; 3 | * Input: const a = []; 4 | * Output: const a = [1; 5 | */ 6 | export function emptyArray(code) { 7 | 8 | return code.replace(/\[1;/g, '[];'); 9 | } 10 | -------------------------------------------------------------------------------- /app/scripts/post-processors/index.js: -------------------------------------------------------------------------------- 1 | export * from './template-string'; 2 | export * from './empty-array'; 3 | -------------------------------------------------------------------------------- /app/scripts/post-processors/template-string.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Description: Tempalte string quotes are wrong 3 | * Input: const a = `1`; 4 | * Output: const a = ‘1‘; 5 | */ 6 | export function templateString(code) { 7 | return code.replace(/‘/g, '`'); 8 | } 9 | -------------------------------------------------------------------------------- /app/scripts/sandbox.js: -------------------------------------------------------------------------------- 1 | import { getParameters } from 'codesandbox/lib/api/define'; 2 | import { bus, BusEvent } from './bus'; 3 | // import { js } from 'js-beautify'; 4 | 5 | export function generateSandbox(code) { 6 | const parameters = getParameters({ 7 | files: { 8 | 'index.js': { 9 | content: code 10 | }, 11 | 'package.json': { 12 | content: { dependencies: {} } 13 | } 14 | } 15 | }); 16 | 17 | bus.emit(BusEvent.LinkGenerated, null, `https://codesandbox.io/api/v1/sandboxes/define?parameters=${parameters}`); 18 | } 19 | -------------------------------------------------------------------------------- /app/scripts/vendor.js: -------------------------------------------------------------------------------- 1 | // If you use usage in babelrc dont import polyfilll import '@babel/polyfill'; 2 | -------------------------------------------------------------------------------- /app/styles/app.scss: -------------------------------------------------------------------------------- 1 | // Vendor 2 | @import 3 | 'vendor/normalize', 4 | 'vendor/bootstrap', 5 | 'vendor/filepond'; 6 | 7 | // Base Helpers 8 | @import 9 | 'base/fonts', 10 | 'base/icons', 11 | 'base/states', 12 | 'base/utilities'; 13 | 14 | // Base Files 15 | @import 'base/globals'; 16 | 17 | // Components 18 | @import 'components/conversor'; 19 | -------------------------------------------------------------------------------- /app/styles/base/_fonts.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Font-face generator for all the fonts of the project, 3 | // will be useful to add different files for each font. 4 | // 5 | 6 | @import 'variables'; 7 | @import 'mixins/fonts'; 8 | 9 | @include font-include(OpenSans, Light, font-weight(light), normal); 10 | @include font-include(OpenSans, Regular, font-weight(regular), normal); 11 | @include font-include(OpenSans, Bold, font-weight(bold), normal); 12 | -------------------------------------------------------------------------------- /app/styles/base/_globals.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Define global styles for the application, 3 | // usually html and body content. 4 | // 5 | 6 | @import 'variables'; 7 | 8 | html, 9 | body { 10 | $font-size: 16px; 11 | 12 | align-content: center; 13 | align-items: center; 14 | background: get-color(basic, brightest); 15 | color: get-color(basic, darkest); 16 | display: flex; 17 | font-family: OpenSans; 18 | font-size: $font-size * .65; 19 | flex-direction: column; 20 | justify-content: center; 21 | height: 100%; 22 | width: 100%; 23 | 24 | @media screen and (min-width: get-media(s)) { 25 | font-size: $font-size * .8; 26 | } 27 | 28 | @media screen and (max-width: get-media(m)) { 29 | font-size: $font-size; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/styles/base/_icons.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Create a map for all the icons of the app, 3 | // will generate automatically all the icon classes. 4 | // 5 | // How to use: 6 | //
7 | // 8 | 9 | @import 'mixins/icomoon'; 10 | 11 | $icons: ( 12 | ck-play: e900 13 | ); 14 | 15 | @include icomoon-generate($icons); 16 | -------------------------------------------------------------------------------- /app/styles/base/_states.scss: -------------------------------------------------------------------------------- 1 | // 2 | // States to use on the elements of the app, 3 | // are useful to define a temporary class that 4 | // will be added or removed via JavaScript event. 5 | // 6 | // How to use: 7 | //
8 | // 9 | 10 | @import 'variables'; 11 | @import 'mixins/media-suffixes'; 12 | 13 | .is { 14 | &-hidden { 15 | display: none !important; 16 | } 17 | 18 | &-disabled { 19 | @include media-suffixes { 20 | opacity: .5; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/styles/base/_utilities.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Helpers with typical values that you need, 3 | // in the app, by default we usually use 4 | // Bootstrap utilities but, you can define more here. 5 | // 6 | // How to use: 7 | //
8 | // 9 | 10 | @import 'variables'; 11 | @import './mixins/map-utilities'; 12 | 13 | .u { 14 | &-align { 15 | &-center { 16 | text-align: center; 17 | } 18 | 19 | &-left { 20 | text-align: left; 21 | } 22 | 23 | &-right { 24 | text-align: right; 25 | } 26 | } 27 | 28 | @include map-utilities(color, get-color, secondary, dark); 29 | } 30 | -------------------------------------------------------------------------------- /app/styles/base/_variables-definitions.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Basic variables for the application, 3 | // to import variables you have to import 4 | // the file `variables.scss`. 5 | // 6 | // Consider to use 'shirt' sizes for naming if you can, 7 | // typical shirt sizes are xs, s, m, l ,xl 8 | // but you can add more xxxs, xxs, s, sm, m, ml, xxxxxl. 9 | // 10 | 11 | // Colors 12 | $color-primary: ( 13 | brightest: null, 14 | brighter: null, 15 | bright: #48DDDD, 16 | normal: #06B2B1, 17 | dark: #0E2E2E, 18 | darker: null, 19 | darkest: #06131F 20 | ); 21 | 22 | $color-secondary: ( 23 | normal: #FFDD2E, 24 | dark: #D1B425, 25 | ); 26 | 27 | $color-basic: ( 28 | brightest: #FFFFFF, 29 | brighter: #E7E7E7, 30 | bright: #DADADA, 31 | normal: null, 32 | dark: #9C9C9C, 33 | darker: #585858, 34 | darkest: #131313 35 | ); 36 | 37 | // Add all colors to this map 38 | $color: ( 39 | primary: $color-primary, 40 | secondary: $color-secondary, 41 | basic: $color-basic, 42 | ); 43 | 44 | // Times 45 | $time: ( 46 | slow: .5s, 47 | normal: .35s, 48 | fast: .15s 49 | ); 50 | 51 | // Fonts 52 | $font-weight: ( 53 | light: 200, 54 | semilight: 300, 55 | normal: 500, 56 | semibold: 600, 57 | bold: 700, 58 | black: 800 59 | ); 60 | 61 | $font-size: ( 62 | xs: .5rem, // 8px 63 | s: .85rem, // 13.6px 64 | m: 1rem, // [16px] 65 | l: 1.25rem, // 20px 66 | xl: 1.5rem // 24px 67 | ); 68 | 69 | // Medias (Only as example, use the values you really need) 70 | $media: ( 71 | xxs: 360px, 72 | xs: 640px, 73 | s: 768px, 74 | m: 1024px, 75 | l: 1280px, 76 | xl: 1440px 77 | ); 78 | 79 | // Z-index 80 | $z: ( 81 | xs: 1, 82 | s: 10, 83 | m: 20, 84 | l: 30, 85 | xl: 50, 86 | xxl: 100 87 | ); 88 | -------------------------------------------------------------------------------- /app/styles/base/_variables.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Wrappers for project variables, to create a new variable 3 | // please use `variables-definitions.scss` file. 4 | // 5 | // If you want to use a variable, import `variables.scss` file, 6 | // and add the corresponding map-get wrapper here. 7 | // 8 | 9 | /* stylelint-disable */ 10 | @import './variables-definitions'; 11 | @import './mixins/generic-get'; 12 | 13 | // Special map for colors 14 | @function get-color($namespace, $variance: normal) { 15 | $color-map: get($color, $namespace); 16 | 17 | @return get($color-map, $variance); 18 | } 19 | 20 | // Generic maps 21 | @function get-time($key: normal) { @return get($time, $key); } 22 | @function get-font-weight($key: m) { @return get($font-weight, $key); } 23 | @function get-font-size($key: m) { @return get($font-size, $key); } 24 | @function get-media($key: m) { @return get($media, $key); } 25 | @function get-z($key: m) { @return get($z, $key); } 26 | -------------------------------------------------------------------------------- /app/styles/base/mixins/_fonts.scss: -------------------------------------------------------------------------------- 1 | /* stylelint-disable */ 2 | // @Author https://gist.github.com/jonathantneal/d0460e5c2d5d7f9bc5e6 3 | 4 | // ============================================================================= 5 | // String Replace 6 | // ============================================================================= 7 | 8 | @function str-replace($string, $search, $replace: '') { 9 | $index: str-index($string, $search); 10 | 11 | @if $index { 12 | @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); 13 | } 14 | 15 | @return $string; 16 | } 17 | 18 | // ============================================================================= 19 | // Font Face 20 | // ============================================================================= 21 | 22 | @mixin font-face($name, $path, $weight: null, $style: null, $exts: eot woff ttf svg) { 23 | $src: null; 24 | 25 | $extmods: ( eot: '?', svg: '#' + str-replace($name, ' ', '_') ); 26 | 27 | $formats: ( otf: 'opentype', ttf: 'truetype' ); 28 | 29 | @each $ext in $exts { 30 | $extmod: if(map-has-key($extmods, $ext), $ext + map-get($extmods, $ext), $ext); 31 | $format: if(map-has-key($formats, $ext), map-get($formats, $ext), $ext); 32 | $src: append($src, url(quote($path + '.' + $extmod)) format(quote($format)), comma); 33 | } 34 | 35 | @font-face { 36 | font-family: quote($name); 37 | font-style: $style; 38 | font-weight: $weight; 39 | src: $src; 40 | } 41 | } 42 | 43 | @mixin font-include($font, $type, $weight: null, $style: null) { 44 | @include font-face($font, '~assets/fonts/' + $font + '/' + $font + '-' + $type, $weight, $style); 45 | } 46 | -------------------------------------------------------------------------------- /app/styles/base/mixins/_generic-get.scss: -------------------------------------------------------------------------------- 1 | @function get($map, $key) { 2 | @if map-has-key($map, $key) { 3 | @return map-get($map, $key); 4 | } 5 | 6 | @error 'Invalid key: `#{$key}` for map `#{$map}`'; 7 | } 8 | -------------------------------------------------------------------------------- /app/styles/base/mixins/_icomoon.scss: -------------------------------------------------------------------------------- 1 | /* stylelint-disable */ 2 | @mixin icomoon { 3 | @font-face { 4 | font-family: 'Icomoon'; 5 | src: url('/fonts/Icomoon/icomoon.eot?pjsjp3'); 6 | src: url('/fonts/Icomoon/icomoon.eot?pjsjp3#iefix') format('embedded-opentype'), url('/fonts/Icomoon/icomoon.ttf?pjsjp3') format('truetype'), url('/fonts/Icomoon/icomoon.woff?pjsjp3') format('woff'), url('/fonts/Icomoon/icomoon.svg?pjsjp3#Icomoon') format('svg'); 7 | font-weight: normal; 8 | font-style: normal; 9 | } 10 | 11 | [class^='icon-'], [class*=' icon-'] { 12 | /* use !important to prevent issues with browser extensions that change fonts */ 13 | font-family: 'Icomoon' !important; 14 | speak: none; 15 | font-style: normal; 16 | font-weight: normal; 17 | font-variant: normal; 18 | text-transform: none; 19 | line-height: 1; 20 | /* Better Font Rendering =========== */ 21 | -webkit-font-smoothing: antialiased; 22 | -moz-osx-font-smoothing: grayscale; 23 | } 24 | 25 | } 26 | 27 | @function unicode($str){ 28 | @return unquote('\'') + unquote(str-insert($str, '\\', 1)) + unquote('\''); 29 | } 30 | 31 | @mixin icomoon-generate($icons) { 32 | @include icomoon(); 33 | 34 | @each $key, $value in $icons { 35 | .icon-#{$key}:before { 36 | content: unicode($value); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /app/styles/base/mixins/_map-utilities.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Mixin to generate utility classes for any map variable 3 | // 4 | // Example: 5 | // .u { 6 | // @include map-utilities(color, get-color, secondary, dark); 7 | // @include map-utilities(color, get-color, secondary); 8 | // @include map-utilities(border-color, get-color, primary, bright); 9 | // } 10 | // 11 | // Generates the following css 12 | // .u-color-secondary-dark { 13 | // color: #D1B425; } 14 | 15 | // .u-color-secondary { 16 | // color: #FFDD2E; } 17 | 18 | // .u-border-color-primary-bright { 19 | // border-color: #48DDDD; } 20 | // 21 | // And can be used like 22 | //
23 | // 24 | 25 | @import '../variables'; 26 | 27 | // map-utilities(get-color, secondary, dark); 28 | @mixin map-utilities($prop, $map, $key, $key2: null) { 29 | $result: call($map, $key); 30 | $extra: ''; 31 | 32 | @if ($key2) { 33 | $result: call($map, $key, $key2); 34 | $extra: '-#{$key2}'; 35 | } 36 | 37 | &-#{$prop}-#{$key}#{$extra} { 38 | #{$prop}: $result; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/styles/base/mixins/_media-suffixes.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Mixin to generate media suffixes for any class. 3 | // 4 | // Example: 5 | // .a { 6 | // @include media-suffixes { 7 | // opacity: 1; 8 | // } 9 | // } 10 | // 11 | // Generates the following css 12 | // .a { 13 | // opacity: 0; } 14 | // @media screen and (max-width: 640px) { 15 | // .a\@xs { 16 | // opacity: 0; } } 17 | // @media screen and (max-width: 768px) { 18 | // .a\@s { 19 | // opacity: 0; } } 20 | // ... 21 | // 22 | // And can be used like 23 | //
24 | // That means that the opacity of the div will 25 | // be 0 for screens bigger than 's' media query. 26 | // 27 | 28 | @import '../variables'; 29 | 30 | $medias: xxs, xs, s, m, l, xl; 31 | 32 | @mixin media-suffixes { 33 | @content; 34 | 35 | @each $media in $medias { 36 | &\@#{$media} { 37 | @media screen and (max-width: get-media($media)) { 38 | @content; 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/styles/components/_conversor.scss: -------------------------------------------------------------------------------- 1 | @import '../base/variables'; 2 | 3 | .conversor { 4 | display: flex; 5 | max-width: 60rem; 6 | width: 100%; 7 | 8 | &-content { 9 | margin-top: -20vh; 10 | position: relative; 11 | width: 100%; 12 | } 13 | 14 | &-title { 15 | margin: 0 auto 1rem auto; 16 | text-align: center; 17 | } 18 | 19 | &-subtitle { 20 | font-size: get-font-size(l); 21 | font-weight: get-font-weight(light); 22 | margin: 0 auto 10vh auto; 23 | text-align: center; 24 | } 25 | 26 | &-result { 27 | text-align: center; 28 | } 29 | 30 | &-loading { 31 | align-items: center; 32 | background: rgba(get-color(basic, brightest), .5); 33 | display: flex; 34 | height: 100%; 35 | justify-content: center; 36 | left: 0; 37 | position: absolute; 38 | top: 0; 39 | width: 100%; 40 | } 41 | 42 | &-spinner { 43 | $size: 4rem; 44 | 45 | height: $size; 46 | width: $size; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/styles/vendor/_bootstrap.scss: -------------------------------------------------------------------------------- 1 | @import '../base/variables'; 2 | 3 | $grid-breakpoints: ( 4 | xs: 0, 5 | sm: get-media(xs) + 1, 6 | md: get-media(s) + 1, 7 | lg: get-media(m) + 1, 8 | xl: get-media(l) + 1 9 | ); 10 | 11 | $container-max-widths: ( 12 | sm: get-media(xs), 13 | md: get-media(s), 14 | lg: get-media(m), 15 | xl: get-media(l) 16 | ); 17 | 18 | $primary: get-color(primary); 19 | $secondary: get-color(secondary); 20 | 21 | $link-color: auto; 22 | $link-hover-color: auto; 23 | $link-hover-decoration: none; 24 | 25 | @import '../../../node_modules/bootstrap/scss/functions'; 26 | @import '../../../node_modules/bootstrap/scss/variables'; 27 | @import '../../../node_modules/bootstrap/scss/mixins'; 28 | @import '../../../node_modules/bootstrap/scss/root'; 29 | // @import '../../../node_modules/bootstrap/scss/reboot'; 30 | @import '../../../node_modules/bootstrap/scss/images'; 31 | // @import '../../../node_modules/bootstrap/scss/type'; 32 | // @import '../../../node_modules/bootstrap/scss/code'; 33 | @import '../../../node_modules/bootstrap/scss/grid'; 34 | // @import '../../../node_modules/bootstrap/scss/tables'; 35 | // @import '../../../node_modules/bootstrap/scss/forms'; 36 | @import '../../../node_modules/bootstrap/scss/buttons'; 37 | // @import '../../../node_modules/bootstrap/scss/transitions'; 38 | @import '../../../node_modules/bootstrap/scss/dropdown'; 39 | // @import '../../../node_modules/bootstrap/scss/button-group'; 40 | // @import '../../../node_modules/bootstrap/scss/input-group'; 41 | // @import '../../../node_modules/bootstrap/scss/custom-forms'; 42 | @import '../../../node_modules/bootstrap/scss/nav'; 43 | @import '../../../node_modules/bootstrap/scss/navbar'; 44 | // @import '../../../node_modules/bootstrap/scss/card'; 45 | // @import '../../../node_modules/bootstrap/scss/breadcrumb'; 46 | // @import '../../../node_modules/bootstrap/scss/pagination'; 47 | // @import '../../../node_modules/bootstrap/scss/badge'; 48 | // @import '../../../node_modules/bootstrap/scss/jumbotron'; 49 | // @import '../../../node_modules/bootstrap/scss/alert'; 50 | // @import '../../../node_modules/bootstrap/scss/progress'; 51 | // @import '../../../node_modules/bootstrap/scss/media'; 52 | // @import '../../../node_modules/bootstrap/scss/list-group'; 53 | // @import '../../../node_modules/bootstrap/scss/close'; 54 | // @import '../../../node_modules/bootstrap/scss/modal'; 55 | // @import '../../../node_modules/bootstrap/scss/tooltip'; 56 | // @import '../../../node_modules/bootstrap/scss/popover'; 57 | // @import '../../../node_modules/bootstrap/scss/carousel'; 58 | @import '../../../node_modules/bootstrap/scss/utilities'; 59 | // @import '../../../node_modules/bootstrap/scss/print'; 60 | @import '../../../node_modules/bootstrap/scss/spinners'; 61 | -------------------------------------------------------------------------------- /app/styles/vendor/_filepond.scss: -------------------------------------------------------------------------------- 1 | /* stylelint-disable */ 2 | @import '../../node_modules/filepond/dist/filepond.css'; 3 | -------------------------------------------------------------------------------- /app/styles/vendor/_normalize.scss: -------------------------------------------------------------------------------- 1 | /* stylelint-disable */ 2 | @import '../../node_modules/normalize-scss/sass/normalize/variables'; 3 | @import '../../node_modules/normalize-scss/sass/normalize/vertical-rhythm'; 4 | @import '../../node_modules/normalize-scss/sass/normalize/normalize-mixin'; 5 | @include normalize; 6 | 7 | *, 8 | *::before, 9 | *::after { 10 | box-sizing: border-box; 11 | } 12 | 13 | a, 14 | a:active, 15 | a:hover, 16 | a:visited { 17 | text-decoration: none; 18 | } 19 | -------------------------------------------------------------------------------- /cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "http://localhost:4000", 3 | "pluginsFile": "tests/e2e/plugins/index.js" 4 | } -------------------------------------------------------------------------------- /dist/CNAME: -------------------------------------------------------------------------------- 1 | screentocodesandbox.js.org 2 | -------------------------------------------------------------------------------- /dist/fonts/05d1a99a91a5552d048ca2f15505fdb7.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/05d1a99a91a5552d048ca2f15505fdb7.woff -------------------------------------------------------------------------------- /dist/fonts/1bf71be111189e76987a4bb9b3115cb7.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/1bf71be111189e76987a4bb9b3115cb7.ttf -------------------------------------------------------------------------------- /dist/fonts/50145685042b4df07a1fd19957275b81.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/50145685042b4df07a1fd19957275b81.ttf -------------------------------------------------------------------------------- /dist/fonts/55bfb3e43457ec893f128c2d73f76457.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/55bfb3e43457ec893f128c2d73f76457.eot -------------------------------------------------------------------------------- /dist/fonts/629a55a7e793da068dc580d184cc0e31.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/629a55a7e793da068dc580d184cc0e31.ttf -------------------------------------------------------------------------------- /dist/fonts/87051a9d79eb9fc8c317b5777320f78d.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/87051a9d79eb9fc8c317b5777320f78d.woff -------------------------------------------------------------------------------- /dist/fonts/885e3d6f49fb6783494654e69793e802.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/885e3d6f49fb6783494654e69793e802.eot -------------------------------------------------------------------------------- /dist/fonts/90327f5ac43d0fbc708f3653ffc0a043.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/90327f5ac43d0fbc708f3653ffc0a043.woff -------------------------------------------------------------------------------- /dist/fonts/e1d396939867c493f06f2bbc071993d9.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/dist/fonts/e1d396939867c493f06f2bbc071993d9.eot -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Screenshot to CodeSandbox conversor 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

13 | Screenshot to CodeSandbox conversor 14 |

15 |

16 | Convert your code screenshots to Code Sandbox projects in a second. 17 |

18 |
19 | 22 | 23 | 26 |
27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | moduleFileExtensions: [ 3 | 'js', 4 | 'json' 5 | ], 6 | transformIgnorePatterns: [ 7 | '/node_modules/' 8 | ], 9 | moduleNameMapper: { 10 | '^@/(.*)$': '/src/$1' 11 | }, 12 | testMatch: [ 13 | '**/**/*.test.(js)|**/tests/unit/*.(js)' 14 | ], 15 | testURL: 'http://localhost/' 16 | }; 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-spa", 3 | "description": "Stable version of a basic SPA example with SCSS and ES6.", 4 | "license": "MIT", 5 | "version": "2.4.1", 6 | "scripts": { 7 | "prod": "webpack --env.NODE_ENV=production", 8 | "dev": "webpack --env.NODE_ENV=development", 9 | "start": "webpack-dev-server --env.NODE_ENV=development --hot --open", 10 | "test": "npm run test:unit && npm run test:e2e", 11 | "test:unit": "jest", 12 | "test:e2e:cypress": "cypress run", 13 | "test:e2e": "start-server-and-test start http-get://localhost:4000 test:e2e:cypress", 14 | "lint": "npm run lint:scripts && npm run lint:styles", 15 | "lint:scripts": "eslint \"./app/**/*.js\"", 16 | "lint:styles": "stylelint \"./app/**/*.scss\"", 17 | "publish": "git subtree push --prefix dist origin gh-pages" 18 | }, 19 | "husky": { 20 | "hooks": {} 21 | }, 22 | "dependencies": { 23 | "@babel/polyfill": "^7.4.3", 24 | "bootstrap": "^4.3.1", 25 | "codesandbox": "^2.1.6", 26 | "cypress": "^3.2.0", 27 | "filepond": "^4.4.7", 28 | "js-beautify": "^1.10.0", 29 | "js-event-bus": "^1.0.0", 30 | "normalize-scss": "7.0.1", 31 | "tesseract.js": "^4.0.2" 32 | }, 33 | "devDependencies": { 34 | "@babel/core": "^7.3.4", 35 | "@babel/plugin-syntax-dynamic-import": "^7.2.0", 36 | "@babel/preset-env": "^7.3.4", 37 | "@babel/register": "^7.0.0", 38 | "@cypress/webpack-preprocessor": "^4.0.3", 39 | "autoprefixer": "^9.5.0", 40 | "babel-jest": "^24.7.1", 41 | "babel-loader": "^8.0.5", 42 | "css-loader": "^2.1.1", 43 | "eslint": "^5.16.0", 44 | "eslint-plugin-cypress": "^2.2.1", 45 | "file-loader": "^3.0.1", 46 | "html-webpack-plugin": "^3.2.0", 47 | "husky": "^1.3.1", 48 | "jest": "^24.7.1", 49 | "mini-css-extract-plugin": "^0.5.0", 50 | "node-sass": "^4.11.0", 51 | "postcss-loader": "^3.0.0", 52 | "require.all": "^2.0.4", 53 | "sass-loader": "^7.1.0", 54 | "start-server-and-test": "^1.7.13", 55 | "style-loader": "^0.23.1", 56 | "stylelint": "^9.10.1", 57 | "stylelint-config-standard": "^18.2.0", 58 | "stylelint-processor-html": "^1.0.0", 59 | "stylelint-scss": "^3.5.4", 60 | "uglifyjs-webpack-plugin": "^2.1.2", 61 | "webpack": "^4.29.6", 62 | "webpack-cli": "^3.2.3", 63 | "webpack-dev-server": "^3.2.1" 64 | }, 65 | "repository": "https://github.com/CKGrafico/Frontend-Boilerplates#frontend-boilerplates", 66 | "author": "https://github.com/CKGrafico/Frontend-Boilerplates#-contributors" 67 | } 68 | -------------------------------------------------------------------------------- /tasks/plugins/extract-styles.js: -------------------------------------------------------------------------------- 1 | const MiniCSSExtractPlugin = require('mini-css-extract-plugin'); 2 | 3 | module.exports = (env) => { 4 | const defaultConfig = new MiniCSSExtractPlugin(); 5 | 6 | const plugin = { 7 | production: defaultConfig 8 | }; 9 | 10 | return plugin[env]; 11 | }; 12 | -------------------------------------------------------------------------------- /tasks/plugins/globals.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | 3 | module.exports = (env) => { 4 | const defaultConfig = new webpack.DefinePlugin({ 5 | 'global': {} 6 | }); 7 | 8 | const plugin = { 9 | production: defaultConfig, 10 | development: defaultConfig 11 | }; 12 | 13 | return plugin[env]; 14 | }; 15 | -------------------------------------------------------------------------------- /tasks/plugins/html.js: -------------------------------------------------------------------------------- 1 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 2 | 3 | module.exports = (env) => { 4 | const defaultConfig = new HtmlWebpackPlugin({ 5 | hash: true, 6 | filename: 'index.html', 7 | template: './app/index.html' 8 | }); 9 | 10 | const plugin = { 11 | production: defaultConfig, 12 | development: defaultConfig 13 | }; 14 | 15 | return plugin[env]; 16 | }; 17 | -------------------------------------------------------------------------------- /tasks/plugins/uglify.js: -------------------------------------------------------------------------------- 1 | const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); 2 | 3 | module.exports = (env) => { 4 | const defaultConfig = new UglifyJSPlugin({ 5 | uglifyOptions: { 6 | keep_classnames: true, 7 | keep_fnames: true, 8 | } 9 | }); 10 | 11 | const plugin = { 12 | production: defaultConfig 13 | }; 14 | 15 | return plugin[env]; 16 | }; 17 | -------------------------------------------------------------------------------- /tasks/rules/files.js: -------------------------------------------------------------------------------- 1 | module.exports = (env) => { 2 | return [ 3 | { 4 | test: /\.(png|jpg|gif)$/, 5 | use: [ 6 | { 7 | loader: 'file-loader', 8 | options: { 9 | outputPath: 'images', 10 | }, 11 | }, 12 | ], 13 | }, 14 | { 15 | test: /\.(woff(2)?|ttf|eot|svg)$/, 16 | use: [ 17 | { 18 | loader: 'file-loader', 19 | options: { 20 | outputPath: 'fonts', 21 | }, 22 | }, 23 | ], 24 | } 25 | ] 26 | }; 27 | -------------------------------------------------------------------------------- /tasks/rules/scripts.js: -------------------------------------------------------------------------------- 1 | module.exports = (env) => { 2 | return { 3 | test: /\.js$/, 4 | exclude: /node_modules/, 5 | use: [ 6 | { 7 | loader: 'babel-loader' 8 | } 9 | ] 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /tasks/rules/styles.js: -------------------------------------------------------------------------------- 1 | const MiniCSSExtractPlugin = require('mini-css-extract-plugin'); 2 | 3 | module.exports = (env) => { 4 | const styleLoaders = { 5 | production: MiniCSSExtractPlugin.loader, 6 | development: 'style-loader' 7 | }; 8 | 9 | return { 10 | test: /\.scss$/, 11 | exclude: /node_modules/, 12 | use: [{ 13 | loader: styleLoaders[env] // Creates style nodes from JS strings 14 | }, 15 | { 16 | loader: 'css-loader' // Translates CSS into CommonJS 17 | }, 18 | { 19 | loader: 'postcss-loader', // More CSS Plugins 20 | options: { 21 | plugins: () => [require('autoprefixer')({ 22 | 'browsers': ['last 2 versions'] 23 | })], 24 | } 25 | }, 26 | { 27 | loader: 'sass-loader', // Compiles Sass to CSS, using Node Sass by default 28 | options: { 29 | //includePaths: ['absolute/path/a'] 30 | } 31 | }] 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /tests/e2e/plugins/index.js: -------------------------------------------------------------------------------- 1 | const wp = require('@cypress/webpack-preprocessor') 2 | 3 | module.exports = (on, config) => { 4 | const options = { 5 | webpackOptions: require('../../../webpack.config'), 6 | } 7 | on('file:preprocessor', wp(options)) 8 | 9 | return Object.assign({}, config, { 10 | fixturesFolder: 'tests/e2e/fixtures', 11 | integrationFolder: 'tests/e2e/specs', 12 | screenshotsFolder: 'tests/e2e/screenshots', 13 | videosFolder: 'tests/e2e/videos' 14 | }) 15 | } -------------------------------------------------------------------------------- /tests/e2e/specs/app.spec.js: -------------------------------------------------------------------------------- 1 | describe('My First Test', function() { 2 | it('Visits the Kitchen Sink', function() { 3 | cy.visit('/') 4 | }) 5 | }) -------------------------------------------------------------------------------- /tests/e2e/videos/app.spec.js.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CKGrafico/ScreenshotToCodeSandbox/dc8f45971d89373fe1770ff855836816bf59508f/tests/e2e/videos/app.spec.js.mp4 -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const rules = require('require.all')('./tasks/rules'); 3 | const plugins = require('require.all')('./tasks/plugins'); 4 | 5 | module.exports = env => { 6 | let environment = env.NODE_ENV; 7 | env.NODE_ENV = JSON.stringify(environment); 8 | 9 | rules((name, rule) => rule(environment)); 10 | plugins((name, rule) => rule(environment)); 11 | 12 | return ({ 13 | mode: environment, 14 | entry: { 15 | app: [ 16 | path.resolve(__dirname, 'app/scripts/app.js'), 17 | path.resolve(__dirname, 'app/styles/app.scss') 18 | ] 19 | }, 20 | output: { 21 | filename: '[name].js' 22 | }, 23 | module: { 24 | rules: [ 25 | ...rules.files, 26 | rules.scripts, 27 | rules.styles 28 | ] 29 | }, 30 | plugins: [ 31 | plugins.html, 32 | plugins.globals, 33 | plugins.extractStyles 34 | ], 35 | devServer: { 36 | open: true, 37 | port: 4000, 38 | https: false, 39 | hot: true, 40 | historyApiFallback: true, 41 | watchOptions: { 42 | poll: true 43 | } 44 | // proxy: { '/api': 'http://localhost:3000' } 45 | }, 46 | optimization: { 47 | minimizer: [plugins.uglify], 48 | splitChunks: { 49 | cacheGroups: { 50 | vendor: { 51 | chunks: 'all', 52 | test: path.resolve(__dirname, 'node_modules'), 53 | name: 'vendor', 54 | enforce: true 55 | } 56 | } 57 | } 58 | }, 59 | resolve: { 60 | alias: { 61 | 'styles': path.resolve(__dirname, 'app/styles'), 62 | 'assets': path.resolve(__dirname, 'app/assets'), 63 | '~': path.resolve(__dirname, 'app/scripts') 64 | } 65 | }, 66 | devtool: (() => environment === 'production' ? false : 'inline-source-map')() 67 | }); 68 | }; 69 | --------------------------------------------------------------------------------