Giter Club home page Giter Club logo

jl-coloringbook's Introduction

JL Coloring book

A single javascript file that creates a custom HTML tag (webcomponent) that can be used for a highly customizable coloring book on your website.

Features

  • Minimum HTML required to implement
  • Anyone can color a coloring book page.
  • Supports erasing, saving and pringing.
  • Undo function
  • When navigating to another coloring page or a different web page, the state saved so you can continue coloring where you left off
  • Supports any number of images (pages) in your coloring book, with included navigation.
  • Multiple coloring books can be embeded on a page.
  • Customizable color palette.
  • Will not interfere with your website's CSS, and your website will not interfere with how the component is themed.
  • Full Themeable without editing javascript code.

Demo

Visit https://primoweb.com/vfc-coloring-book for a demo of the script embeded into a busy wordpress design. See the examples folder for more.

Prerequisites

###jQuery 3+

Your page will need jquery on it already, which most websites already have. If not, you can include it as simply as

<script src="https://code.jquery.com/jquery-3.4.1.min.js"</script>

You can embed that code either in the head of your page, or somewhere prior to calling the tag. If you're using wordpress or another content manatement system, it likely already has jquery installed so ignore it unless the coloring book fails to initialize.

Upload and call the jl-coloringBook.js file (or point to CDN).

Include the following code somewhere near top of your HTML, preferably in the <head> section:

<script src="/PathToFile/js-coloringBook.js"></script>

To pull the file from jsDelivr CDN use the following..

<script src="https://cdn.jsdelivr.net/gh/collinph/jl-coloringbook/jl-coloringBook.js"></script>

Simple Use

JL Coloring book works in its most simple form by wrapping a group of <img> tags with the <jl-coloringbook> tag.

<jl-coloringbook>
	<img src="yourImageHere.jpg" />
	<img src="yourSecondImageHere.jpg" />
	<img src="rinseAndRepeatToYourHeartsContent.jpg" />
</jl-coloringbook>

You can embed this code in any section of your HTML and the plugin will automatically size itself based on the container.

Customization

Don't like the colors? Want to change the spacing? Want to randomize the image that loads on default? We've got you covered.

Custom color palette

You can add <i> tags to replace the default palette of painting colors as in the example below. Please note that the last color will be the "eraser" tool.

<jl-coloringbook>
	<i color="rgba(87, 87, 87,0.8)"></i>
	<i color="rgba(220, 35, 35,0.8)"></i>
	<i color="rgba(42, 75, 215,0.8)"></i>
	<i color="rgba(29, 105, 20,0.8)"></i>
	<i color="rgba(129, 74, 25,0.8)"></i>
	<i color="rgba(129, 38, 192,0.8)"></i>
	<i color="rgba(255, 255, 255,0.8)"></i>
	<i color="rgba(255, 255, 255)"></i>
	<img src="./images/astronaut.png" />
	<img src="./images/eagle.png" />
	<img src="./images/glass.jpg" />
</jl-coloringbook>

Randomize the first loaded image

To make the coloring book to open to a random page when first loaded, use the randomize attribute.

<jl-coloringbook randomize="true">
	<img src="./images/astronaut.png" />
	<img src="./images/eagle.png" />
	<img src="./images/glass.jpg" />
</jl-coloringbook>

Max Brush size

The default maximum brush size is 32 (px) because most browsers do not support a cursor larger than 32x32. You can make the max brush size larger than 32, however the cursor size won't grow beyond 32px. To increase the max brush size, use the maxbrushsize attribute.

<jl-coloringbook maxbrushsize="32">
	<img src="./images/astronaut.png" />
	<img src="./images/eagle.png" />
	<img src="./images/glass.jpg" />
</jl-coloringbook>

Advanced customization of the layout.

Want bigger buttons? Want it to look a particular way on mobile? Want to change the look entirely? You'll need to create a custom theme file and edit to your liking. You will have to tell the component to use this css file by using the css attribute.

<jl-coloringbook css="./customizedThene.css">
	<img src="./images/astronaut.png" />
	<img src="./images/eagle.png" />
	<img src="./images/glass.jpg" />
</jl-coloringbook>

"Outer CSS" rules.

CSS Classes or rules can be used on the jl-coloringbook tag to force it to render at specific widths or alignments like you would any

or section of your site.

Important Note

Due to the way browser security is concerned, images should be hosted on the same server as the website (they usually are). You can get around this with proper CORS rules, however, that's outside the scope of this document. You'll know that you're violating CORS rules if the print and save function doesn't work.

Licensing

This project is free to be used on any site free of charge. If you enjoy this project and would like to its continued development, I accept tips via paypal at mailto Copyright 2020, Joe Love

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.