Code Monkey home page Code Monkey logo

angular-weather-widget's Introduction

Angular Weather Widget

Build Status codecov npm version devDependency Status GitHub issues GitHub stars GitHub license

Demo

https://krzysztofsaja.github.io/angular-weather-widget/

Table of contents

About

Weather Widget based on Open Weather Map Api

Installation

Install through npm:

npm install --save angular-weather-widget

Then include in your apps module:

import { Component, NgModule } from '@angular/core';
import { AngularWeatherWidgetModule, WeatherApiName } from 'angular-weather-widget';

@NgModule({
  imports: [
        AngularWeatherWidgetModule.forRoot({
          key: OPEN_WEATHER_MAP_API_KEY,
          name: WeatherApiName.OPEN_WEATHER_MAP,
          baseUrl: 'http://api.openweathermap.org/data/2.5'
        })
  ]
})
export class MyModule {}

Configuration

Use in one of your apps components:

import { Component } from '@angular/core';
import { WeatherSettings, TemperatureScale, ForecastMode, WeatherLayout } from 'angular-weather-widget';


@Component({
  template: '<weather-widget [settings]="settings"></weather-widget>'
})
export class MyComponent {
    settings: WeatherSettings = {
      location: {
        cityName: 'Szczecin'
      },
      backgroundColor: '#347c57',
      color: '#ffffff',
      width: '300px',
      height: 'auto',
      showWind: false,
      scale: TemperatureScale.CELCIUS,
      forecastMode: ForecastMode.DETAILED,
      showDetails: false,
      showForecast: true,
      layout: WeatherLayout.WIDE,
      language: 'en'
    };
}

If you set proper OPEN_WEATHER_MAP_API_KEY key, data will be retrived from Open Weather Map Api. However, you can also pass relevant information from parent component, eg.

import { Component } from '@angular/core';
import { WeatherSettings, TemperatureScale, ForecastMode } from 'angular-weather-widget';


@Component({
  template: '<weather-widget [currentWeather]=currentWeather [forecast]=forecast  [settings]="settings"></weather-widget>'
})
export class MyComponent {
  currentWeather: CurrentWeather = CURRENT_WATHER_MOCK;
  forecast: Forecast[] = FORECAST_MOCK;
  settings: WeatherSettings = {
  location: {
    cityName: 'Szczecin'
  }
};  
}

You may also find it useful to view the demo source. You may also find it useful to view the demo source.

Usage without a module bundler

<script src="node_modules/angular-weather-widget/bundles/angular-weather-widget.umd.js"></script>
<script>
    // everything is exported angularWeatherWidget namespace
</script>

Documentation

All documentation is auto-generated from the source via compodoc and can be viewed here: https://krzysztofsaja.github.io/angular-weather-widget/docs/

Development

Prepare your environment

  • Install Node.js and yarn
  • Install local dev dependencies: yarn while current directory is this repo

Development server

Run yarn start to start a development server on port 8000 with auto reload + tests.

Testing

Run yarn test to run tests once or yarn run test:watch to continually run tests.

Release

  • Bump the version in package.json (once the module hits 1.0 this will become automatic)
yarn run release

License

MIT

angular-weather-widget's People

Contributors

krzysztofsaja avatar kthprog avatar billg118 avatar

Watchers

Matthew G. Harvell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.