![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
csdemo-weather-widgets
Advanced tools
This is a sample custom element library that contains some simple weather related elements. This library contains the following custom elements:
This library is not currently published to NPM, so the easiest way to include it is to:
npm run build
npm link
npm link csdemo-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 csdemo
so the ignoredElements
line is Vue.config.ignoredElements = [/csdemo-\w*/];
.
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';
}
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.
csdemo-temperature
Displays the temperature
, given in Kelvin, in the given scale
(C or F).
<csdemo-temperature scale="F" temperature="297"></csdemo-temperature>
csdemo-condition
Displays the current condition in both text and icon form.
<csdemo-condition [condition]="200" [iconPaths]="iconMap"></csdemo-condition>
csdemo-daily-forecast
Displays the forcast for a given day.
<csdemo-daily-forecast scale="F" [forecasts]="forecastData" [iconPaths]="iconMap"></csdemo-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.
csdemo-uv-index
Displays the UV index along with a risk level, in a color appropriate for the level of risk.
<csdemo-uv-index [uvIndex]="value"></csdemo-uv-index>
FAQs
Demonstration Weather Widgets
The npm package csdemo-weather-widgets receives a total of 3 weekly downloads. As such, csdemo-weather-widgets popularity was classified as not popular.
We found that csdemo-weather-widgets demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.