Created
May 27, 2016 01:21
-
-
Save ibdknox/bdb1860a88d99dff72d617f2ae63cb33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------- | |
Handle Events | |
----------------- | |
click on a restaurant or pin, show a restaurant | |
app = [@app] | |
[#click element] | |
choose | |
element = [#yelp-restaurant-list-element restaurant] | |
or | |
element = [#yelp-restaurant-pin restaurant] | |
end | |
change forever | |
app.selected := restaurant | |
app.content := "restaurant" | |
end | |
click on yelp logo, show map | |
app = [@app] | |
[#click element] | |
element = [#yelp-logo] | |
change forever | |
app.content := "map" | |
end | |
----------------- | |
Draw the page | |
----------------- | |
draw the selected restaurant | |
[@app content: "restaurant", selected: restaurant] | |
root = [@yelp-root] | |
restaurant = [#restaurant name image] | |
change | |
root.children += [#div class: "restaurant-info", children: | |
[#div class: "info-header", children: | |
[#h2 text: name] | |
[#div children: | |
[#img src: image]]]] | |
end | |
draw the map pane | |
[@app content: "map"] | |
root = [@yelp-root] | |
[#restaurant street city state zip] | |
[#address-to-latlon street city state zip lat long] | |
change | |
root.children = [#map class: "map", pins: [#yelp-restaurant-pin lat lon]] | |
end | |
draw the restaurant list | |
restaurant = [#restaurant name rating] | |
root = [@yelp-root] | |
star-image = "star{rating}.png" | |
change | |
root.children += [#div class: "restaurant-list-container" children: | |
[#div class: "restaurant-list-header" children: [#h1 text: "Restaurants"]] | |
[#div class: "restaurant-list-elements" children: | |
[#div #yelp-restaurant-list-element, class: "restaurant-list-element", | |
restaurant, name, star-image, children: | |
[#h1 text: name] | |
[#img src: star-image]]]] | |
end | |
draw the main page | |
change | |
[#div @yelp-root class: "yelp-root", children: | |
[#div class: "header", children: [#h1 #yelp-logo text: "Yelp"]]] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment