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

kws-weather-widgets

v2.0.3

Published

Demonstration Weather Widgets

Downloads

7

Readme

Built With Stencil

My Weather Widgets

This is a sample web component library that contains some simple weather related widgets. This library contains the following components:

  • Simple
    • kws-temperature - takes a temperature in Kelvin and displays the value in either Celcius or Fahrenheit
    • kws-uv-index - takes a UV Index value and displays the value with a description and color coding
    • kws-condition - given a mapping of condition types to image URLs and a condition code, determines which code to use and displays the image with a label
  • Compound
    • kws-daily-forecast - condition, date, low, high

Usage

Include the library in your project: npm i kws-weather-widgets

The Stencil documentation site has an excellent Framework Integration Guide. Following that to guide to integrate the library with your project.

Note: if you are using Vue, the prefix used is kws so the ignoredElements line is Vue.config.ignoredElements = [/kws-\w*/];.

Images

This library does not include its own images. In order to inform the library how to get the images to use, you need to set up a map that specifies the image file to use for each of the weather conditions.

Here is an example:

export class IconMap {
  sunny = 'assets/images/sunny.png';
  cloudy = 'assets/images/cloudy.png';
  lightRain = 'assets/images/rain.png';
  shower = 'assets/images/shower.png';
  sunnyThunderStorm = 'assets/images/partial-tstorm.png';
  thunderStorm = 'assets/images/tstorm.png';
  fog = 'assets/images/fog.png';
  snow = 'assets/images/snow.png';
  unknown = 'assets/images/unknown.png';
}

Components

Any component that take a condition assumes that the condition is one of the condition codes used by OpenWeatherMap.org.

Examples shown below are using Angular property bindings. Use whatever is appropriate for the architecture of your application.

kws-temperature

Displays the temperature, given in Kelvin, in the given scale (C or F).

<kws-temperature scale="F" temperature="297"></kws-temperature>

kws-condition

Displays the current condition in both text and icon form.

<kws-condition [condition]="200" [iconPaths]="iconMap"></kws-condition>

kws-daily-forecast

Displays the forcast for a given day.

<kws-daily-forecast scale="F" [forecasts]="forecastData" [iconPaths]="iconMap"></kws-daily-forecast>

The forecast property is an array of forecast data for a single day in the following format:

export interface Forecast {
  date: Date;
  condition: number;
  temperature: number;
}

This data will be the weather conditions every X hours throughout the day. The component figures out a general condition to use for that day from the given data.

The temperature is specified in Kelvin.

kws-uv-index

Displays the UV index along with a risk level, in a color appropriate for the level of risk.

<kws-uv-index [uvIndex]="value"></kws-uv-index>