Skip to content

Commit

Permalink
Initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Oct 23, 2016
1 parent 5482cc8 commit 5bf0ccd
Show file tree
Hide file tree
Showing 26 changed files with 1,024 additions and 3 deletions.
89 changes: 89 additions & 0 deletions .babelrc
@@ -0,0 +1,89 @@
{
"env": {
"commonjs": {
"plugins": [
[
"transform-react-remove-prop-types", {
"mode": "wrap"
}
]
],
"presets": [
"es2015",
"react",
"stage-1"
]
},
"development": {
"plugins": [
"typecheck",
[
"react-transform",
{
"transforms": [
{
"transform": "react-transform-hmr",
"imports": [
"react"
],
"locals": [
"module"
]
},
{
"transform": "react-transform-catch-errors",
"imports": [
"react",
"redbox-react"
]
}
]
}
]
],
"presets": [
"es2015",
"react",
"stage-1"
]
},
"es": {
"plugins": [
"transform-runtime",
[
"transform-react-remove-prop-types", {
"mode": "wrap"
}
]
],
"presets": [
"es2015-rollup",
"react",
"stage-1"
]
},
"production": {
"comments": false,
"plugins": [
"transform-react-remove-prop-types",
"transform-runtime"
],
"presets": [
"es2015",
"react",
"stage-1"
]
},
"test": {
"comments": false,
"plugins": [
"__coverage__"
],
"presets": [
"es2015",
"react",
"stage-1"
]
}
}
}
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
.DS_Store
node_modules
npm-debug.log
build
coverage
dist
10 changes: 10 additions & 0 deletions .npmignore
@@ -0,0 +1,10 @@
build
coverage
docs
source
.*
*.md
circle.yml
index.html
karma.conf.js
webpack.config.*.js
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Brian Vaughn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7 changes: 7 additions & 0 deletions circle.yml
@@ -0,0 +1,7 @@
general:
branches:
ignore:
- gh-pages
machine:
node:
version: v6.6.0
7 changes: 7 additions & 0 deletions examples/render-function.js
@@ -0,0 +1,7 @@
function ExampleComponent ({ foo, bar }) {
return (
<div foo={foo}>
{bar}
</div>
)
}
19 changes: 19 additions & 0 deletions index.html
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<title>react-presents</title>
<meta charset="utf-8">
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />

