teacup 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1627 -0
- data/lib/teacup-ios/stylesheet_extensions/autoresize.rb +1 -1
- data/lib/teacup-ios/stylesheet_extensions/device.rb +1 -1
- data/lib/teacup-osx/style_extensions/autoresize.rb +1 -1
- data/lib/teacup/constraint.rb +9 -0
- data/lib/teacup/limelight.rb +19 -0
- data/lib/teacup/stylesheet.rb +10 -0
- data/lib/teacup/stylesheet_extensions/constraints.rb +1 -1
- data/lib/teacup/stylesheet_extensions/transform.rb +1 -1
- data/lib/teacup/version.rb +1 -1
- data/spec/ios/stylesheet_spec.rb +3 -1
- data/spec/limelight_spec.rb +27 -0
- metadata +6 -2
data/lib/teacup/constraint.rb
CHANGED
@@ -122,6 +122,8 @@ module Teacup
|
|
122
122
|
self.priority = :high # this is the xcode default
|
123
123
|
end
|
124
124
|
|
125
|
+
# c.equals(100)
|
126
|
+
# c.equals(:superview, :width)
|
125
127
|
def equals(relative_to, attribute2=nil)
|
126
128
|
self.set_relationship(NSLayoutRelationEqual, relative_to, attribute2)
|
127
129
|
end
|
@@ -169,6 +171,13 @@ module Teacup
|
|
169
171
|
times 1.0/multiplier
|
170
172
|
end
|
171
173
|
|
174
|
+
# If no relationship has been set, the "use case" here is:
|
175
|
+
#
|
176
|
+
# c.plus(10).equals(:view, :x)
|
177
|
+
#
|
178
|
+
# Which is the same as
|
179
|
+
#
|
180
|
+
# c.equals(:view, :x).minus(10)
|
172
181
|
def plus(constant)
|
173
182
|
if not self.relationship
|
174
183
|
constant = -constant
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Teacup
|
2
|
+
class Limelight
|
3
|
+
include StylesheetExtension
|
4
|
+
attr :styles
|
5
|
+
|
6
|
+
def initialize(&block)
|
7
|
+
@styles = {}
|
8
|
+
instance_exec(&block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(property, value=nil, &more_props)
|
12
|
+
if more_props
|
13
|
+
value = Limelight.new(&more_props).styles
|
14
|
+
end
|
15
|
+
styles[property] = value
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/teacup/stylesheet.rb
CHANGED
@@ -65,6 +65,8 @@ module Teacup
|
|
65
65
|
# a second phase, the ':extends' chain is flattened.
|
66
66
|
#
|
67
67
|
class Stylesheet
|
68
|
+
include StylesheetExtension
|
69
|
+
|
68
70
|
attr_reader :name
|
69
71
|
|
70
72
|
class << self
|
@@ -249,6 +251,7 @@ module Teacup
|
|
249
251
|
end
|
250
252
|
|
251
253
|
queries.each do |stylename|
|
254
|
+
|
252
255
|
# reset the stylesheet_cache for this stylename
|
253
256
|
@stylesheet_cache.delete(stylename) if @stylesheet_cache
|
254
257
|
|
@@ -319,6 +322,13 @@ module Teacup
|
|
319
322
|
end
|
320
323
|
end
|
321
324
|
|
325
|
+
# supports the 'new-style' stylesheet syntax.
|
326
|
+
# @example
|
327
|
+
def method_missing(stylename, &styles)
|
328
|
+
properties = Limelight.new(&styles).styles
|
329
|
+
style(stylename, properties)
|
330
|
+
end
|
331
|
+
|
322
332
|
protected
|
323
333
|
|
324
334
|
# The list of Stylesheets or names that have been imported into this one.
|
data/lib/teacup/version.rb
CHANGED
data/spec/ios/stylesheet_spec.rb
CHANGED
@@ -25,8 +25,10 @@ describe "Teacup::Stylesheet" do
|
|
25
25
|
style :example_button,
|
26
26
|
frame: [[0, 0], [100, 100]]
|
27
27
|
|
28
|
-
style :example_label,
|
28
|
+
style :example_label,
|
29
29
|
backgroundColor: :blue
|
30
|
+
|
31
|
+
style :example_textfield, extends: :example_label
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
describe "Teacup::Stylesheet" do
|
2
|
+
|
3
|
+
describe "Limelight-style syntax" do
|
4
|
+
before do
|
5
|
+
@limelight = Teacup::Stylesheet.new :most_generic do
|
6
|
+
label {
|
7
|
+
backgroundColor :blue
|
8
|
+
title 'In the lime light'
|
9
|
+
}
|
10
|
+
|
11
|
+
button {
|
12
|
+
title 'Click Here!'
|
13
|
+
layer {
|
14
|
+
color :blue
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have styles" do
|
21
|
+
@limelight.query(:label)[:backgroundColor].should == :blue
|
22
|
+
@limelight.query(:label)[:title].should == 'In the lime light'
|
23
|
+
@limelight.query(:button)[:title].should == 'Click Here!'
|
24
|
+
@limelight.query(:button)[:layer][:color].should == :blue
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teacup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- the rubymotion community
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Teacup is a community-driven DSL for RubyMotion. It has CSS-like styling, and
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- lib/teacup/core_extensions/view_getters.rb
|
28
28
|
- lib/teacup/handler.rb
|
29
29
|
- lib/teacup/layout.rb
|
30
|
+
- lib/teacup/limelight.rb
|
30
31
|
- lib/teacup/merge_defaults.rb
|
31
32
|
- lib/teacup/restyle.rb
|
32
33
|
- lib/teacup/stylesheet.rb
|
@@ -56,6 +57,7 @@ files:
|
|
56
57
|
- lib/teacup-osx/style.rb
|
57
58
|
- lib/teacup-osx/style_extensions/autoresize.rb
|
58
59
|
- lib/teacup.rb
|
60
|
+
- README.md
|
59
61
|
- spec/ios/appearance_spec.rb
|
60
62
|
- spec/ios/calculations_spec.rb
|
61
63
|
- spec/ios/child_controllers_spec.rb
|
@@ -77,6 +79,7 @@ files:
|
|
77
79
|
- spec/ios/ui_view_getters_spec.rb
|
78
80
|
- spec/ios/uiswitch_spec.rb
|
79
81
|
- spec/ios/view_spec.rb
|
82
|
+
- spec/limelight_spec.rb
|
80
83
|
homepage: https://github.com/rubymotion/teacup
|
81
84
|
licenses:
|
82
85
|
- BSD
|
@@ -123,3 +126,4 @@ test_files:
|
|
123
126
|
- spec/ios/ui_view_getters_spec.rb
|
124
127
|
- spec/ios/uiswitch_spec.rb
|
125
128
|
- spec/ios/view_spec.rb
|
129
|
+
- spec/limelight_spec.rb
|