Coder Social home page Coder Social logo

nilportugues / contrast-swatch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jxnblk/contrast-swatch

0.0 2.0 0.0 295 KB

๐Ÿ…ฐ๏ธ Image microservice for color contrast information

Home Page: https://contrast.now.sh/cff/40f

JavaScript 100.00%

contrast-swatch's Introduction

Contrast Swatch

Image microservice for color contrast information

Usage

Contrast swatch images can be used in any place an image is rendered. The URL accepts a foreground and background color.

https://contrast.now.sh/cff/40f

HTML

<img src="https://contrast.now.sh/fff/07c" alt="color contrast indicator" />

Markdown

![color contrast indicator](https://contrast.now.sh/fff/07c)

React

You can wrap the image in a React component (or any templating engine) for generating documentation.

import React from 'react'

export default ({
  foreground,
  background,
  ...props
}) =>
  <img
    {...props}
    src={`https://contrast.now.sh/${foreground}/${background}`}
    alt='color contrast indicator'
  />

Customization

Use URL queries to customize the styles.

https://contrast.now.sh/fff/40f?width=256&height=96&fontSize=1.25

Pass/Fail Label

Font Size

Size

Width & Height

Custom Text

Options

Option Description
size Width & height in pixels
width Width of image in pixels
height Height of image in pixels (font size will scale based on height)
fontSize Relative font size (default 1)
label Show a pass/fail label based on the WCAG Criteria
text Render any custom text

Metadata

A JSON response with color contrast information can be fetched by adding the type=json query to the URL.

https://contrast.now.sh/cff/40f?type=json

Note: the returned JSON schema might change in a future version

Related

MIT License

contrast-swatch's People

Contributors

jxnblk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.