├── .editorconfig ├── .eslintrc ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── demo └── src │ └── index.js ├── nwb.config.js ├── package.json ├── src ├── components │ ├── Panel.js │ ├── Panel.spec.js │ ├── Panels.js │ ├── Panels.spec.js │ ├── Tab.js │ ├── Tab.spec.js │ ├── TabList.js │ ├── TabList.spec.js │ ├── Tabs.js │ └── Tabs.spec.js ├── helpers │ └── idSafeName.js └── index.js └── tools ├── testData.js └── testSetup.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*.{css,html,js,scss}] 5 | indent_style = space 6 | indent_size = 4 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 | "parserOptions": { 3 | "ecmaVersion": 6, 4 | "ecmaFeatures": { 5 | "jsx": true 6 | }, 7 | "sourceType": "module" 8 | }, 9 | "env": { 10 | "browser": true 11 | }, 12 | "globals": { 13 | "module": true, 14 | }, 15 | "plugins": [ 16 | "react" 17 | ], 18 | "extends": ["plugin:react/recommended"], 19 | "rules": { 20 | "comma-dangle": [2, "never"], 21 | "no-cond-assign": [2, "except-parens"], 22 | "no-console": 1, 23 | "no-constant-condition": 2, 24 | "no-control-regex": 2, 25 | "no-debugger": 2, 26 | "no-dupe-args": 2, 27 | "no-dupe-keys": 2, 28 | "no-duplicate-case": 2, 29 | "no-empty": 1, 30 | "no-empty-character-class": 2, 31 | "no-ex-assign": 2, 32 | "no-extra-boolean-cast": 2, 33 | "no-extra-parens": [2, "functions"], 34 | "no-extra-semi": 2, 35 | "no-func-assign": 2, 36 | "no-invalid-regexp": 2, 37 | "no-irregular-whitespace": 2, 38 | "no-obj-calls": 2, 39 | "no-regex-spaces": 1, 40 | "no-sparse-arrays": 2, 41 | "no-unexpected-multiline": 2, 42 | "no-unreachable": 2, 43 | "no-unsafe-negation": 2, 44 | "use-isnan": 2, 45 | "valid-typeof": 2, 46 | 47 | "accessor-pairs": [2, { "getWithoutSet":true }], 48 | "block-scoped-var": 2, 49 | "curly": [2, "all"], 50 | "dot-location": [2, "property"], 51 | "eqeqeq": [2, "smart"], 52 | "no-alert": 2, 53 | "no-else-return": 2, 54 | "no-eval": 2, 55 | "no-extra-bind": 2, 56 | "no-fallthrough": 2, 57 | "no-floating-decimal": 2, 58 | "no-global-assign": 2, 59 | "no-implicit-globals": 2, 60 | "no-implied-eval": 2, 61 | "no-labels": 2, 62 | "no-multi-spaces": 2, 63 | "no-multi-str": 2, 64 | "no-new-func": 2, 65 | "no-octal-escape": 2, 66 | "no-octal": 2, 67 | "no-redeclare": 2, 68 | "no-return-assign": [2, "except-parens"], 69 | "no-script-url": 2, 70 | "no-self-assign": 2, 71 | "no-throw-literal": 2, 72 | "no-unused-labels": 2, 73 | "no-useless-call": 2, 74 | "no-useless-concat": 2, 75 | "no-void": 2, 76 | "no-with": 2, 77 | "radix": 2, 78 | "wrap-iife": [2, "inside"], 79 | "yoda": [2, "never", {}], 80 | 81 | "strict": [2,"function"], 82 | 83 | "no-delete-var": 2, 84 | "no-shadow": [2, { "builtinGlobals": false, "hoist": "functions", "allow": [] }], 85 | "no-shadow-restricted-names": 2, 86 | "no-undef": 2, 87 | "no-undef-init": 2, 88 | "no-unused-vars": 2, 89 | "no-use-before-define": [2, "nofunc"], 90 | 91 | "array-bracket-spacing": [2, "never"], 92 | "block-spacing": [2, "always"], 93 | "brace-style": [2, "stroustrup", { "allowSingleLine": false }], 94 | "camelcase": [2, { "properties": "always" }], 95 | "comma-spacing": [2, { "before": false, "after": true }], 96 | "comma-style": [2, "last"], 97 | "computed-property-spacing": [2, "never"], 98 | "eol-last": 2, 99 | "func-call-spacing": [2, "never"], 100 | "indent": [2, 4, { "SwitchCase": 1 }], 101 | "key-spacing": [2, { "beforeColon": false, "afterColon": true }], 102 | "keyword-spacing": 2, 103 | "linebreak-style": [2, "unix"], 104 | "new-cap": 2, 105 | "new-parens": 2, 106 | "newline-after-var": [2, "always"], 107 | "newline-before-return": 2, 108 | "no-lonely-if": 2, 109 | "no-mixed-spaces-and-tabs": [2, "smart-tabs"], 110 | "no-multiple-empty-lines": [2, { "max": 2 }], 111 | "no-nested-ternary": 2, 112 | "no-tabs": 1, 113 | "no-trailing-spaces": [2, { "skipBlankLines": false }], 114 | "no-whitespace-before-property": 2, 115 | "quote-props": [2, "consistent-as-needed"], 116 | "quotes": [1, "single"], 117 | "semi": [2, "always"], 118 | "semi-spacing": [2, { "before": false, "after": true }], 119 | "space-before-blocks": [2, "always"], 120 | "space-before-function-paren": [2, "always"], 121 | "space-infix-ops": 2, 122 | "wrap-regex": 2, 123 | 124 | "react/jsx-uses-vars": 2 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /coverage 2 | /demo/dist 3 | /es 4 | /lib 5 | /node_modules 6 | /umd 7 | npm-debug.log* 8 | .DS_Store 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "4" 4 | install: 5 | - "npm install" 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # React Accessible Tabs 2 | 3 | ## Prerequisites 4 | 5 | [Node.js](http://nodejs.org/) >= v4 must be installed. 6 | 7 | ## Installation 8 | 9 | - Running `npm install` in the components's root directory will install everything you need for development. 10 | 11 | ## Demo Development Server 12 | 13 | - `npm start` will run a development server with the component's demo app at [http://localhost:3000](http://localhost:3000) with hot module reloading. 14 | 15 | ## Running Tests 16 | 17 | - `npm test` will run the tests once. 18 | 19 | - `npm run test:watch` will run the tests on every change. 20 | 21 | ## Building 22 | 23 | - `npm run build` will build the component for publishing to npm and also bundle the demo app. 24 | 25 | - `npm run clean` will delete built resources. 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Matt Stow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Accessible Tabs 2 | 3 | An accessible React tabs component, ported from [my vanilla JS plugin](http://codepen.io/stowball/pen/xVWwWe). 4 | 5 | [![npm version](https://badge.fury.io/js/react-accessible-tabs.svg)](https://badge.fury.io/js/react-accessible-tabs) 6 | [![Build Status](https://travis-ci.org/stowball/react-accessible-tabs.svg?branch=master)](https://travis-ci.org/stowball/react-accessible-tabs) 7 | 8 | ## Demo 9 | 10 | [See it in action](https://stowball.github.io/react-accessible-tabs/). 11 | 12 | ## Usage 13 | 14 | ### Installation 15 | 16 | ```sh 17 | npm install react-accessible-tabs --save 18 | ``` 19 | 20 | ### In React 21 | 22 | ```js 23 | import Tabs from 'react-accessible-tabs'; 24 | 25 | class App extends React.Component { 26 | render () { 27 | const tabContent = [ 28 | { 29 | label: 'Tab 1', 30 | content: 31 | }, 32 | { 33 | label: 'Tab 2', 34 | content: 35 | }, 36 | { 37 | label: 'Tab 3', 38 | content: '

Tab 3 content

' 39 | }, 40 | { 41 | label: 'Tab 4', 42 | content: [ 43 |
, 44 | '

Tab 4 content

' 45 |