├── .babelrc
├── index.js
├── public
├── favicon.ico
└── index.html
├── src
├── components
│ ├── index.js
│ ├── Progress.js
│ ├── util.js
│ ├── Step.js
│ ├── Hint.js
│ └── Impress.js
├── images
│ └── swipe-right.png
├── index.js
├── App.test.js
├── App.js
├── demo
│ └── impress-demo.js
└── styles
│ └── _base.scss
├── styles
├── react-impressjs.map
├── react-impressjs.css
└── impress-demo.css
├── .travis.yml
├── .gitignore
├── .npmignore
├── config
├── jest
│ ├── fileTransform.js
│ └── cssTransform.js
├── polyfills.js
├── env.js
├── webpack.config.impress.js
├── paths.js
├── webpack.config.dev.js
├── webpack.config.prod.js
└── webpack.config.impress.prod.js
├── scripts
├── test.js
├── build.js
├── build_impress.js
└── start.js
├── LICENSE
├── package.json
└── README.md
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-0", "react"]
3 | }
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = require('./lib');
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgioWan/react-impressjs/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/src/components/index.js:
--------------------------------------------------------------------------------
1 | export {default as Impress} from './Impress';
2 | export {default as Step} from './Step';
--------------------------------------------------------------------------------
/src/images/swipe-right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgioWan/react-impressjs/HEAD/src/images/swipe-right.png
--------------------------------------------------------------------------------
/styles/react-impressjs.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":[],"names":[],"mappings":"","file":"static/css/main.1cce37d7.css","sourceRoot":""}
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import App from './App';
4 |
5 | ReactDOM.render(
6 | ,
7 | document.getElementById('root')
8 | );
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | notifications:
4 | email:
5 | - georgio.wan@gmail.com
6 |
7 | node_js:
8 | - 7.6.0
9 |
10 | npm:
11 | - 4
12 |
13 | before_install:
14 | - npm install yarn -g
15 | - yarn install
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import App from './App';
4 |
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div');
7 | ReactDOM.render(, div);
8 | });
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 | /lib
12 |
13 | # misc
14 | .DS_Store
15 | .env
16 | npm-debug.log*
17 | yarn-debug.log*
18 | yarn-error.log*
19 |
20 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 |
12 | # misc
13 | .DS_Store
14 | .env
15 | npm-debug.log*
16 | yarn-debug.log*
17 | yarn-error.log*
18 |
19 | /src
20 | /public
21 | /scripts
22 | /config
23 |
24 |
--------------------------------------------------------------------------------
/config/jest/fileTransform.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | // This is a custom Jest transformer turning file imports into filenames.
4 | // http://facebook.github.io/jest/docs/tutorial-webpack.html
5 |
6 | module.exports = {
7 | process(src, filename) {
8 | return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
9 | },
10 | };
11 |
--------------------------------------------------------------------------------
/config/jest/cssTransform.js:
--------------------------------------------------------------------------------
1 | // This is a custom Jest transformer turning style imports into empty objects.
2 | // http://facebook.github.io/jest/docs/tutorial-webpack.html
3 |
4 | module.exports = {
5 | process() {
6 | return 'module.exports = {};';
7 | },
8 | getCacheKey(fileData, filename) {
9 | // The output is always the same.
10 | return 'cssTransform';
11 | },
12 | };
13 |
--------------------------------------------------------------------------------
/scripts/test.js:
--------------------------------------------------------------------------------
1 | process.env.NODE_ENV = 'test';
2 | process.env.PUBLIC_URL = '';
3 |
4 | // Load environment variables from .env file. Suppress warnings using silent
5 | // if this file is missing. dotenv will never modify any environment variables
6 | // that have already been set.
7 | // https://github.com/motdotla/dotenv
8 | require('dotenv').config({silent: true});
9 |
10 | const jest = require('jest');
11 | const argv = process.argv.slice(2);
12 |
13 | // Watch unless on CI or in coverage mode
14 | if (!process.env.CI && argv.indexOf('--coverage') < 0) {
15 | argv.push('--watch');
16 | }
17 |
18 |
19 | jest.run(argv);
20 |
--------------------------------------------------------------------------------
/config/polyfills.js:
--------------------------------------------------------------------------------
1 | if (typeof Promise === 'undefined') {
2 | // Rejection tracking prevents a common issue where React gets into an
3 | // inconsistent state due to an error, but it gets swallowed by a Promise,
4 | // and the user has no idea what causes React's erratic future behavior.
5 | require('promise/lib/rejection-tracking').enable();
6 | window.Promise = require('promise/lib/es6-extensions.js');
7 | }
8 |
9 | // fetch() polyfill for making API calls.
10 | require('whatwg-fetch');
11 |
12 | // Object.assign() is commonly used with React.
13 | // It will use the native implementation if it's present and isn't buggy.
14 | Object.assign = require('object-assign');
15 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Impress, Step } from './components';
3 | //import { Impress, Step } from '../';
4 | import './styles/_base.scss';
5 | //import '../styles/impress-demo.css';
6 |
7 | import demo from './demo/impress-demo';
8 |
9 | class App extends Component {
10 | render() {
11 | return (
12 |
13 | {
14 | demo.map( (d, index ) => {
15 | return (
16 | React.createElement( Step, {
17 | id: d.id,
18 | className: d.className,
19 | data: d.data,
20 | key: index
21 | },
22 | d.content.map( (child, index) => {
23 | return (
24 | React.cloneElement( child, {
25 | id: child.id,
26 | className: child.className,
27 | key: index
28 | })
29 | );
30 | }))
31 |
32 | );
33 | })
34 | }
35 |
36 | );
37 | }
38 | }
39 |
40 | export default App;
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright © 2017 GeorgioWan
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.
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | React-impressJS Demo
8 |
9 |
10 |
11 |
12 |
13 |
Fork
14 |
Star
15 |
React-impressJS © 2017♥OAwan
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/config/env.js:
--------------------------------------------------------------------------------
1 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
2 | // injected into the application via DefinePlugin in Webpack configuration.
3 |
4 | var REACT_APP = /^REACT_APP_/i;
5 |
6 | function getClientEnvironment(publicUrl) {
7 | var raw = Object
8 | .keys(process.env)
9 | .filter(key => REACT_APP.test(key))
10 | .reduce((env, key) => {
11 | env[key] = process.env[key];
12 | return env;
13 | }, {
14 | // Useful for determining whether we’re running in production mode.
15 | // Most importantly, it switches React into the correct mode.
16 | 'NODE_ENV': process.env.NODE_ENV || 'development',
17 | // Useful for resolving the correct path to static assets in `public`.
18 | // For example,
.
19 | // This should only be used as an escape hatch. Normally you would put
20 | // images into the `src` and `import` them in code to get their paths.
21 | 'PUBLIC_URL': publicUrl
22 | });
23 | // Stringify all values so we can feed into Webpack DefinePlugin
24 | var stringified = {
25 | 'process.env': Object
26 | .keys(raw)
27 | .reduce((env, key) => {
28 | env[key] = JSON.stringify(raw[key]);
29 | return env;
30 | }, {})
31 | };
32 |
33 | return { raw, stringified };
34 | }
35 |
36 | module.exports = getClientEnvironment;
37 |
--------------------------------------------------------------------------------
/src/components/Progress.js:
--------------------------------------------------------------------------------
1 | import React, {Component} from 'react';
2 | import {Line} from 'rc-progress';
3 | import PropTypes from 'prop-types';
4 |
5 | export default class Progress extends Component {
6 | render() {
7 | const {progress, stepsData, activeStep, stepsTotal} = this.props;
8 | const color_gold = '#e5b560',
9 | color_gray = '#3e4852';
10 | const ua = navigator.userAgent.toLowerCase();
11 | const progressWidth = (ua.search(/(iphone)|(ipod)|(android)/) === -1)
12 | ? 0.2
13 | : 1;
14 | let currentStepIndex = Object.keys(stepsData).
15 | findIndex((s) => s === activeStep.id) + 1;
16 | let percent = parseInt(currentStepIndex / stepsTotal * 100, 10);
17 |
18 | return (
19 |
25 |
31 |
32 | {currentStepIndex}
33 | {'/' +
34 | stepsTotal}
35 |
36 |
37 |
41 |
42 | );
43 | }
44 | }
45 |
46 | Progress.propTypes = {
47 | /**
48 | * Progress of presentation
49 | */
50 | progress: PropTypes.bool,
51 |
52 | /**
53 | * Steps data
54 | */
55 | stepsData: PropTypes.object,
56 |
57 | /**
58 | * Object representing current step
59 | */
60 | activeStep: PropTypes.shape({
61 | id: PropTypes.string,
62 | }),
63 |
64 | /**
65 | * Amount of steps
66 | */
67 | stepsTotal: PropTypes.number,
68 | };
69 |
--------------------------------------------------------------------------------
/config/webpack.config.impress.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack');
2 | var paths = require('./paths');
3 | var ExtractTextPlugin = require("extract-text-webpack-plugin");
4 |
5 | var publicPath = '/';
6 |
7 | module.exports = {
8 | entry: [
9 | //index: paths.componentPath
10 | //Impress: paths.impressPath,
11 | //Step: paths.stepPath
12 | require.resolve('./polyfills'),
13 | paths.appIndexJs,
14 | ],
15 | output: {
16 | path: paths.appDist,
17 | pathinfo: true,
18 | filename: '[name].js',
19 | publicPath: publicPath
20 | },
21 | resolve: {
22 | fallback: paths.nodePaths,
23 | extensions: ['.js', '.json', '.jsx', ''],
24 | alias: {
25 | 'react-native': 'react-native-web'
26 | }
27 | },
28 | module: {
29 | preLoaders: [
30 | {
31 | test: /\.(js|jsx)$/,
32 | loader: 'eslint',
33 | include: paths.appSrc,
34 | }
35 | ],
36 | loaders: [
37 | {
38 | exclude: [
39 | /\.html$/,
40 | /\.(js|jsx)$/,
41 | /\.css$/,
42 | /\.json$/,
43 | /\.svg$/,
44 | /\.sass$/,
45 | /\.scss$/
46 |
47 | ],
48 | loader: 'url',
49 | query: {
50 | limit: 10000,
51 | name: 'static/media/[name].[hash:8].[ext]'
52 | }
53 | },
54 | {
55 | test: /\.(js|jsx)$/,
56 | include: paths.appSrc,
57 | loader: 'babel',
58 | query: {
59 | cacheDirectory: true
60 | }
61 | },
62 | {
63 | test: /\.css$/,
64 | loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
65 | },
66 | // Scss
67 | {
68 | test: /\.s[ac]ss$/,
69 | include: paths.appSrc,
70 | loader: ExtractTextPlugin.extract(['css', 'sass'])
71 | },
72 | {
73 | test: /\.json$/,
74 | loader: 'json'
75 | },
76 | {
77 | test: /\.svg$/,
78 | loader: 'file',
79 | query: {
80 | name: 'static/media/[name].[hash:8].[ext]'
81 | }
82 | }
83 | ]
84 | },
85 | plugins: [
86 | new ExtractTextPlugin("[name].css")
87 | ]
88 | };
89 |
--------------------------------------------------------------------------------
/src/components/util.js:
--------------------------------------------------------------------------------
1 | export function toNumber(numeric, fallback) {
2 | return isNaN(numeric) ? (fallback || 0) : Number(numeric);
3 | }
4 |
5 | export function translate(data) {
6 | return ' translate3d(' + toNumber(data.x) + 'px, ' + toNumber(data.y) +
7 | 'px, ' + toNumber(data.z) + 'px)';
8 | }
9 |
10 | export function rotate(data, revert) {
11 | let rX = ' rotateX(' + toNumber(data.rotateX) + 'deg) ',
12 | rY = ' rotateY(' + toNumber(data.rotateY) + 'deg) ',
13 | rZ = ' rotateZ(' + toNumber(data.rotateZ) + 'deg) ';
14 |
15 | return revert ? rZ + rY + rX : rX + rY + rZ;
16 | }
17 |
18 | export function scale(data) {
19 | return ' scale(' + toNumber(data, 1) + ')';
20 | }
21 |
22 | export function perspective(p) {
23 | return ' perspective(' + p + 'px) ';
24 | }
25 |
26 | export function computeWindowScale(config) {
27 | let hScale = window.innerHeight / config.height,
28 | wScale = window.innerWidth / config.width,
29 | scale = hScale > wScale ? wScale : hScale;
30 |
31 | if (config.maxScale && scale > config.maxScale) {
32 | scale = config.maxScale;
33 | }
34 |
35 | if (config.minScale && scale < config.minScale) {
36 | scale = config.minScale;
37 | }
38 |
39 | return scale;
40 | }
41 |
42 | export const pfx = (() => {
43 | let style = document.createElement('dummy').style,
44 | prefixes = 'Webkit Moz O ms Khtml'.split(' '),
45 | memory = {};
46 |
47 | return (prop) => {
48 | if (typeof memory[prop] === 'undefined') {
49 | let ucProp = prop.charAt(0).toUpperCase() + prop.substr(1),
50 | props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(
51 | ' ');
52 |
53 | memory[prop] = null;
54 | for (let i in props) {
55 | if (style[props[i]] !== undefined) {
56 | memory[prop] = props[i];
57 | break;
58 | }
59 | }
60 | }
61 |
62 | return memory[prop];
63 | };
64 | })();
65 |
66 | export function css(el, props) {
67 | for (let key in props) {
68 | if (props.hasOwnProperty(key)) {
69 | let pkey = pfx(key);
70 | if (pkey !== null) {
71 | el.style[pkey] = props[key];
72 | }
73 | }
74 | }
75 | return el;
76 | }
77 |
78 | export function throttle(fn, delay) {
79 | let timer = null;
80 | return function() {
81 | let context = this, args = arguments;
82 | clearTimeout(timer);
83 | timer = setTimeout(function() {
84 | fn.apply(context, args);
85 | }, delay);
86 | };
87 | }
88 |
89 | export function getElementFromHash(stepsData) {
90 | let id = window.location.hash.replace(/^#\/?/, '');
91 | return stepsData[id];
92 | }
93 |
--------------------------------------------------------------------------------
/config/paths.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var fs = require('fs');
3 | var url = require('url');
4 |
5 | // Make sure any symlinks in the project folder are resolved:
6 | // https://github.com/facebookincubator/create-react-app/issues/637
7 | var appDirectory = fs.realpathSync(process.cwd());
8 | function resolveApp(relativePath) {
9 | return path.resolve(appDirectory, relativePath);
10 | }
11 |
12 | // We support resolving modules according to `NODE_PATH`.
13 | // This lets you use absolute paths in imports inside large monorepos:
14 | // https://github.com/facebookincubator/create-react-app/issues/253.
15 |
16 | // It works similar to `NODE_PATH` in Node itself:
17 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
18 |
19 | // We will export `nodePaths` as an array of absolute paths.
20 | // It will then be used by Webpack configs.
21 | // Jest doesn’t need this because it already handles `NODE_PATH` out of the box.
22 |
23 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
24 | // Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
25 | // https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
26 |
27 | var nodePaths = (process.env.NODE_PATH || '')
28 | .split(process.platform === 'win32' ? ';' : ':')
29 | .filter(Boolean)
30 | .filter(folder => !path.isAbsolute(folder))
31 | .map(resolveApp);
32 |
33 | var envPublicUrl = process.env.PUBLIC_URL;
34 |
35 | function ensureSlash(path, needsSlash) {
36 | var hasSlash = path.endsWith('/');
37 | if (hasSlash && !needsSlash) {
38 | return path.substr(path, path.length - 1);
39 | } else if (!hasSlash && needsSlash) {
40 | return path + '/';
41 | } else {
42 | return path;
43 | }
44 | }
45 |
46 | function getPublicUrl(appPackageJson) {
47 | return envPublicUrl || require(appPackageJson).homepage;
48 | }
49 |
50 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer
51 | // "public path" at which the app is served.
52 | // Webpack needs to know it to put the right