dom-rb 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 506d56aaaa6c084470621a2b06ede1564a619014
4
- data.tar.gz: 41005f31a9cda1c1106ce501307f3bbab5a47735
3
+ metadata.gz: 2a1e4262174591a71793ff83f613266799532cef
4
+ data.tar.gz: e3446a6022ed4daef1a4d0baa819bdfc5d502d52
5
5
  SHA512:
6
- metadata.gz: 63ec0c8fe718cc6e45a8acea70f090b334cd442f2d8e58ae17eec03dbe7ee4fc256c05ed2e016fb5d7c8c0fd5090ef8fcadb84297d318439d76cd6a9bc622348
7
- data.tar.gz: 9eea6f3341e0a9421748e0a2b7c995930b5595be4071b77db2572e41cdb2eeff52d9ae2da86fd63aa7f465bf4ce5be4aaaeff6c103935dc5ac817acd220016ef
6
+ metadata.gz: 849d13f0b39045e93dac4887de8e254ed34e3e5076abd21a806ac9a8c74140b882fa2000bd9c06cbc51d39513b8810e72c0b174cf94a9bf6a8761c5d5c702212
7
+ data.tar.gz: 6dc0612437026220e2015338cf050de46a0df7d7dcd9b690f8c164c68650d626c4a02e839343426e49f1488289d870d3f2718f7717cb02b1fc6437099476c44b
@@ -80,41 +80,41 @@ module CSR
80
80
  )
81
81
  end
82
82
 
83
- def remove_sign_icon(callback: nil, tooltip: nil, popover: nil)
83
+ def remove_sign_icon(callback: nil, attributes: nil, tooltip: nil, popover: nil)
84
84
  icon(
85
85
  :remove_sign,
86
86
  callback: callback,
87
- attributes: { style: {color: 'red'} },
87
+ attributes: merge_attributes({ style: {color: 'red'} }, attributes),
88
88
  tooltip: tooltip,
89
89
  popover: popover
90
90
  )
91
91
  end
92
92
 
93
- def refresh_icon(callback: nil, tooltip: nil, popover: nil)
93
+ def refresh_icon(callback: nil, attributes: nil, tooltip: nil, popover: nil)
94
94
  icon(
95
95
  :refresh,
96
96
  callback: callback,
97
- attributes: { style: {color: 'inherit'} },
97
+ attributes: merge_attributes({ style: { color: 'inherit' } }, attributes),
98
98
  tooltip: tooltip,
99
99
  popover: popover
100
100
  )
101
101
  end
102
102
 
103
- def save_icon(callback: nil, tooltip: nil, popover: nil)
103
+ def save_icon(callback: nil, attributes: nil, tooltip: nil, popover: nil)
104
104
  icon(
105
105
  :save,
106
106
  callback: callback,
107
- attributes: { style: {color: 'inherit'} },
107
+ attributes: merge_attributes({ style: { color: 'inherit' } }, attributes),
108
108
  tooltip: tooltip,
109
109
  popover: popover
110
110
  )
111
111
  end
112
112
 
113
- def hamburger_icon(callback: nil, tooltip: nil, popover: nil)
113
+ def hamburger_icon(callback: nil, attributes: nil, tooltip: nil, popover: nil)
114
114
  icon(
115
115
  :menu_hamburger,
116
116
  callback: callback,
117
- attributes: { style: {color: 'inherit'} },
117
+ attributes: merge_attributes({ style: { color: 'inherit' } }, attributes),
118
118
  tooltip: tooltip,
119
119
  popover: popover
120
120
  )
@@ -134,17 +134,15 @@ module CSR
134
134
  if menu_attributes
135
135
  _menu_attributes = merge_attributes(_menu_attributes, menu_attributes)
136
136
  end
137
- tag(
138
- :div,
137
+ div(
139
138
  attributes: {
140
139
  class: 'dropdown',
141
140
  },
142
141
  content: [
143
- tag(
144
- :div,
142
+ div(
145
143
  attributes: {
146
144
  class: 'dropdown-toggle',
147
- data_toggle: 'dropdown'
145
+ data_toggle: 'dropdown',
148
146
  },
149
147
  content: icon(
150
148
  icon,
@@ -228,7 +226,7 @@ module CSR
228
226
  font_size: 'smaller',
229
227
  margin_left: '0.5em',
230
228
  margin_right: '0.5em',
231
- vertical_align: 'middle',
229
+ margin_top: '0.3em',
232
230
  color: 'inherit',
233
231
  background_color: 'inherit',
234
232
  }.merge(
@@ -49,18 +49,19 @@ module CSR
49
49
  result
50
50
  end
51
51
 
52
- # args are hashes, lowest to highest precedence
53
- # TODO: only handles two levels deep (style, onclick, ...)
52
+ # args are hashes, lowest to highest precedence,
53
+ # i.e. later args override earlier args
54
+ # goes deep recursively
54
55
  def merge_attributes(*args)
55
56
  result = args[0] || {}
56
57
  args.each do |arg|
57
58
  if arg
58
- arg.each_pair do |k,v|
59
- prev = result[k]
60
- if Hash == v && Hash === prev
61
- result[k] = v.merge(prev)
59
+ arg.each_pair do |key, next_value|
60
+ current_value = result[key]
61
+ if Hash === current_value && Hash === next_value
62
+ result[key] = merge_attributes(current_value, next_value)
62
63
  else
63
- result[k] = v
64
+ result[key] = next_value
64
65
  end
65
66
  end
66
67
  end
@@ -1,5 +1,5 @@
1
1
  module CSR
2
2
  module DOM
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dom-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Gunn