<link
type='image/x-icon'
rel='shortcut icon'
>

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="https://unpkg.com/codemirror@5.17.0/lib/codemirror.css" />
</head>
<body>
<div id='root'/>
</body>
</html>
103 changes: 100 additions & 3 deletions package.json
Expand Up @@ -2,10 +2,107 @@
"name": "react-presents",
"version": "0.0.1",
"description": "Slideshow framework built w/ react-router 4",
"main": "index.js",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"jsnext:main": "dist/es/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "npm run build:commonjs && npm run build:css && npm run build:es && npm run build:website && npm run build:umd",
"build:commonjs": "npm run clean:commonjs && cross-env NODE_ENV=production cross-env BABEL_ENV=commonjs babel source/modules/ --out-dir dist/commonjs --ignore *.example.js,*.test.js",
"build:css": "postcss --use autoprefixer source/styles.css > dist/styles.css",
"build:website": "npm run clean:website && cross-env NODE_ENV=production webpack --config webpack.config.website.js -p --bail",
"build:es": "npm run clean:es && cross-env NODE_ENV=production cross-env BABEL_ENV=es babel source/modules/ --out-dir dist/es --ignore *.example.js,*.test.js",
"build:umd": "npm run clean:umd && cross-env NODE_ENV=production webpack --config webpack.config.umd.js --bail",
"clean": "npm run clean:commonjs && npm run clean:website && npm run clean:es && npm run clean:umd",
"clean:commonjs": "rimraf dist/commonjs",
"clean:website": "rimraf build",
"clean:es": "rimraf dist/es",
"clean:umd": "rimraf dist/umd",
"deploy": "gh-pages -d build",
"lint": "standard",
"prebuild": "npm run lint",
"predeploy": "cp ./circle.yml ./build/",
"postpublish": "npm run deploy",
"prepublish": "npm run build",
"start": "cross-env NODE_ENV=development webpack-dev-server --hot --inline --config webpack.config.dev.js",
"watch": "watch 'clear && npm run test -s' source",
"watch:nolint": "watch 'clear && npm run test:unit' source"
},
"author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
"license": "MIT"
"license": "MIT",
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "https://github.com/bvaughn/react-presents.git"
},
"keywords": [
"react",
"reactjs",
"slides",
"slideshow",
"presentation"
],
"bugs": {
"url": "https://github.com/bvaughn/react-presents/issues"
},
"standard": {
"parser": "babel-eslint",
"ignore": [
"dist",
"examples"
],
"global": []
},
"devDependencies": {
"autoprefixer": "^6.2.3",
"babel-cli": "6.8.0",
"babel-core": "^6.5.1",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.3",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-react-inline-elements": "^6.6.5",
"babel-plugin-transform-react-remove-prop-types": "^0.2.10",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-plugin-typecheck": "^3.9.0",
"babel-polyfill": "^6.5.0",
"babel-preset-es2015": "^6.5.0",
"babel-preset-es2015-rollup": "^1.1.1",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"bluebird": "^3.0.5",
"cross-env": "^1.0.7",
"css-loader": "^0.23.0",
"express": "^4.13.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"fs-extra": "^0.30.0",
"gh-pages": "^0.11.0",
"html-webpack-plugin": "^2.16.1",
"immutable": "^3.7.5",
"postcss": "^5.0.14",
"postcss-cli": "^2.3.3",
"postcss-loader": "^0.9.1",
"raw-loader": "^0.5.1",
"react": "^15.3.1",
"react-codemirror": "^0.2.6",
"react-dom": "^15.3.2",
"react-router": "^4.0.0-alpha.5",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.2",
"redbox-react": "^1.0.1",
"rimraf": "^2.4.3",
"standard": "^7.0.1",
"style-loader": "^0.13.0",
"watch": "^0.18.0",
"webpack": "^1.9.6",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"babel-runtime": "^6.11.6",
"codemirror": "^5.18.0"
},
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0"
}
}
8 changes: 8 additions & 0 deletions source/index.js
@@ -0,0 +1,8 @@
import ContentSlide from './modules/ContentSlide'
import Presentation from './modules/Presentation'
import PropTypes from './modules/PropTypes'
import Slide from './modules/Slide'
import Step from './modules/Step'
import TitleSlide from './modules/TitleSlide'

export { ContentSlide, Presentation, PropTypes, Slide, Step, TitleSlide }
85 changes: 85 additions & 0 deletions source/modules/Code.js
@@ -0,0 +1,85 @@
import React, { Component, PropTypes } from 'react'
import CodeMirror from 'react-codemirror'

// By default, highlight JSX
import 'codemirror/mode/jsx/jsx'

const DEFAULT_CODE_MIRROR_OPTIONS = {
lineNumbers: false,
mode: 'jsx',
readOnly: true,
theme: 'reactpresents'
}

export default class Code extends Component {
static defaultProps = {
codeMirrorOptions: {},
dimLines: [],
highlightLines: []
}

static propTypes = {
codeMirrorOptions: PropTypes.object.isRequired,
dimLines: PropTypes.array.isRequired,
highlightLines: PropTypes.array.isRequired,
value: PropTypes.string.isRequired
}

componentDidMount () {
const { dimLines, highlightLines } = this.props

this._textMarks = []
this._addClassNameToLines(dimLines, 'dim')
this._addClassNameToLines(highlightLines, 'highlight')
}

componentWillUpdate (nextProps, nextState) {
const { dimLines, highlightLines } = this.props

if (
dimLines !== nextProps.dimLines ||
highlightLines !== nextProps.highlightLines
) {
this._textMarks.forEach(
(textMark) => {
textMark.clear()
}
)

this._textMarks = []
this._addClassNameToLines(nextProps.dimLines, 'dim')
this._addClassNameToLines(nextProps.highlightLines, 'highlight')
}
}

render () {
const { codeMirrorOptions, value } = this.props

const options = {
...DEFAULT_CODE_MIRROR_OPTIONS,
...codeMirrorOptions
}

return (
<CodeMirror
options={options}
ref={(ref) => {
this._codeMirror = ref
}}
value={value}
/>
)
}

_addClassNameToLines (lineNumbers, className) {
lineNumbers.forEach(([start, stop]) => {
this._textMarks.push(
this._codeMirror.codeMirror.doc.markText(
{ line: start, ch: 0 },
{ line: stop + 1, ch: 0 },
{ className }
)
)
})
}
}

0 comments on commit 5bf0ccd

Please sign in to comment.