
Security News
Node.js TSC Votes to Stop Distributing Corepack
Corepack will be phased out from future Node.js releases following a TSC vote.
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 0 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
Corepack will be phased out from future Node.js releases following a TSC vote.
Research
Security News
Research uncovers Black Basta's plans to exploit package registries for ransomware delivery alongside evidence of similar attacks already targeting open source ecosystems.
Security News
Oxlint's beta release introduces 500+ built-in linting rules while delivering twice the speed of previous versions, with future support planned for custom plugins and improved IDE integration.