Skip to content

Commit

Permalink
Add show icon feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Schneider committed Jun 10, 2015
1 parent f8aca15 commit 1136a3b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.6.0
* Add show icon feature

## 0.5.1
* Fix bugs when API call was unsuccessful

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

Displays the temperature in the status bar of Atom.

![Screenshot](http://i.imgur.com/6PRbC4b.png)
![Screenshot](http://i.imgur.com/9hxsmDq.png)

More features coming soon, feel free to put in requests or contribute!

## Configuration

Configuration for weather can be found by going to: settings > packages > weather and click on settings.

### Show Icon
By default weather will show an icon associated with the current weather. To change this, check/uncheck the option.

### Zipcode
By default weather uses the zipcode 43201. Enter in your zipcode into the text box and you're all set!

Expand Down
12 changes: 12 additions & 0 deletions lib/weather-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class WeatherView extends HTMLElement
setInterval(@fetchWeather.bind(@), @updateInterval())

atom.config.onDidChange 'weather.zipcode', @fetchWeather.bind(@)
atom.config.onDidChange 'weather.showIcon', @fetchWeather.bind(@)

isVisible: ->
@classList.contains('hidden')
Expand All @@ -35,11 +36,22 @@ class WeatherView extends HTMLElement
zipcode: ->
atom.config.get('weather.zipcode')

iconUrl: (iconName) ->
'http://openweathermap.org/img/w/' + iconName + '.png'

showIcon: (iconName) ->
return unless atom.config.get 'weather.showIcon'

img = document.createElement('img')
img.setAttribute('src', @iconUrl(iconName))
@content.appendChild(img)

weatherUrl: ->
'http://api.openweathermap.org/data/2.5/weather?zip=' + @zipcode() + ',us&units=imperial'

showWeather: (weather) ->
@content.innerText = Math.round(weather.main.temp) + 'F'
@showIcon(weather.weather[0].icon)

fetchWeather: ->
console.info('Fetching weather')
Expand Down
3 changes: 3 additions & 0 deletions lib/weather.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module.exports = Weather =
updateInterval:
type: 'integer'
default: 15
showIcon:
type: 'boolean'
default: true

consumeStatusBar: (statusBar) ->
@statusBarTile = statusBar.addRightTile(item: @weatherView, priority: 100)
Expand Down
8 changes: 7 additions & 1 deletion styles/weather.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
// for a full listing of what's available.
@import "ui-variables";

.weather {
.weather .weather-content img {
height: 30px;
width: auto;
}

.weather .weather-content {
color: gray;
}

0 comments on commit 1136a3b

Please sign in to comment.