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

coherent-guic-cli

v4.0.2

Published

A command line interface for creating Game UI Components for Gameface.

Downloads

19

Readme

The coherent-guic-cli is a tool that helps you create and develop components from the GameUIComponents suite. It can also setup a development environment with live reload that will allow you to easily create a UI using the components.

Getting Started

To install the cli open a console and type:

npm i -g coherent-guic-cli

This will install the cli as a global module and will make it available from everywhere.

Available Commands

|Command |Description |Arguments |Usage | |---|---|---|---| |create-project |Create a new project from template. | template> <directory>|coherent-guic-cli create-project webpack ./my-folder| |create-component | Create a new component. | [name], [directory]| coherent-guic-cli create my-component ./my-folder| |build | Build the component. Creates the distributable files located in the /dist folder. | N/A | coherent-guic-cli build| |watch | Build the component and watch for file changes. Creates the distributable files located in the /dist folder and rebuilds them on change. | N/A |coherent-guic-cli watch| |build-demo| Build the demo. | N/A |coherent-guic-cli build-demo| |start-demo | Start a development server and host the demo with live reload for quick development iteration cycle. | N/A |coherent-guic-cli start-demo| |--help, -h| Show help. | N/A | coherent-guic-cli --help|

Usage

Setting up an Environment

If you want to create a UI using the components - use the create-project command. It allows you to setup a project that uses Webpack or Vite. Open a console and type:

coherent-guic-cli create-project webpack ./my-folder

or

coherent-guic-cli create-project vite ./my-folder

This will automatically install all dependencies. After the project is ready - navigate to my-folder and type

npm run dev

this will start a development server with live reload enabled for both project types - webpack and vite.

<template> can be webpack or vite.

Example:

coherent-guic-cli create-project vite ./my-folder

This will create a new project inside ./my-folder and will install the dependencies. After that you can navigate to the folder and start a development server:

cd ./my-folder
npm run dev

Creating a Component

You can use the CLI to create and develop custom components like the Checkbox. It will setup the required environment for the development of a custom component. Use the create command to create a component:

coherent-guic-cli create-component my-first-guic components

The create command accepts two positional arguments - the name of the component and its containing folder. The name must:

  • start with an ASCII lowercase letter (a-z)
  • contain a hyphen
  • not contain any ASCII uppercase letters
  • not contain certain other characters such as ? ! < > @ # $ % ^ & * ( ) + [ ] ~
  • not be any of:
    • annotation-xml
    • color-profile
    • font-face
    • font-face-src
    • font-face-uri
    • font-face-format
    • font-face-name
    • missing-glyph

The name of the component will be used for the registration of the custom HTML element and for the name of the component class. The create command will generate the following files:

\components:
|
\---gameface-my-first-guic
    |   coherent-gameface-components-theme.css
    |   index.js
    |   package.json
    |   README.md
    |   script.js
    |   style.css
    |   template.html
    |
    \--demo
            demo.html
            demo.js

The registered custom element can be used like this:

<gameface-my-first-guic class="my-first-guic-component">
    <component-slot data-name="name">my-first-guic</component-slot>
</gameface-my-first-guic>

And the custom element's definition looks like this:

class GamefaceMyFirstGuic extends BaseComponent {
   constructor() {
        super();
        this.template = template;
        this.init = this.init.bind(this);
    }

    init(data) {
        this.setupTemplate(data, () => {
            components.renderOnce(this);
            // attach event handlers here
        });
    }

    connectedCallback() {
        components.loadResource(this)
            .then(this.init)
            .catch(err => console.error(err));
    }
}

Note that the gameface prefix is added to the component name and to the containing folder.

Building the Demo

Each component has index.html and demo.js files that demonstrate how to use it. You can create a production build of the demo using the build-demo command. It will generate the bundle.js and index.html files along with any other assets such as styles located in the demo folder. Load the demo/demo.html file in a web browser to see the component.

coherent-guic-cli build-demo

Serve the Demo

You can start a development server that hosts the demo. This allows you to easily make changes and quickly see them applied on the demo page as the live reload will automatically update the page.

coherent-guic-cli start-demo