bulmacomp 0.1.1 → 1.0.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 +38 -4
- data/app/components/bulmacomp/breadcrumb_component.rb +10 -10
- data/app/components/bulmacomp/dropdown_component.rb +115 -0
- data/app/components/bulmacomp/menu_component.rb +18 -18
- data/app/components/bulmacomp/panel_component.rb +2 -3
- data/app/components/bulmacomp/tabs_component.rb +22 -34
- data/lib/bulmacomp/version.rb +1 -2
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03f4ba3be9bf671e75a46e7e6269bb992e8249e595a939a045b71091ad74baa4
|
|
4
|
+
data.tar.gz: 7f2455a6f4b08c00aae69819a2f603c46dd26bcd6c63546d2c39785d58393e63
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5dd184d2ba86cd80d0b29660d0c20bb890cdfb61eb9468beb055281e66acce8346c31f1f002e696a322a11af2e004e35b3493a190fe9f2ca2923f57ac111ed7
|
|
7
|
+
data.tar.gz: 31100768b00f36a1c5d7ba730a4235aae1a1816877d7f62c9a2ca6213ff81c6c19b245b6cd2939798b63b0f5a7a98ab98d5cd613787b0c1a572aacab2609a112
|
data/README.md
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
# Bulmacomp
|
|
2
|
-
[https://
|
|
2
|
+
[](https://badge.fury.io/rb/bulmacomp)
|
|
3
|
+
[](https://codeclimate.com/github/isprambiente/bulmacomp/maintainability)
|
|
4
|
+
[](https://github.com/isprambiente/bulmacomp/actions/workflows/rubyonrails.yml)
|
|
5
|
+
[](https://www.rubydoc.info/github/isprambiente/bulmacomp)
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
Bulmacomp is a [ViewComponent](https://viewcomponent.org/) collection for [Bulma](https://bulma.io/) css framework.
|
|
8
|
+
|
|
9
|
+
Bulmacomp provide a "view component" for each bulma component:
|
|
10
|
+
|
|
11
|
+
* [Breadcrumb](https://bulma.io/documentation/components/breadcrumb/) - [Bulmacomp::BreadcrumbComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/BreadcrumbComponent)
|
|
12
|
+
* [Card](https://bulma.io/documentation/components/card/) - [Bulmacomp::CardComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/CardComponent)
|
|
13
|
+
* [Dropdown](https://bulma.io/documentation/components/dropdown/) - [Bulmacomp::DropdownComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/DropdownComponent)
|
|
14
|
+
* [Menu](https://bulma.io/documentation/components/menu/) - [Bulmacomp::MenuComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/MenuComponent)
|
|
15
|
+
* [Message](https://bulma.io/documentation/components/message/) - [Bulmacomp::MessageComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/MessageComponent)
|
|
16
|
+
* [Modal](https://bulma.io/documentation/components/modal/) - [Bulmacomp::ModalCompoent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/ModalCompoent)
|
|
17
|
+
* [Navbar](https://bulma.io/documentation/components/navbar/) - [Bulmacomp::NavbarCompoent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/NavbarComponent)
|
|
18
|
+
* [Pagination](https://bulma.io/documentation/components/pagination/) - [Bulmacomp::PaginationComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/PaginationComponent)
|
|
19
|
+
* [Panel](https://bulma.io/documentation/components/panel/) - [Bulmacomp::PanelComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/PanelComponent)
|
|
20
|
+
* [Tabs](https://bulma.io/documentation/components/tabs/) - [Bulmacomp::TabsComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/tabsComponent)
|
|
6
21
|
|
|
7
22
|
## Installation
|
|
8
23
|
Add this line to your application's Gemfile:
|
|
@@ -21,8 +36,27 @@ Or install it yourself as:
|
|
|
21
36
|
$ gem install bulmacomp
|
|
22
37
|
```
|
|
23
38
|
|
|
39
|
+
## Usage
|
|
40
|
+
Bulmacomp provide standard view components. You can simply render of a new instance of the components with your parameters:
|
|
41
|
+
```ruby
|
|
42
|
+
render Bulmacomp::MessageComponent.new(title: 'example', close: true, close_options: {id: 'close'}) do
|
|
43
|
+
Some content
|
|
44
|
+
end
|
|
45
|
+
```
|
|
46
|
+
returns
|
|
47
|
+
```html
|
|
48
|
+
<article class="message">
|
|
49
|
+
<div class="message-header">
|
|
50
|
+
<p>Example</p>
|
|
51
|
+
<button id="close" class="delete" aria-label="delete" data-close='message'></button>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="message-body">Some content</div>
|
|
54
|
+
</article>
|
|
55
|
+
```
|
|
56
|
+
You can get more details from [View Component site](https://viewcomponent.org/) and [Bulmacom documentation](https://rubydoc.info/github/isprambiente/bulmacomp/main)
|
|
57
|
+
|
|
24
58
|
## Contributing
|
|
25
|
-
|
|
59
|
+
Issues, forks and pull requests are welcomed
|
|
26
60
|
|
|
27
61
|
## License
|
|
28
62
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -11,9 +11,9 @@ module Bulmacomp
|
|
|
11
11
|
# </ul>
|
|
12
12
|
# </nav>
|
|
13
13
|
#
|
|
14
|
-
# @example Breadcrumb with
|
|
15
|
-
#
|
|
16
|
-
# render Bulmacomp::BreadcrumbComponent.new(
|
|
14
|
+
# @example Breadcrumb with elements:
|
|
15
|
+
# elements = [link_to('one','#'), link_to('two','#')]
|
|
16
|
+
# render Bulmacomp::BreadcrumbComponent.new(elements: elements)
|
|
17
17
|
# <nav class="breadcrumb" aria-label="breadcrumbs">
|
|
18
18
|
# <ul>
|
|
19
19
|
# <li><a href="#">one</a></li>
|
|
@@ -32,16 +32,16 @@ module Bulmacomp
|
|
|
32
32
|
# </ul>
|
|
33
33
|
# </nav>
|
|
34
34
|
class BreadcrumbComponent < ViewComponent::Base
|
|
35
|
-
# @param [Array<String>] list
|
|
36
|
-
# Any number of Objects to push into this collection
|
|
37
35
|
# @param [Hash] opts
|
|
38
36
|
# options to generate content
|
|
37
|
+
# @param [Array<String>] elements
|
|
38
|
+
# array of elements to push into this breadcrumbs collection
|
|
39
39
|
# @option opts [String] :*
|
|
40
40
|
# each other key going as tag option, default is class: 'breadcrumb', aria_label: 'breadcrumbs'
|
|
41
|
-
# @yield [optional]
|
|
42
|
-
def initialize(
|
|
41
|
+
# @yield [optional] breadcrumb content
|
|
42
|
+
def initialize(elements: [], **opts)
|
|
43
43
|
super
|
|
44
|
-
@
|
|
44
|
+
@elements = elements
|
|
45
45
|
@opts = { class: 'breadcrumb', aria: { label: 'breadcrumbs' } }.merge(opts)
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -50,9 +50,9 @@ module Bulmacomp
|
|
|
50
50
|
tag.nav tag.ul(ul_content), **@opts
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
# @return [Text], safe join of
|
|
53
|
+
# @return [Text], safe join of elements arguments and proc content
|
|
54
54
|
def ul_content
|
|
55
|
-
safe_join(@
|
|
55
|
+
safe_join(@elements.map { |e| tag.li(e) }.<<(content))
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bulmacomp
|
|
4
|
+
# Make an html structure for a bulma dropdown
|
|
5
|
+
#
|
|
6
|
+
# @example empty dropdown
|
|
7
|
+
# render Bulmacomp::DropdownComponent.new()
|
|
8
|
+
#
|
|
9
|
+
# <div class="dropdown">
|
|
10
|
+
# <div class="dropdown-trigger">
|
|
11
|
+
# <button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
|
|
12
|
+
# <span class="icon is-small"><i class="fas fa-angle-down" aria-hidden="true"></i></span>
|
|
13
|
+
# </button>
|
|
14
|
+
# </div>
|
|
15
|
+
# <div class="dropdown-menu" role="menu">
|
|
16
|
+
# <div class="dropdown-content"></div>
|
|
17
|
+
# </div>
|
|
18
|
+
# </div>
|
|
19
|
+
# @example dropdown with title and elements
|
|
20
|
+
# render Bulmacomp::DropdownComponent.new(title: 'title', elements: [1,2])
|
|
21
|
+
#
|
|
22
|
+
# <div class="dropdown">
|
|
23
|
+
# <div class="dropdown-trigger">
|
|
24
|
+
# <button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
|
|
25
|
+
# <span>title</span>
|
|
26
|
+
# <span class="icon is-small"><i class="fas fa-angle-down" aria-hidden="true"></i></span>
|
|
27
|
+
# </button>
|
|
28
|
+
# </div>
|
|
29
|
+
# <div class="dropdown-menu" role="menu">
|
|
30
|
+
# <div class="dropdown-content">
|
|
31
|
+
# <div class="dropdown-item">1</div>
|
|
32
|
+
# <div class="dropdown-item">2</div>
|
|
33
|
+
# </div>
|
|
34
|
+
# </div>
|
|
35
|
+
# </div>
|
|
36
|
+
#
|
|
37
|
+
# @example dropdown with yield, elements and other option
|
|
38
|
+
# = render Bulmacomp::DropdownComponent.new(title: 'title', elements: [1,2], id: 'menu',
|
|
39
|
+
# button_options: {class: 'button is-success'}, icon: nil) do
|
|
40
|
+
# some content
|
|
41
|
+
#
|
|
42
|
+
# <div class="dropdown">
|
|
43
|
+
# <div class="dropdown-trigger">
|
|
44
|
+
# <button class="button is-success" aria-haspopup="true" aria-controls="dropdown-menu">
|
|
45
|
+
# <span>title</span>
|
|
46
|
+
# </button>
|
|
47
|
+
# </div>
|
|
48
|
+
# <div class="dropdown-menu" role="menu">
|
|
49
|
+
# <div class="dropdown-content">
|
|
50
|
+
# <div class="dropdown-item">1</div>
|
|
51
|
+
# <div class="dropdown-item">2</div>
|
|
52
|
+
# some content
|
|
53
|
+
# </div>
|
|
54
|
+
# </div>
|
|
55
|
+
# </div>
|
|
56
|
+
#
|
|
57
|
+
class DropdownComponent < ViewComponent::Base
|
|
58
|
+
# @param [Hash] opts
|
|
59
|
+
# options to generate content
|
|
60
|
+
# @option opts [String] title
|
|
61
|
+
# Content of button, default empty string
|
|
62
|
+
# @option opts [Array<String>] elements
|
|
63
|
+
# collection of dropdown-item
|
|
64
|
+
# @option opts [String] icon
|
|
65
|
+
# icon span class content for button,
|
|
66
|
+
# default: <i class="fas fa-angle-down" aria-hidden="true"></i>
|
|
67
|
+
# @option opts {Hash} button_options
|
|
68
|
+
# options for button tag
|
|
69
|
+
# @option opts [String] :*
|
|
70
|
+
# each key going as content tag option, default is class: 'dropdown'
|
|
71
|
+
# @yield [optional] dropdown content
|
|
72
|
+
def initialize(title: nil, elements: [], icon: default_icon, button_options: {}, **opts)
|
|
73
|
+
super
|
|
74
|
+
@title = tag.span title if title.present?
|
|
75
|
+
@elements = elements
|
|
76
|
+
@icon = tag.span icon, class: 'icon is-small' if icon.present?
|
|
77
|
+
@button_options = default_button_options.merge(button_options)
|
|
78
|
+
@opts = default_opts.merge(opts)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# @return [String] default content for button icon
|
|
82
|
+
def default_icon
|
|
83
|
+
'<i class="fas fa-angle-down" aria-hidden="true"></i>'.html_safe
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# @return [Hash] default option for content tag
|
|
87
|
+
def default_opts
|
|
88
|
+
{ class: 'dropdown' }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# return [Hash] default option for button tag
|
|
92
|
+
def default_button_options
|
|
93
|
+
{ class: 'button', aria: { haspopup: 'true', controls: 'dropdown-menu' } }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Generated html string for bulma dropdown
|
|
97
|
+
# @return [String]
|
|
98
|
+
def call
|
|
99
|
+
tag.div safe_join([tag_trigger, tag_content]), **@opts
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# generated html for '.dropdown-trigger' div
|
|
103
|
+
# @return [String]
|
|
104
|
+
def tag_trigger
|
|
105
|
+
tag.div tag.button(safe_join([@title, @icon]), **@button_options), class: 'dropdown-trigger'
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# generated html for '.dropdown-content' div.
|
|
109
|
+
# Map each content of {elements} in a '.dropdown-item' div and add yield content
|
|
110
|
+
# @return [String]
|
|
111
|
+
def tag_content
|
|
112
|
+
tag.div safe_join([@elements.map { |e| tag.div(e, class: 'dropdown-item') }, content]), class: 'dropdown-content'
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -8,10 +8,10 @@ module Bulmacomp
|
|
|
8
8
|
#
|
|
9
9
|
# <aside class='menu'></aside>
|
|
10
10
|
#
|
|
11
|
-
# @example menu with title and
|
|
11
|
+
# @example menu with title and elements
|
|
12
12
|
# title = 'Menu title'
|
|
13
|
-
#
|
|
14
|
-
# render Bulmacomp::MenuComponent.new(
|
|
13
|
+
# elements = [link_to('first entry', '#'), link_to('second entry', '#')
|
|
14
|
+
# render Bulmacomp::MenuComponent.new(elements: elements, title: title)
|
|
15
15
|
#
|
|
16
16
|
# <aside class='menu'>
|
|
17
17
|
# <p class='menu-label'>Menu title</p>
|
|
@@ -21,9 +21,9 @@ module Bulmacomp
|
|
|
21
21
|
# </ul>
|
|
22
22
|
# </aside>
|
|
23
23
|
#
|
|
24
|
-
# @example menu with title and annidate
|
|
25
|
-
#
|
|
26
|
-
# = render Bulmacomp::MenuComponent.new(
|
|
24
|
+
# @example menu with title and annidate elements
|
|
25
|
+
# elements = ['Uno',['Due',['Tre','Quattro']]]
|
|
26
|
+
# = render Bulmacomp::MenuComponent.new(elements: elements)
|
|
27
27
|
#
|
|
28
28
|
# <aside class='menu'>
|
|
29
29
|
# <p class='menu-label'>Uno</p>
|
|
@@ -47,8 +47,8 @@ module Bulmacomp
|
|
|
47
47
|
# </aside>
|
|
48
48
|
#
|
|
49
49
|
# @example with mixed conetent (arguments before)
|
|
50
|
-
#
|
|
51
|
-
# = render Bulmacomp::MenuComponent.new(
|
|
50
|
+
# elements = ['argument content',['argoument menu']]
|
|
51
|
+
# = render Bulmacomp::MenuComponent.new(elements: elements) do
|
|
52
52
|
# %p yield content
|
|
53
53
|
#
|
|
54
54
|
# <aside class='menu'>
|
|
@@ -60,22 +60,22 @@ module Bulmacomp
|
|
|
60
60
|
# </aside>
|
|
61
61
|
#
|
|
62
62
|
class MenuComponent < ViewComponent::Base
|
|
63
|
-
# @param [Array<String,Array>] list
|
|
64
|
-
# each entry is used to generate menu entries throug {first_level} method
|
|
65
63
|
# @param [Hash] opts
|
|
66
64
|
# options to generate content
|
|
65
|
+
# @option opts [Array<String>] elements
|
|
66
|
+
# each entry is used to generate menu elements throug {first_level} method
|
|
67
67
|
# @option opts [String] :*
|
|
68
68
|
# each key going as tag option, default is class: 'menu'
|
|
69
|
-
def initialize(
|
|
69
|
+
def initialize(elements: [], **opts)
|
|
70
70
|
super
|
|
71
|
-
@
|
|
71
|
+
@elements = elements
|
|
72
72
|
@opts = { class: 'menu' }.merge(opts)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
# Generate an html safe string with full bulma menu.
|
|
76
76
|
# @return [String] html string menu
|
|
77
77
|
def call
|
|
78
|
-
tag.aside first_level(@
|
|
78
|
+
tag.aside first_level(@elements) + content, **@opts
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
# Generate a string with all bulma menu element from `values` param.
|
|
@@ -84,7 +84,7 @@ module Bulmacomp
|
|
|
84
84
|
# * as `p.menu-title` tag if is not an Array
|
|
85
85
|
# * as {map_menu} if is an Array
|
|
86
86
|
# @return [String]
|
|
87
|
-
# @param [Array] values menu
|
|
87
|
+
# @param [Array] values menu elements
|
|
88
88
|
# @example
|
|
89
89
|
# Bulmacomp::MenuComponent.new().first_level(['Uno',['Due','Tre']])
|
|
90
90
|
#
|
|
@@ -95,14 +95,14 @@ module Bulmacomp
|
|
|
95
95
|
)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
# Generate a string with the "real" menu
|
|
99
|
-
# from 'values' param. The menu
|
|
98
|
+
# Generate a string with the "real" menu elements (no title)
|
|
99
|
+
# from 'values' param. The menu elements are incapsulated in a ul tag
|
|
100
100
|
#
|
|
101
101
|
# Each element in 'values' is mapped:
|
|
102
102
|
# * as li tag if is not an Array
|
|
103
103
|
# * as {sub_menu} if is an Array
|
|
104
104
|
# @return [String]
|
|
105
|
-
# @param [Array] values menu
|
|
105
|
+
# @param [Array] values menu elements
|
|
106
106
|
# @example
|
|
107
107
|
# Bulmacomp::MenuComponent.new().map_menu(['Uno',['Due','Tre']])
|
|
108
108
|
#
|
|
@@ -115,7 +115,7 @@ module Bulmacomp
|
|
|
115
115
|
# The first array element is used as ancescor, other element
|
|
116
116
|
# are used to make the sub menu with {map_menu} method.
|
|
117
117
|
# @return [String]
|
|
118
|
-
# @param [Array] values sub-menu
|
|
118
|
+
# @param [Array] values sub-menu elements
|
|
119
119
|
# @example
|
|
120
120
|
# Bulmacomp::MenuComponent.new().sub_menu(['Uno',['Due','Tre']])
|
|
121
121
|
#
|
|
@@ -29,14 +29,13 @@ module Bulmacomp
|
|
|
29
29
|
# @option opts [String] :title
|
|
30
30
|
# panel title
|
|
31
31
|
# @option opts [String] :*
|
|
32
|
-
# each other key going as tag option, default is class: '
|
|
32
|
+
# each other key going as tag option, default is class: 'panel'
|
|
33
33
|
# @yield [optional]
|
|
34
34
|
# panel content
|
|
35
35
|
def initialize(title: nil, **opts)
|
|
36
36
|
super
|
|
37
37
|
@title = title
|
|
38
|
-
@opts = opts
|
|
39
|
-
@opts[:class] = 'panel' unless @opts[:class]
|
|
38
|
+
@opts = { class: 'panel' }.merge(opts)
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
# return [String] html_safe generated bulma panel
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
module Bulmacomp
|
|
4
4
|
# Make an HTML strucrure for a bulma tabs
|
|
5
5
|
#
|
|
6
|
-
# @example
|
|
6
|
+
# @example
|
|
7
7
|
# render Bulmacomp::TabsComponent.new()
|
|
8
8
|
#
|
|
9
9
|
# <div class="tabs">
|
|
10
10
|
# <ul></ul>
|
|
11
11
|
# </div>
|
|
12
12
|
#
|
|
13
|
-
# @example
|
|
14
|
-
#
|
|
15
|
-
# render Bulmacomp::TabsComponent.new(
|
|
13
|
+
# @example tabs with elements
|
|
14
|
+
# elements = [link_to('one','#'), link_to('two','#')]
|
|
15
|
+
# render Bulmacomp::TabsComponent.new(elements: elements)
|
|
16
16
|
#
|
|
17
17
|
# <div class="tabs">
|
|
18
18
|
# <ul>
|
|
@@ -21,62 +21,50 @@ module Bulmacomp
|
|
|
21
21
|
# </ul>
|
|
22
22
|
# </div>
|
|
23
23
|
#
|
|
24
|
-
# @example yield
|
|
24
|
+
# @example tabs with yield content
|
|
25
25
|
# = render Bulmacomp::TabsComponent.new() do
|
|
26
|
-
#
|
|
26
|
+
# %li some text
|
|
27
27
|
#
|
|
28
28
|
# <div class="tabs">
|
|
29
29
|
# <ul>
|
|
30
|
-
# <li
|
|
30
|
+
# <li>some text</li>
|
|
31
31
|
# </ul>
|
|
32
32
|
# </div>
|
|
33
33
|
#
|
|
34
|
-
# @example
|
|
35
|
-
#
|
|
36
|
-
# = render Bulmacomp::TabsComponent.new(
|
|
37
|
-
#
|
|
34
|
+
# @example tabs with full options
|
|
35
|
+
# elements = [link_to('one','#'), link_to('two','#')]
|
|
36
|
+
# = render Bulmacomp::TabsComponent.new(elements: elements, id: 'ok') do
|
|
37
|
+
# %li some text
|
|
38
38
|
#
|
|
39
39
|
# <div class="tabs" id="ok">
|
|
40
40
|
# <ul>
|
|
41
41
|
# <li><a href='#'>one</li>
|
|
42
42
|
# <li><a href='#'>two</li>
|
|
43
|
-
# <li
|
|
43
|
+
# <li>some text</li>
|
|
44
44
|
# </ul>
|
|
45
45
|
# </div>
|
|
46
46
|
class TabsComponent < ViewComponent::Base
|
|
47
47
|
# @param [Hash] opts
|
|
48
48
|
# options to generate content
|
|
49
|
-
# @
|
|
50
|
-
# elements
|
|
49
|
+
# @param [Array<String>] elements
|
|
50
|
+
# array of elements for tabs collection
|
|
51
51
|
# @option opts [String] :*
|
|
52
|
-
# each key going as tag option, default is class: 'tabs'
|
|
53
|
-
# @yield [optional]
|
|
52
|
+
# each other key going as tag option, default is class: 'tabs'
|
|
53
|
+
# @yield [optional] tabs content
|
|
54
54
|
def initialize(elements: [], **opts)
|
|
55
55
|
super
|
|
56
56
|
@elements = elements
|
|
57
|
-
@opts = { class: 'tabs' }.merge
|
|
57
|
+
@opts = { class: 'tabs' }.merge(opts)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
#
|
|
61
|
-
# @return [String] html_safe generated bulma tabs
|
|
60
|
+
# @return [String] html_safe tabs
|
|
62
61
|
def call
|
|
63
|
-
tag.div
|
|
62
|
+
tag.div tag.ul(ul_content), **@opts
|
|
64
63
|
end
|
|
65
64
|
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
tag.ul safe_join([map_elements, content])
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Map elements in a li tag
|
|
73
|
-
# @return [String]
|
|
74
|
-
# @example
|
|
75
|
-
# Bulmacomp::TabsComponent.new(elements).map_elements
|
|
76
|
-
#
|
|
77
|
-
# <li>1</li><li>2</li><li>3</li>
|
|
78
|
-
def map_elements
|
|
79
|
-
safe_join(@elements.map { |e| tag.li e })
|
|
65
|
+
# @return [Text], safe join of elements arguments and proc content
|
|
66
|
+
def ul_content
|
|
67
|
+
safe_join([@elements.map { |e| tag.li(e) }, content])
|
|
80
68
|
end
|
|
81
69
|
end
|
|
82
70
|
end
|
data/lib/bulmacomp/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bulmacomp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- MDreW
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-03-
|
|
11
|
+
date: 2023-03-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 7.0
|
|
19
|
+
version: '7.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 7.0
|
|
26
|
+
version: '7.0'
|
|
27
27
|
description: Collection of view components for bulma css framework
|
|
28
28
|
email:
|
|
29
29
|
- andrea.ranaldi@gmail.com
|
|
@@ -36,6 +36,7 @@ files:
|
|
|
36
36
|
- Rakefile
|
|
37
37
|
- app/components/bulmacomp/breadcrumb_component.rb
|
|
38
38
|
- app/components/bulmacomp/card_component.rb
|
|
39
|
+
- app/components/bulmacomp/dropdown_component.rb
|
|
39
40
|
- app/components/bulmacomp/menu_component.rb
|
|
40
41
|
- app/components/bulmacomp/message_component.rb
|
|
41
42
|
- app/components/bulmacomp/modal_component.rb
|
|
@@ -52,8 +53,8 @@ licenses:
|
|
|
52
53
|
- MIT
|
|
53
54
|
metadata:
|
|
54
55
|
homepage_uri: https://github.com/isprambiente/bulmacomp
|
|
55
|
-
source_code_uri: https://github.com/
|
|
56
|
-
changelog_uri: https://github.com/
|
|
56
|
+
source_code_uri: https://github.com/isprambiente/bulmacomp
|
|
57
|
+
changelog_uri: https://github.com/isprambiente/bulmacomp
|
|
57
58
|
post_install_message:
|
|
58
59
|
rdoc_options: []
|
|
59
60
|
require_paths:
|