├── .editorconfig ├── .gitignore ├── .travis.yml ├── compositor.json ├── index.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 'stable' 4 | -------------------------------------------------------------------------------- /compositor.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "johnotander/random-a11y-combo", 3 | "version": "0.1.4", 4 | "libraries": { 5 | "xv": "^1.1.19" 6 | }, 7 | "title": "", 8 | "branch": "", 9 | "style": { 10 | "name": "Brutalist", 11 | "componentSet": { 12 | "nav": "nav/BasicNav", 13 | "header": "header/BasicHeader", 14 | "article": "article/MarkdownArticle", 15 | "footer": "footer/BasicFooter" 16 | }, 17 | "fontFamily": "Consolas, \"Liberation Mono\", Menlo, Courier, monospace", 18 | "heading": {}, 19 | "typeScale": [ 20 | 48, 21 | 32, 22 | 20, 23 | 18, 24 | 16, 25 | 14, 26 | 12 27 | ], 28 | "layout": { 29 | "maxWidth": 1024, 30 | "fluid": true 31 | }, 32 | "colors": { 33 | "text": "#333", 34 | "background": "#fff", 35 | "primary": "#666", 36 | "secondary": "#888", 37 | "highlight": "#1f80ff", 38 | "muted": "#f6f6f6", 39 | "border": "#eee" 40 | } 41 | }, 42 | "content": [ 43 | { 44 | "component": "nav", 45 | "links": [ 46 | { 47 | "href": "https://github.com/johnotander/random-a11y-combo", 48 | "text": "GitHub" 49 | }, 50 | { 51 | "href": "https://npmjs.com/package/random-a11y-combo", 52 | "text": "npm" 53 | } 54 | ] 55 | }, 56 | { 57 | "component": "header", 58 | "heading": "random-a11y-combo", 59 | "subhead": "Get a random accessible color combination", 60 | "children": [ 61 | { 62 | "component": "ui/TweetButton", 63 | "text": "random-a11y-combo: Get a random accessible color combination", 64 | "url": null 65 | }, 66 | { 67 | "component": "ui/GithubButton", 68 | "user": "johnotander", 69 | "repo": "random-a11y-combo" 70 | } 71 | ], 72 | "text": "v1.0.0" 73 | }, 74 | { 75 | "component": "article", 76 | "metadata": { 77 | "source": "github.readme" 78 | }, 79 | "html": "\n\n
npm install --save random-a11y-combo
const randomA11yCombo = require('random-a11y-combo')\n\nrandomA11yCombo() // => ['#4e9d4d','#0b2352']\nrandomA11yCombo('#fff') // => ['#fff','#444']
MIT
\ngit checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Crafted with <3 by John Otander (@4lpine).
\n\n\n" 80 | }, 81 | { 82 | "component": "footer", 83 | "links": [ 84 | { 85 | "href": "https://github.com/johnotander/random-a11y-combo", 86 | "text": "GitHub" 87 | }, 88 | { 89 | "href": "https://github.com/johnotander", 90 | "text": "johnotander" 91 | } 92 | ] 93 | } 94 | ] 95 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var randomHexColor = require('random-hex-color') 4 | var getContrast = require('get-contrast') 5 | 6 | module.exports = function (colorOne) { 7 | colorOne = colorOne || randomHexColor() 8 | var colorTwo = randomHexColor() 9 | 10 | while (!getContrast.isAccessible(colorOne, colorTwo)) { 11 | colorTwo = randomHexColor() 12 | } 13 | 14 | return [colorOne, colorTwo] 15 | } 16 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 John Otander 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "random-a11y-combo", 3 | "description": "Get a random accessible color combination", 4 | "author": "John Otander", 5 | "version": "1.0.0", 6 | "main": "index.js", 7 | "files": [ 8 | "index.js" 9 | ], 10 | "scripts": { 11 | "test": "ava" 12 | }, 13 | "repository": "johnotander/random-a11y-combo", 14 | "keywords": [], 15 | "license": "MIT", 16 | "dependencies": { 17 | "get-contrast": "^2.0.0", 18 | "is-present": "^1.0.0", 19 | "random-hex-color": "^1.0.0" 20 | }, 21 | "devDependencies": { 22 | "ava": "*" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # random-a11y-combo [](https://travis-ci.org/johnotander/random-a11y-combo) [](https://github.com/feross/standard) 2 | 3 | Get a random accessible color combination 4 | 5 | ## Installation 6 | 7 | ```bash 8 | npm install --save random-a11y-combo 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```javascript 14 | const randomA11yCombo = require('random-a11y-combo') 15 | 16 | randomA11yCombo() // => ['#4e9d4d','#0b2352'] 17 | randomA11yCombo('#fff') // => ['#fff','#444'] 18 | ``` 19 | 20 | ## License 21 | 22 | MIT 23 | 24 | ## Contributing 25 | 26 | 1. Fork it 27 | 2. Create your feature branch (`git checkout -b my-new-feature`) 28 | 3. Commit your changes (`git commit -am 'Add some feature'`) 29 | 4. Push to the branch (`git push origin my-new-feature`) 30 | 5. Create new Pull Request 31 | 32 | Crafted with <3 by John Otander ([@4lpine](https://twitter.com/4lpine)). 33 | 34 | *** 35 | 36 | > This package was initially generated with [yeoman](http://yeoman.io) and the [p generator](https://github.com/johnotander/generator-p.git). 37 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava' 2 | import isPresent from 'is-present' 3 | import randomA11yCombo from './' 4 | 5 | test('random-a11y-combo does something awesome', t => { 6 | t.plan(1) 7 | 8 | t.true(isPresent(randomA11yCombo())) 9 | }) 10 | 11 | test('random-a11y-combo returns a random a11y combo for a given hex', t => { 12 | t.plan(1) 13 | 14 | t.true(isPresent(randomA11yCombo('#fff'))) 15 | }) 16 | --------------------------------------------------------------------------------This package was initially generated with yeoman and the p generator.
\n