Skip to content

Instantly share code, notes, and snippets.

@krainboltgreene
Last active September 24, 2015 05:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krainboltgreene/676052 to your computer and use it in GitHub Desktop.
Save krainboltgreene/676052 to your computer and use it in GitHub Desktop.
An example of draper UI
# This is some sample pseudo-code for a desktop application framework
#
# title: chitter.app - A twitter desktop app
# created: 2020.11.14-00:56:25
# author: Kurtis Rainbolt-Greene
require 'dapper-ui'
require 'looking-glass'
require 'twitter'
version = 1.0 # Sets the version of the software.
(...) # Twitter account logic here!
view 'Chitter - A Twitter Desktop App' do # Opens a new window, with the title as the string.
# You can set the attributes of this window with methods like below
height 800
width 600 # numbers are in pixels
color hsla 20, 20, 20, 100 # hue, saturation, light, and alpha of the background color. can also be represented in graidents like:
# color hsla(20,255,255,100),rgba(224,223,245,100),hsl(222,222,222)
style :main # of course you can always just pull from a .glass style file.
# Styles are cascading, so precedence matters.
stack do # A stack is a collection of flows, or blocks of information. Think a column on a spread sheet.
flow do
text "Personal Timeline", { font: 'Helvetica', color: hsla 50,0,0,100 } # The text method is basically a paragraph of text, and takes a list of styles.
end
for tweet in feed do
stack do # You can have stacks in flows!
color hsla 255, 255, 255 # If a value isn't present, assume 100%.
flow text: tweet.content
flow text: tweet.time
end
end
flow { button 'Refresh Stream' { refresh } } # Certain methods change or re-run the code like JS in the browser.
end
stack do
# And here would be another stack
# Other views can be defined, but it's against the standard. Apps should have single tasks they do very well.
# The first view is the :main view, and other views come with an ID. You can call these views like so:
flow do
button 'Press me to show the timer' do
show :timer
end
end
end
# The resulting app would have two columns. One with a list of text, the other with a single button.
# When the button is clicked a new window opens up with a timer.
end
view :timer, 'Twitter Timer'
# logic
end
# New methods, classes, or other logic can be kept in modules and included in the view.
view :spreadsheet, 'An awesome spreadsheet', SpreadSheet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment