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

@k4ys4r/wc-clock

v1.0.2

Published

a web component starter Vite + JS

Downloads

8

Readme

 <wc-clock/> 

It is a web component written in JavaScript/HTML/CSS and without any dependencies. wc-clock allows to display an Analog clock and be customized based on its HTML attributes and CSS variables.

npm version Published on webcomponents.org GitHub License

Installation

# with npm
npm i @k4ys4r/wc-clock

#with yarn
yarn add @k4ys4r/wc-clock

Once installed, import it in your application:

import "@k4ys4r/wc-clock";

//To get access to the Class properties
import { ClockComponent } from "@k4ys4r/wc-clock";

Or, you can imported from CDN :

import "https://cdn.skypack.dev/@k4ys4r/wc-clock";

Or in html script:

<script type="module" src="https://cdn.skypack.dev/@k4ys4r/wc-clock"></script>

Usage

  1. Make sure you've add wc-clock to your app through NPM. See Installation for more details.
  2. Add wc-clock to your app and placed it at the top.
  3. Then it can be used like below:
<wc-clock></wc-clock>

Usage of <wc-clock/> attributes

wc-clock has four attributes can be used to be customized:

<wc-clock hours-ticks minutes-ticks time-zone fixed-time></wc-clock>
  • hours-ticks is used to display the 12 hours ticks on the clock

  • minutes-ticks is used to display the 48 minutes ticks on the clock

  • time-zone is used to define the time zone (default value Europe/Paris). A valid value must be included in the supported time zone value:

    Intl.supportedValuesOf("timeZone");
    // that gives an array of strings :
    /*"Africa/Abidjan"
    "Africa/Accra"
    "Africa/Addis_Ababa"
    "Africa/Algiers"
    "Africa/Asmera"
    "Africa/Bamako"
    "Africa/Bangui"
    "Africa/Banjul"
    ...
    ...
    */
  • fixed-time is used to a fixed time without updating of clock hands. Its value format : format hh:mm:ss (default value is 10:10:30)

Dynamic creation of wc-clock

// import class component
import { ClockComponent } from "@k4ys4r/wc-clock";

// Create wc-clock element
let wcClock = document.createElement(ClockComponent.tagName);

// set of attributes
wcClock.setAttribute(ClockComponent.attributes["fixed-time"], "");
wcClock.setAttribute(ClockComponent.attributes["hours-labels"], [3, 6, 9, 12]);
wcClock.setAttribute(ClockComponent.attributes["hours-ticks"], "");
wcClock.setAttribute(ClockComponent.attributes["hours-ticks"], "");
wcClock.setAttribute(ClockComponent.attributes["minutes-ticks"], "");

// remove of attributes
wcClock.removeAttribute(ClockComponent.attributes["fixed-time"]);
wcClock.setAttribute(ClockComponent.attributes["minutes-ticks"], "");

CSS style

wc-clock has different CSS variables can be used to style some part of the web component. All variables and their default values are listed below:

<style>
  wc-clock {
    --hours-hand-color: #b9b9b9;
    --minutes-hand-color: #b9b9b9;
    --seconds-hand-color: #ff3434;
    --clock-background-color: #1a1a1aff;
    --clock-color: #fff;
    --clock-width: 10rem;
    --seconds-hand-width: 1;
    --seconds-hand-height: 4;
    --minutes-hand-width: 6;
    --minutes-hand-height: 4;
    --hours-hand-width: 6;
    --hours-hand-height: 3;
    --clock-font-size: 1rem;
    --clock-font: Arial, Helvetica, sans-serif;
    --clock-hours-ticks-color: #fff;
    --clock-minutes-ticks-color: #ffffff90;
    --clock-hours-ticks-height: 0.45rem;
    --clock-hours-ticks-width: 0.15rem;
    --clock-minutes-ticks-height: 0.23rem;
    --clock-minutes-ticks-width: 0.05rem;
  }
</style>

Example

  • Demo

  • Usage with Vue

  • Usage with React

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request 😊

License

GitHub License