Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
umairsiddique committed Sep 7, 2018
0 parents commit e88eea1
Show file tree
Hide file tree
Showing 96 changed files with 82,423 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": ["env"],
"plugins": [
"syntax-object-rest-spread",
"transform-object-rest-spread"
]
}
101 changes: 101 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
env:
browser: true

parser: babel-eslint

plugins: [ "import" ]

# enable ECMAScript features
ecmaFeatures:
arrowFunctions: true
binaryLiterals: true
blockBindings: true
classes: true
defaultParams: true
destructuring: true
forOf: true
generators: true
jsx: true
modules: true
objectLiteralShorthandMethods: true
objectLiteralShorthandProperties: true
octalLiterals: true
spread: true
templateStrings: true

rules:
# Possible Errors
# https://github.com/eslint/eslint/tree/master/docs/rules#possible-errors
no-control-regex: 2
no-console: 1
no-debugger: 2
no-dupe-args: 2
no-dupe-keys: 2
no-duplicate-case: 2
no-empty-character-class: 2
no-ex-assign: 2
no-extra-boolean-cast : 2
no-extra-semi: 2
no-invalid-regexp: 2
no-irregular-whitespace: 1
no-proto: 2
no-unexpected-multiline: 2
no-unreachable: 2
valid-typeof: 2

# Best Practices
# https://github.com/eslint/eslint/tree/master/docs/rules#best-practices
no-fallthrough: 2
no-redeclare: 2

# Stylistic Issues
# https://github.com/eslint/eslint/tree/master/docs/rules#stylistic-issues
comma-spacing: 2
eol-last: 2
eqeqeq: ["error", "smart"]
indent: [2, 2, {SwitchCase: 1}]
keyword-spacing: 2
max-len: [1, 160, 2]
new-parens: 2
no-mixed-spaces-and-tabs: 2
no-multiple-empty-lines: [2, {max: 2}]
no-trailing-spaces: 2
object-curly-spacing: [2, "never"]
quotes: [2, "double", "avoid-escape"]
semi: 2
space-before-blocks: [2, "always"]
space-before-function-paren: [2, "never"]
space-in-parens: [2, "never"]
space-infix-ops: 2
space-unary-ops: 2

# ECMAScript 6
# http://eslint.org/docs/rules/#ecmascript-6
arrow-parens: [2, "always"]
arrow-spacing: [2, {"before": true, "after": true}]
no-confusing-arrow: 2
prefer-const: 2

# JSX
jsx-quotes: [2, "prefer-double"]

# Import
import/no-unresolved: [1, {"commonjs": true, "amd": true}]
import/export: 2

# Strict Mode
# https://github.com/eslint/eslint/tree/master/docs/rules#strict-mode
strict: [2, "global"]

# Variables
# https://github.com/eslint/eslint/tree/master/docs/rules#variables
no-undef: 2
no-unused-vars: [2, {"args": "none"}]

# Global scoped method and vars
globals:
__dirname: true
require: true
process: true
ENV: true
module: true
76 changes: 76 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# Parcel build output
dist
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.11.4
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Unlayer Playgrounds
93 changes: 93 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import gulp from "gulp";
import {spawn} from "child_process";
import hugoBin from "hugo-bin";
import log from "fancy-log";
import pluginError from "plugin-error";
import flatten from "gulp-flatten";
import postcss from "gulp-postcss";
import cssImport from "postcss-import";
import cssnext from "postcss-cssnext";
import BrowserSync from "browser-sync";
import webpack from "webpack";
import webpackConfig from "./webpack.conf";

const browserSync = BrowserSync.create();

// Hugo arguments
const hugoArgsDefault = ["-d", "../dist", "-s", "site", "-v"];
const hugoArgsPreview = ["--buildDrafts", "--buildFuture"];

// Development tasks
gulp.task("hugo", (cb) => buildSite(cb));
gulp.task("hugo-preview", (cb) => buildSite(cb, hugoArgsPreview));

// Run server tasks
gulp.task("server", ["hugo", "css", "js", "fonts"], (cb) => runServer(cb));
gulp.task("server-preview", ["hugo-preview", "css", "js", "fonts"], (cb) => runServer(cb));

// Build/production tasks
gulp.task("build", ["css", "js", "fonts"], (cb) => buildSite(cb, [], "production"));
gulp.task("build-preview", ["css", "js", "fonts"], (cb) => buildSite(cb, hugoArgsPreview, "production"));

// Compile CSS with PostCSS
gulp.task("css", () => (
gulp.src("./src/css/*.css")
.pipe(postcss([cssImport({from: "./src/css/main.css"}), cssnext()]))
.pipe(gulp.dest("./dist/css"))
.pipe(browserSync.stream())
));

// Compile Javascript
gulp.task("js", (cb) => {
const myConfig = Object.assign({}, webpackConfig);

webpack(myConfig, (err, stats) => {
if (err) throw new pluginError("webpack", err);
log(`[webpack] ${stats.toString({
colors: true,
progress: true
})}`);
browserSync.reload();
cb();
});
});

// Move all fonts in a flattened directory
gulp.task('fonts', () => (
gulp.src("./src/fonts/**/*")
.pipe(flatten())
.pipe(gulp.dest("./dist/fonts"))
.pipe(browserSync.stream())
));

// Development server with browsersync
function runServer() {
browserSync.init({
server: {
baseDir: "./dist"
}
});
gulp.watch("./src/js/**/*.js", ["js"]);
gulp.watch("./src/css/**/*.css", ["css"]);
gulp.watch("./src/fonts/**/*", ["fonts"]);
gulp.watch("./site/**/*", ["hugo"]);
};

/**
* Run hugo and build the site
*/
function buildSite(cb, options, environment = "development") {
const args = options ? hugoArgsDefault.concat(options) : hugoArgsDefault;

process.env.NODE_ENV = environment;

return spawn(hugoBin, args, {stdio: "inherit"}).on("close", (code) => {
if (code === 0) {
browserSync.reload();
cb();
} else {
browserSync.notify("Hugo build failed :(");
cb("Hugo build failed");
}
});
}
22 changes: 22 additions & 0 deletions javascript/basic/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
</head>

<body>
<div id="editor"></div>

<script src="//editor.unlayer.com/embed.js"></script>
<script>
unlayer.init({
id: 'editor',
projectId: 1071,
locale: 'en',
});
</script>

<script src="src/index.js"></script>
</body>
</html>
Loading

0 comments on commit e88eea1

Please sign in to comment.