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

mx-custom-countdown

v0.2.4

Published

Stencil Component Starter

Downloads

5

Readme

ACME Countdown

Goal: Create a Countdown timer for ACME Corp as a custom web component.

Stack: JavaScript, Stencil, HTML, CSS

Breakdown:

  1. Define requirements 1.1 - Web Component needs to recieve Countdown-Name and Countdown-Time in SECONDS. Adittional: Create a finish custom message. 1.2 - Seconds need to be translated to Hours/Minutes/Seconds. 1.3 - Timer needs a count-down logic. 1.4 - Give some style! UI is important. 1.5 - Give some pre-defined customization! Developers UX is also important.

  2. Create Stencil project.

  3. Create count-down logic.

  4. Give your code some styling love and final touches.

  5. Refactor.

Additional Info on 1.6

Available Tags: name="Launch Time" -> Title to be shown above Timer seconds="10000" -> Time of coutdown in Seconds final-message="Liftoff!" -> Message to be displayed once time is off custom-style="nasa" -> Custom Styles: Try "nasa" (white bkg), "spacex" (black bkg) or "acme" (red bkg) logo="nasa" -> predefined logo: Try "nasa", "spacex" or "acme" -> can be customized by importing a PNG file into the assets folder

Publish Package in NPM:

  1. Set account
  2. Build component
  3. Publish

In order to get the Package run: npm install mx-custom-countdown

In order to use the web-components:

React ->

  1. Install package
  2. Go to index.js and add the following imports: import {defineCustomElements} from "mx-custom-countdown/loader";

At the end of your file add:

defineCustomElements(window);

  1. Go to the file you want to use the component on and use it as you wish. Ex:

possible properties:

seconds="10" name="Launch" final-message="Lift off" custom-style="spacex" (possible combinations: nasa (white), spacex (black), acme(red)) logo="spacex" (possible: nasa, spacex, acme)

Angular:

  1. Install package
  2. Go to app.module.ts and add: import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core"

on ngModule:

@NgModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA] })

Afterwards you need to register the elements like this (similar to React):

On main.ts:

import {defineCustomElements} from "mx-custom-countdown/loader";

defineCustomElements(window);


Stencil Component Starter

This is a starter project for building a standalone Web Component using Stencil.

Stencil is also great for building entire apps. For that, use the stencil-app-starter instead.

Stencil

Stencil is a compiler for building fast web apps using Web Components.

Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements v1 spec.

Stencil components are just Web Components, so they work in any major framework or with no framework at all.

Getting Started

To start building a new web component using Stencil, clone this repo to a new directory:

git clone https://github.com/ionic-team/stencil-component-starter.git my-component
cd my-component
git remote rm origin

and run:

npm install
npm start

To build the component for production, run:

npm run build

To run the unit tests for the components, run:

npm test

Need help? Check out our docs here.

Naming Components

When creating new component tags, we recommend not using stencil in the component name (ex: <stencil-datepicker>). This is because the generated component has little to nothing to do with Stencil; it's just a web component!

Instead, use a prefix that fits your company or any name for a group of related components. For example, all of the Ionic generated web components use the prefix ion.

Using this component

There are three strategies we recommend for using web components built with Stencil.

The first step for all three of these strategies is to publish to NPM.

Script tag
  • Put a script tag similar to this <script type='module' src='https://unpkg.com/[email protected]/dist/my-component.esm.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc
Node Modules
  • Run npm install my-component --save
  • Put a script tag similar to this <script type='module' src='node_modules/my-component/dist/my-component.esm.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc
In a stencil-starter app
  • Run npm install my-component --save
  • Add an import to the npm packages import my-component;
  • Then you can use the element anywhere in your template, JSX, html etc