npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@creenv/gui

v1.5.0

Published

The GUI controls used by the Creative Environment Creenv. Vanilla JS, lightweight, customizable

Downloads

22

Readme

Creenv GUI

@creenv/gui is the gui used within the Creative Environment project. It is bundled with Creenv by default. The Creative Environment Graphical User Interace solves 2 issues you may have met trying to add controls to your projects: redundancy and too much of a trouble to setup. Using the strength of es6 files encapsulation, you will now be able to define a controllable config on your creative projects.

Show me how it's done

The idea behind this GUI is to have 2 objects:

  • a config object: it will contain all the properties used in live by your application
  • a controls object: it will be used at the initialization to explain to the GUI the constraints over each controllable property

So, without splitting the objects into multiple files for readability (as it is in after you run the cli create-creenv), this is what the initialization of the GUI would look like:

// the config 
var config = {
  strength: 13,
  background: new Color(255,25,255,0.8), // can also be a string, ex: #efef17
  isGlowActive: false,
  textToDisplay: "test"
};

var userControls = {
  object: config, 
  controls: [

    [
      "a folder name",
      {
        property: "strength",
        min: 0, max: 150, step: 30,
        callback: val => { console.log("number updated: "+val); }
      },
      {
        property: "background" // we leave full control to the user here 
      }
    ],

    [
      "another folder",
      {
        property: "isGlowActive",
        callback: val => { console.log("boolean changed: "+val) }
      },
      {
        property: "textToDisplay"
      }
    ]

  ]
}

var gui = new GUI(userControls);

aaaaand... BOOM:

[ici image]

As simple as that. Now, whenver you'll want to get the values of the config variable, they will match the one provided by the user.

What you need to know

There are a few things you need to know about the GUI if you want to use it wisely.

Structure of the controls object

The controls object must match a specific structure, otherwise it won't be transformed into the desired UI.

// the controls variable is an object, it must have at least 2 properties :
let controls = {

  // the variable, an object in which the properties are stored
  object: yourConfigObject,

  // an array with all the controls, in which all items follow a schema
  controls: [

    // if the item is an object, it will be considered as a controller
    {
      // a controller must have a "property" property. it will match the name of the
      // property in the config object, see the example above. must be a string
      property: "propertyName",

      /**
       * depending on the type of the property, the controller will either be: 
       * string: input text
       * boolean: checkbox 
       * string, css color format: color picker
       * number: slider
       * it's automatic. look at the example above
       * */

      // everything else is optional. look at the controls property below to learn
      // about the controllers properties you can use
    }

  ]

}

The philosophy behind this architecture is to create you config object with default values, that will be used at the initialization of your app. In the render loop, the config values are used by algorithms, and because those values are changed in real time, the algorithms will use those new values. There is no need for callback mechanism, even though it is available, because required in some cases.