GithubHelp home page GithubHelp logo

checkboxland's Introduction

Checkboxland

a grid of checkboxes displaying the words 'Welcome to Checkboxland

Checkboxland is a JavaScript library for rendering anything as HTML checkboxes.

You can use it to display animations, text, images, video, and arbitrary data. It also supports plugins, so you can add your own APIs.

Checkboxland is dependency-free, framework-agnostic, and fun! 🙃

For more details see the docs.

Setup

Install this package via npm:

npm install checkboxland

Example

Import it into your application, and create a checkbox grid:

import { Checkboxland } from 'checkboxland';

const cbl = new Checkboxland({ dimensions: '8x7', selector: '#my-container' });

// Create a data representation of the heart.
const heart = [
  [0,1,1,0,0,1,1,0],
  [1,0,0,1,1,0,0,1],
  [1,0,0,0,0,0,0,1],
  [1,0,0,0,0,0,0,1],
  [0,1,0,0,0,0,1,0],
  [0,0,1,0,0,1,0,0],
  [0,0,0,1,1,0,0,0],
];

// This updates the grid with the data we provided.
cbl.setData(heart);

a grid of checkboxes displaying the shape of a heart

Contributing

Checkboxland is designed to be extendable. If you want to add a feature, first ask yourself if it could be done as an external plugin.

If you contribution requires a change to the core library, follow these steps:

  1. Fork/Clone the repo.
  2. Make your changes on a feature branch.
  3. Run the docs site locally (npm run dev) to confirm that the demos still work as expected.
  4. Submit a Pull Request.

License

MIT

checkboxland's People

Contributors

bryanbraun avatar juliemyoung avatar jwg4 avatar konradlinkowski avatar psimyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

checkboxland's Issues

Normalize checkbox colors across browsers using "accent-color"

Currently different browsers display different default checkbox colors:

Edge: image

Safari: image

Chrome: image

We can use the new accent-color CSS property to make them all the same color across browsers (at least for the browsers that support it). I'd suggest that we make them all the same as the safari color (since it's blue-ish and that browser doesn't yet support accent-color yet).

For now, we can start by just adding these style changes to this normalize stylesheet (and possibly renaming the stylesheet from normalize-size.css to normalize.css): https://github.com/bryanbraun/checkboxland/blob/main/docs/css/cbl-normalize-size.css .

Add support for new renderImage and renderVideo dataSources

The renderImage and renderVideo plugins would be a bit more flexible if they accepted other dataSources like:

These dataSources would add support for additional use cases, including:

  • Uploading longer videos (those that are too long to be successfully converted to a data URL).
  • Enable uploading of animated gifs, using third-party conversion tools like Gifler or Gifuct.
  • ...probably other ones!

Replace "@pika/pack" and it's plugins with a better publishing method

@pika/pack is no longer being developed. See the archived repo here: https://github.com/FredKSchott/pika-pack

We should transition this to a better supported publishing method. The key features I'd want to support is:

Option 1: Parcel

  • Tried and true.
  • I suspect it doesn't support type publishing.

Option: 2: Publish to JSR

Suggestion: basic drawing

I thought that maybe a plugin to draw things like the standard 2d canvas context api would improve the thing a lot.
@bryanbraun What do you think about that?

Safari: the CSP blocks AnchorJS's dynamic style creation, causing anchor-js to fail.

In Safari, anchor-js fails to load because the newly-added CSP is blocking dynamic style addition.

This appears to be a browser bug, specific to Safari. This issue describes what's happening, as such:

Based on a Twitter convo with @mikewest https://twitter.com/tabatkins/status/1189288783738523648, it looks like the restriction on script-created style elements is probably an accident of implementation, not an intentional restriction. Thus script-created CSSStyleSheets should be fine to stay un-restricted by CSP.

Thus, we could wait until Safari fixes it, or remove / loosen the CSP significantly (perhaps with style-src: 'unsafe-inline');

Lasers demo: beam sometimes fails when clicking on the edge

In the lasers demo, if you click on the edge of the grid, there's a chance that the beam fails to deploy, like this checkbox in the bottom-right:

image

There are no javascript errors. It's likely because the randomly chosen direction points in such a way that the code doesn't know which way it needs to be reflected.

typescript support (plugins)

what a fun library! thanks @bryanbraun 👏

i noticed you're using pika for automatically building types. this is rad for the main checkboxland instance, but, when it comes to plugins those types are not inferred. since a plugin's js file does not export its internal functions, pika doesnt either.


for example, in print.js, if the print function is exported too

export default {
  name: 'print',
  exec: print,
  print // added this line
}

THEN, i believe the output .d.ts file would look something like:

declare namespace _default {
    export const name: string;
    export { print as exec };
    export { print as print }; // added this line
}
export default _default;
declare function print(text: any, options?: {}): any;

and THEN people using your lib in typescript could augment the main checkboxland class w plugins as needed, something like:

import { Checkboxland } from 'checkboxland';
import CblPluginPrintTypes from '../../node_modules/checkboxland/dist-types/plugins/print/print';
// augmented 
type CblPluggedIn = Checkboxland & typeof CblPluginPrintTypes;
const cbl = new Checkboxland({ dimensions }) as CblPluggedIn;
cbl.print('words'); // works correctly without ts errors

of course, there are other ways to correctly add plugin typings to the cbl class in typescript and maybe you have an idea for the builtin plugins, just offering one solution.

cheers

Suggestion: 'ghost mode'

Hi, I did something like this a few years ago, see:

http://johnhorner.info/dot-matrix/

not nearly as modern as yours. However I also came up with 'ghost mode' which uses disabled checkboxes instead of checked ones for a muted effect. You could also have inverted ghost mode, where the background boxes were disabled and the foreground enabled? Possibly even very crude anti-aliasing.

Anyway, love your work, just a suggestion.

sh: pika: command not found

I try to run this locally and I get sh: pika: command not found

I guess pika is missing in dependencies? I have no idea what that is. I see pika-pack but no pika

Cycle through the demos at the top of the page automatically

Like the matterjs docs do.

Ideally:

  • They cycle automatically, but if you click to look at a specific one it interrupts the cycle permanently.

Extra credit:

  • We find a way to prevent the flash between demos, possibly by having the next iFrame loads behind the existing one, and then having the existing one disappear.

Does this plugin work with gatsby.js for react?

Unable to get it to run on first try importing the example code as it's own component

Receiving the error
Warning: validateDOMNesting(...): <a> cannot appear as a descendant of <a>. and
TypeError: Cannot set property 'innerHTML' of null

thank you!

Make the "Conways Game of Life" demo interactive

Here's the link to the demo: https://www.bryanbraun.com/checkboxland/docs/demos/game-of-life/

Currently, if you pause the game, check some boxes, and then unpause, the newly checked boxes don't affect the game. They are simply overridden by the internal state of the game.

A nice improvement would be to make it interactive. We could do this by pulling the state of the grid from Checkboxland with each iteration (using .getData()), and feeding that into our Conways code.

Get a bunch of cool images

  • OG images for the docs site
  • OG image for the github repo
  • A good demo image for the top of the README.
  • Images to include in a blog post.
    • Animated gifs, for each of the demos

User input events

Is there any way to detect user clicks? Do you plan to add this in the future?

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.