├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── README.md ├── demo ├── .babelrc ├── build │ └── index.html ├── package.json ├── src │ └── index.jsx └── webpack.config.js ├── index.js ├── karma.conf.js ├── package.json ├── src └── center.jsx ├── test └── center.spec.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-0", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | max_line_length = 100 11 | tab_width = 4 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | **/*.html 3 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "node": true, 6 | "commonjs": true, 7 | "mocha": true, 8 | "jquery": true, 9 | "mongo": true 10 | }, 11 | "ecmaFeatures": { 12 | "arrowFunctions": true, 13 | "blockBindings": true, 14 | "classes": true, 15 | "defaultParams": true, 16 | "destructuring": true, 17 | "forOf": true, 18 | "generators": true, 19 | "modules": true, 20 | "objectLiteralComputedProperties": true, 21 | "objectLiteralDuplicateProperties": false, 22 | "objectLiteralShorthandMethods": true, 23 | "objectLiteralShorthandProperties": true, 24 | "restParams": true, 25 | "spread": true, 26 | "superInFunctions": true, 27 | "templateStrings": true, 28 | "jsx": true 29 | }, 30 | "rules": { 31 | "strict": [2, "never"], 32 | "callback-return": 0, 33 | "handle-callback-err": 0, 34 | "no-mixed-requires": [0, false], 35 | "no-new-require": 0, 36 | "no-path-concat": 0, 37 | "no-process-exit": 0, 38 | "no-restricted-modules": 0, 39 | "no-sync": 0, 40 | "arrow-parens": 0, 41 | "arrow-spacing": [2, { "before": true, "after": true }], 42 | "constructor-super": 0, 43 | "generator-star-spacing": 0, 44 | "no-class-assign": 0, 45 | "no-const-assign": 2, 46 | "no-this-before-super": 0, 47 | "no-var": 2, 48 | "object-shorthand": 0, 49 | "prefer-const": 2, 50 | "prefer-spread": 0, 51 | "prefer-reflect": 0, 52 | "require-yield": 0, 53 | "comma-dangle": [2, "always-multiline"], 54 | "no-cond-assign": [2, "always"], 55 | "no-console": 0, 56 | "no-constant-condition": 1, 57 | "no-control-regex": 2, 58 | "no-debugger": 1, 59 | "no-dupe-args": 2, 60 | "no-dupe-keys": 2, 61 | "no-duplicate-case": 2, 62 | "no-empty-character-class": 2, 63 | "no-empty": 2, 64 | "no-ex-assign": 2, 65 | "no-extra-boolean-cast": 0, 66 | "no-extra-parens": [2, "functions"], 67 | "no-extra-semi": 2, 68 | "no-func-assign": 2, 69 | "no-inner-declarations": 2, 70 | "no-invalid-regexp": 2, 71 | "no-irregular-whitespace": 2, 72 | "no-negated-in-lhs": 2, 73 | "no-obj-calls": 2, 74 | "no-regex-spaces": 2, 75 | "no-sparse-arrays": 2, 76 | "no-unreachable": 2, 77 | "use-isnan": 2, 78 | "valid-jsdoc": 0, 79 | "valid-typeof": 2, 80 | "no-unexpected-multiline": 0, 81 | "init-declarations": 0, 82 | "no-catch-shadow": 0, 83 | "no-delete-var": 2, 84 | "no-label-var": 0, 85 | "no-shadow-restricted-names": 2, 86 | "no-shadow": 2, 87 | "no-undef-init": 0, 88 | "no-undef": 2, 89 | "no-undefined": 0, 90 | "no-unused-vars": [2, {"vars": "local", "args": "after-used"}], 91 | "no-use-before-define": [0], 92 | "array-bracket-spacing": [2, "never"], 93 | "brace-style": [2, "1tbs", {"allowSingleLine": true }], 94 | "camelcase": [2, {"properties": "never"}], 95 | "comma-spacing": [2, {"before": false, "after": true}], 96 | "comma-style": [2, "last"], 97 | "computed-property-spacing": [2, "never"], 98 | "consistent-this": 0, 99 | "eol-last": 2, 100 | "func-names": 1, 101 | "func-style": 0, 102 | "id-length": 0, 103 | "indent": [2, 2, { "SwitchCase": 1, "VariableDeclarator": 1 }], 104 | "jsx-quotes": [2, "prefer-double"], 105 | "key-spacing": [2, {"beforeColon": false, "afterColon": true}], 106 | "lines-around-comment": 0, 107 | "linebreak-style": 0, 108 | "max-nested-callbacks": 0, 109 | "new-cap": 0, 110 | "new-parens": 0, 111 | "newline-after-var": 0, 112 | "no-array-constructor": 0, 113 | "no-continue": 0, 114 | "no-inline-comments": 0, 115 | "no-lonely-if": 0, 116 | "no-mixed-spaces-and-tabs": 2, 117 | "no-multiple-empty-lines": [2, {"max": 2, "maxEOF": 1}], 118 | "no-nested-ternary": 0, 119 | "no-new-object": 2, 120 | "no-spaced-func": 2, 121 | "no-ternary": 0, 122 | "no-trailing-spaces": 2, 123 | "no-underscore-dangle": 0, 124 | "no-unneeded-ternary": 0, 125 | "object-curly-spacing": [2, "always"], 126 | "one-var": [2, "never"], 127 | "operator-assignment": 0, 128 | "operator-linebreak": 0, 129 | "padded-blocks": [2, "never"], 130 | "quote-props": 0, 131 | "quotes": [2, "single", "avoid-escape"], 132 | "id-match": 0, 133 | "semi-spacing": [2, {"before": false, "after": true}], 134 | "semi": [2, "always"], 135 | "sort-vars": 0, 136 | "space-before-keywords": [2, "always"], 137 | "space-after-keywords": [2, "always"], 138 | "space-before-blocks": 2, 139 | "space-before-function-paren": [2, { "anonymous": "always", "named": "never" }], 140 | "space-in-parens": [2, "never"], 141 | "space-infix-ops": 2, 142 | "space-return-throw-case": 2, 143 | "space-unary-ops": 0, 144 | "spaced-comment": [2, "always", { 145 | "exceptions": ["-", "+"], 146 | "markers": ["=", "!"] 147 | }], 148 | "wrap-regex": 0, 149 | "accessor-pairs": 0, 150 | "block-scoped-var": 2, 151 | "complexity": [0, 11], 152 | "consistent-return": 2, 153 | "curly": [2, "multi-line"], 154 | "default-case": 2, 155 | "dot-notation": [2, { "allowKeywords": true}], 156 | "dot-location": 0, 157 | "eqeqeq": 2, 158 | "guard-for-in": 2, 159 | "no-alert": 1, 160 | "no-caller": 2, 161 | "no-div-regex": 0, 162 | "no-else-return": 2, 163 | "no-empty-label": 2, 164 | "no-eq-null": 0, 165 | "no-eval": 2, 166 | "no-extend-native": 2, 167 | "no-extra-bind": 2, 168 | "no-fallthrough": 2, 169 | "no-floating-decimal": 2, 170 | "no-implicit-coercion": 0, 171 | "no-implied-eval": 2, 172 | "no-invalid-this": 0, 173 | "no-iterator": 2, 174 | "no-labels": 2, 175 | "no-lone-blocks": 2, 176 | "no-loop-func": 0, 177 | "no-multi-spaces": 2, 178 | "no-multi-str": 2, 179 | "no-native-reassign": 2, 180 | "no-new": 2, 181 | "no-new-func": 2, 182 | "no-new-wrappers": 2, 183 | "no-octal": 2, 184 | "no-octal-escape": 2, 185 | "no-param-reassign": 0, 186 | "no-process-env": 0, 187 | "no-proto": 2, 188 | "no-redeclare": 2, 189 | "no-return-assign": 2, 190 | "no-script-url": 2, 191 | "no-self-compare": 2, 192 | "no-sequences": 2, 193 | "no-throw-literal": 2, 194 | "no-unused-expressions": 0, 195 | "no-useless-call": 0, 196 | "no-void": 0, 197 | "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], 198 | "no-with": 2, 199 | "radix": 2, 200 | "vars-on-top": 2, 201 | "wrap-iife": [2, "any"], 202 | "yoda": 2, 203 | "react/display-name": 0, 204 | "react/jsx-boolean-value": [2, "always"], 205 | "react/jsx-closing-bracket-location": [2, "line-aligned"], 206 | "react/jsx-curly-spacing": 0, 207 | "react/jsx-indent-props": [2, 2], 208 | "react/jsx-no-duplicate-props": 0, 209 | "react/jsx-no-undef": 2, 210 | "react/jsx-sort-prop-types": 0, 211 | "react/jsx-sort-props": 0, 212 | "react/jsx-uses-react": 2, 213 | "react/jsx-uses-vars": 2, 214 | "react/no-danger": 0, 215 | "react/no-did-mount-set-state": [2, "allow-in-func"], 216 | "react/no-did-update-set-state": [2, "allow-in-func"], 217 | "react/no-multi-comp": 2, 218 | "react/no-unknown-property": 2, 219 | "react/prop-types": 2, 220 | "react/react-in-jsx-scope": 2, 221 | "react/require-extension": 0, 222 | "react/self-closing-comp": 2, 223 | "react/sort-comp": [2, { 224 | "order": [ 225 | "lifecycle", 226 | "/^on.+$/", 227 | "/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/", 228 | "everything-else", 229 | "/^render.+$/", 230 | "render" 231 | ] 232 | }], 233 | "react/wrap-multilines": [2, { 234 | "declaration": true, 235 | "assignment": true, 236 | "return": true 237 | }], 238 | "babel/generator-star-spacing": 0, 239 | "babel/new-cap": 0, 240 | "babel/object-shorthand": 2, 241 | "babel/arrow-parens": 0, 242 | "babel/no-await-in-loop": 0 243 | }, 244 | "plugins": [ 245 | "babel", 246 | "react" 247 | ] 248 | } 249 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage 2 | dist 3 | demo/node_modules 4 | demo/build/** 5 | !demo/build/index.html 6 | node_modules 7 | npm-debug.log 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .babelrc 2 | .editorconfig 3 | .eslintignore 4 | .eslintrc 5 | .gitignore 6 | .npmignore 7 | .travis.yml 8 | coverage 9 | demo 10 | karma* 11 | node_modules 12 | npm-debug.log 13 | src 14 | tests 15 | webpack* 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "4.1" 4 | before_install: 5 | - export CHROME_BIN=chromium-browser 6 | - export DISPLAY=:99.0 7 | - sh -e /etc/init.d/xvfb start 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Anton Matveev 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 | [](https://www.npmjs.com/package/react-center) [](https://travis-ci.org/aush/react-center) [](https://david-dm.org/aush/react-center) [](https://david-dm.org/aush/react-center#info=devDependencies) [](https://coveralls.io/github/aush/react-center?branch=master) [](https://raw.githubusercontent.com/aush/react-center/master/LICENSE) 2 | 3 | # React Center 4 | Simple react component to center content horizontally and vertically 5 | ###Install 6 | `npm install --save react-center` 7 | 8 | Don't forget to manually install React^0.14 (peer dependency) if you're using npm@3. 9 | ###Use 10 | #####ES6 11 | ```javascript 12 | import React from 'react'; 13 | import ReactDOM from 'react-dom'; 14 | import Center from 'react-center'; 15 | 16 | ReactDOM.render( 17 |