organism-ui 0.2.15 → 0.2.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/ui/style_guide/show.html.erb +3 -5
- data/lib/ui.rb +2 -0
- data/lib/ui/actionable.rb +11 -4
- data/lib/ui/breadcrumbs.rb +22 -11
- data/lib/ui/breadcrumbs/breadcrumb.rb +14 -10
- data/lib/ui/card.rb +1 -3
- data/lib/ui/descriptive_list/item.rb +18 -4
- data/lib/ui/dropdown.rb +6 -0
- data/lib/ui/dropdown/show.erb +1 -1
- data/lib/ui/empty/show.erb +1 -3
- data/lib/ui/errors/base.rb +6 -0
- data/lib/ui/errors/invalid_actions.rb +6 -0
- data/lib/ui/errors/invalid_list_items.rb +6 -0
- data/lib/ui/list.rb +19 -7
- data/lib/ui/pagination/window.rb +1 -1
- data/lib/ui/version.rb +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45abc828f8e47547304444edd15b9ffb4ec4377feb286c5559fe4c60d6e23dfd
|
4
|
+
data.tar.gz: 411a58b849148a4f9c1635a8a318784bc25421a4b146a4911ce0bc4c1cec4dfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db0d57b58f82cd7cf96aa9afad5f6862f7ce8b11652e383ca1ac13b5b38c4c1d360b4c6ad9bdbb66d28926f8c9cc66f657efc16ccab365ed5df8bbd3b6ce6649
|
7
|
+
data.tar.gz: d75702678ac862483be221af7bd4a3a19fc60e502767214a14688ca2710814b893a33c1a7907857d9b6631596f13dd24425e051148249bf569656a0c57f9fb1b
|
@@ -674,11 +674,10 @@
|
|
674
674
|
).()
|
675
675
|
}
|
676
676
|
],
|
677
|
-
|
677
|
+
item_renderer: ->(item) {
|
678
678
|
content_tag(
|
679
679
|
:div,
|
680
|
-
|
681
|
-
content_tag(:p, item),
|
680
|
+
content_tag(:p, item) +
|
682
681
|
content_tag(
|
683
682
|
:nav,
|
684
683
|
cell(
|
@@ -687,8 +686,7 @@
|
|
687
686
|
path: '#',
|
688
687
|
size: :small
|
689
688
|
).call(:edit)
|
690
|
-
)
|
691
|
-
]),
|
689
|
+
),
|
692
690
|
class: 'flex flex-row justify-between items-center p-4'
|
693
691
|
)
|
694
692
|
}
|
data/lib/ui.rb
CHANGED
data/lib/ui/actionable.rb
CHANGED
@@ -2,18 +2,25 @@ module Ui
|
|
2
2
|
module Actionable
|
3
3
|
Actions = Types::Array.default([].freeze).of(Types::Callable)
|
4
4
|
|
5
|
-
def actions
|
5
|
+
def actions(object = model)
|
6
6
|
content_tag(:nav, class: 'ui-actions', role: 'navigation') do
|
7
7
|
render_group(
|
8
|
-
|
9
|
-
action.call(
|
8
|
+
actions_list.map do |action|
|
9
|
+
action.call(object)
|
10
10
|
end
|
11
11
|
)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def actions_list
|
16
|
-
|
16
|
+
begin
|
17
|
+
Actions[options.fetch(:actions, Array.new)]
|
18
|
+
rescue Dry::Types::ConstraintError
|
19
|
+
raise Ui::Errors::InvalidActions.new(
|
20
|
+
"Actions for #{self.class.to_s} are invalid. Ensure you are passing " \
|
21
|
+
"an array of callable objects that will be passed a model"
|
22
|
+
)
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
26
|
def actions_length
|
data/lib/ui/breadcrumbs.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Ui
|
2
2
|
class Breadcrumbs < Component
|
3
|
+
include Stylable
|
4
|
+
|
3
5
|
def show
|
4
|
-
content_tag(:nav, class:
|
5
|
-
breadcrumb_links
|
6
|
-
end
|
6
|
+
content_tag(:nav, render_group(breadcrumb_links.flatten), class: style)
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
@@ -13,13 +13,11 @@ module Ui
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def breadcrumb_links
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end.flatten
|
22
|
-
)
|
16
|
+
breadcrumbs.map.with_index do |crumb, index|
|
17
|
+
[item_renderer.call(crumb)].tap do |array|
|
18
|
+
array.unshift(delimiter) unless index == 0
|
19
|
+
end
|
20
|
+
end
|
23
21
|
end
|
24
22
|
|
25
23
|
def delimiter
|
@@ -27,7 +25,20 @@ module Ui
|
|
27
25
|
end
|
28
26
|
|
29
27
|
def item_renderer
|
30
|
-
options[:item_renderer] ||
|
28
|
+
options[:item_renderer] || default_item_renderer
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_item_renderer
|
32
|
+
->(item) {
|
33
|
+
cell(
|
34
|
+
Ui::Breadcrumbs::Breadcrumb,
|
35
|
+
item
|
36
|
+
).()
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def component_style
|
41
|
+
'ui-breadcrumbs'
|
31
42
|
end
|
32
43
|
end
|
33
44
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Ui
|
2
2
|
class Breadcrumbs < Component
|
3
3
|
class Breadcrumb < Component
|
4
|
+
include Stylable
|
5
|
+
|
4
6
|
property :name
|
5
7
|
property :path
|
6
8
|
property :current?
|
@@ -9,7 +11,7 @@ module Ui
|
|
9
11
|
def show
|
10
12
|
content_tag(
|
11
13
|
:span,
|
12
|
-
link_to(
|
14
|
+
link_to(render_group(title), path),
|
13
15
|
class: style
|
14
16
|
)
|
15
17
|
end
|
@@ -17,17 +19,19 @@ module Ui
|
|
17
19
|
private
|
18
20
|
|
19
21
|
def title
|
20
|
-
[name].tap do |array|
|
21
|
-
array.unshift(content_tag(:i, nil, class: icon)) if
|
22
|
-
end
|
22
|
+
[content_tag(:span, name)].tap do |array|
|
23
|
+
array.unshift(content_tag(:i, nil, class: icon)) if has_icon?
|
24
|
+
end
|
23
25
|
end
|
24
26
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
def has_icon?
|
28
|
+
model.try(:icon)
|
29
|
+
end
|
30
|
+
|
31
|
+
def component_style
|
32
|
+
['ui-breadcrumb'].tap do |array|
|
33
|
+
array << 'ui-breadcrumb--current' if current?
|
34
|
+
end.join(' ')
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
data/lib/ui/card.rb
CHANGED
@@ -5,19 +5,33 @@ module Ui
|
|
5
5
|
content_tag(
|
6
6
|
:div,
|
7
7
|
render_group([
|
8
|
-
content_tag(:dt,
|
8
|
+
content_tag(:dt, item_title),
|
9
9
|
content_tag(:dd, value)
|
10
10
|
]),
|
11
11
|
class: 'ui-descriptive-list__item'
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def value
|
16
|
+
render_group([
|
17
|
+
display(item_value)
|
18
|
+
])
|
19
|
+
end
|
20
|
+
|
21
|
+
def display(value)
|
22
|
+
if value.is_a?(Proc)
|
23
|
+
value.call
|
24
|
+
else
|
25
|
+
value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def item_title
|
16
30
|
model[0]
|
17
31
|
end
|
18
32
|
|
19
|
-
def
|
20
|
-
model[1]
|
33
|
+
def item_value
|
34
|
+
model[1]
|
21
35
|
end
|
22
36
|
end
|
23
37
|
end
|
data/lib/ui/dropdown.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Ui
|
2
2
|
class Dropdown < Component
|
3
|
+
include Stylable
|
4
|
+
|
3
5
|
Modes = Types::String.enum(
|
4
6
|
'click',
|
5
7
|
'hover'
|
@@ -18,5 +20,9 @@ module Ui
|
|
18
20
|
def mode
|
19
21
|
Modes[options.fetch(:mode, 'click')]
|
20
22
|
end
|
23
|
+
|
24
|
+
def component_style
|
25
|
+
"ui-dropdown"
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
data/lib/ui/dropdown/show.erb
CHANGED
data/lib/ui/empty/show.erb
CHANGED
data/lib/ui/list.rb
CHANGED
@@ -4,6 +4,7 @@ module Ui
|
|
4
4
|
include Actionable
|
5
5
|
|
6
6
|
Renderable = Types.Interface(:call)
|
7
|
+
ListItems = Types.Interface(:each, :map, :any?)
|
7
8
|
|
8
9
|
def show
|
9
10
|
render
|
@@ -11,21 +12,32 @@ module Ui
|
|
11
12
|
|
12
13
|
private
|
13
14
|
|
15
|
+
def list_data
|
16
|
+
begin
|
17
|
+
ListItems[model]
|
18
|
+
rescue Dry::Types::ConstraintError
|
19
|
+
raise Ui::Errors::InvalidListItems.new(
|
20
|
+
"List items for #{self.class.to_s} are invalid. Ensure you are passing " \
|
21
|
+
"an empty array or array of items that will be passed to the item renderer"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
14
26
|
def list
|
15
27
|
content_tag(:ul, list_items)
|
16
28
|
end
|
17
29
|
|
18
30
|
def list_items
|
19
|
-
if
|
20
|
-
render_group(
|
31
|
+
if rendered_items.any?
|
32
|
+
render_group(rendered_items)
|
21
33
|
else
|
22
34
|
render_empty
|
23
35
|
end
|
24
36
|
end
|
25
37
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
38
|
+
def rendered_items
|
39
|
+
list_data.map do |item|
|
40
|
+
item_renderer.call(item)
|
29
41
|
end
|
30
42
|
end
|
31
43
|
|
@@ -46,8 +58,8 @@ module Ui
|
|
46
58
|
) if options[:footer]
|
47
59
|
end
|
48
60
|
|
49
|
-
def
|
50
|
-
Renderable[options.fetch(:
|
61
|
+
def item_renderer
|
62
|
+
Renderable[options.fetch(:item_renderer, default_renderable)]
|
51
63
|
end
|
52
64
|
|
53
65
|
def default_renderable
|
data/lib/ui/pagination/window.rb
CHANGED
data/lib/ui/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: organism-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nolan Tait
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -215,6 +215,9 @@ files:
|
|
215
215
|
- lib/ui/empty.rb
|
216
216
|
- lib/ui/empty/show.erb
|
217
217
|
- lib/ui/engine.rb
|
218
|
+
- lib/ui/errors/base.rb
|
219
|
+
- lib/ui/errors/invalid_actions.rb
|
220
|
+
- lib/ui/errors/invalid_list_items.rb
|
218
221
|
- lib/ui/list.rb
|
219
222
|
- lib/ui/list/item.rb
|
220
223
|
- lib/ui/list/show.erb
|
@@ -260,7 +263,7 @@ homepage: https://github.com/nolantait/organism-ui
|
|
260
263
|
licenses:
|
261
264
|
- MIT
|
262
265
|
metadata: {}
|
263
|
-
post_install_message:
|
266
|
+
post_install_message:
|
264
267
|
rdoc_options: []
|
265
268
|
require_paths:
|
266
269
|
- lib
|
@@ -276,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
276
279
|
version: '0'
|
277
280
|
requirements: []
|
278
281
|
rubygems_version: 3.1.4
|
279
|
-
signing_key:
|
282
|
+
signing_key:
|
280
283
|
specification_version: 4
|
281
284
|
summary: A collection of ui components implemented in cells.
|
282
285
|
test_files: []
|