bulmacomp 0.1.0 → 0.1.2

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
  SHA256:
3
- metadata.gz: aba376c1b9ab6ef2532c7c313e28621f910c5959bf0285ce268e2936983ae0c1
4
- data.tar.gz: 5462a699bc0b4fd5985674230ce986a3db9ed7cec16bcd2e098ab234e0793a72
3
+ metadata.gz: cca92c1cfc4fc572cea80c7ee338c832a08aa6f0c7d04440a8ac97a4195c646a
4
+ data.tar.gz: 27ec3921e02f138e0b15899c0f2b692df1ab04acc404af28625bbb50a07d0c5a
5
5
  SHA512:
6
- metadata.gz: 9b4c29854e9bbb3dd9283b698633578d5b8b1c9b0b4868fa919ff392aa1690faa1f59c7cb4e031212d93ddbbde8a3ed966d624b1511dc84d4b83843d82e9d13f
7
- data.tar.gz: 62b1d229680c06b33f75ae136c60999f4942e9f768d01f5ca33d56b1c53c327b33d6f74a6633e58a3835516b5ec16e96854324c4912ba22877f8e51162ec8826
6
+ metadata.gz: 0eb90226ba08d590548c98f9ea4cfac9a4394e1b5520a9c12ef0a96d093187dafa7483fcd187e378f8900c2dee14fc1019c55f585ab975ad8a82894f94cb628a
7
+ data.tar.gz: 2a18563aeab3591580bcc40bd05bcdb2017e98b79581d04fa7444e9aff22733b73dd572811f78912ffd76bf66e7d0c44c4f3a0f296db4b34e9779175934a2563
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Bulmacomp
2
- [https://viewcomponent.org/](ViewComponent) collection for [https://bulma.io/](bulma) css framework
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/b44e91b4f303eb7962b3/maintainability)](https://codeclimate.com/github/isprambiente/bulmacomp/maintainability)
3
+ [![Rails Test](https://github.com/isprambiente/bulmacomp/actions/workflows/rubyonrails.yml/badge.svg)](https://github.com/isprambiente/bulmacomp/actions/workflows/rubyonrails.yml)
4
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/isprambiente/bulmacomp)
3
5
 
4
- ## Usage
5
- How to use my plugin.
6
+
7
+ [https://viewcomponent.org/](ViewComponent) collection for [https://bulma.io/](bulma) css framework
6
8
 
7
9
  ## Installation
8
10
  Add this line to your application's Gemfile:
@@ -21,6 +23,9 @@ Or install it yourself as:
21
23
  $ gem install bulmacomp
22
24
  ```
23
25
 
26
+ ## Usage
27
+ How to use my plugin.
28
+
24
29
  ## Contributing
25
30
  Contribution directions go here.
26
31
 
@@ -11,16 +11,9 @@ module Bulmacomp
11
11
  # </ul>
12
12
  # </nav>
13
13
  #
14
- # @example Empty breadcrumb with option:
15
- # render Bulmacomp::BreadcrumbComponent.new(class: 'breadcrumb one', data: {entity: 'one'})
16
- #
17
- # <nav class="breadcrumb one" aria-label="breadcrumbs" data-entity='one'>
18
- # <ul>
19
- # </ul>
20
- # </nav>
21
- #
22
- # @example Breadcrumb with list element:
23
- # render Bulmacomp::BreadcrumbComponent.new(link_to('one','#'), link_to('two','#'))
14
+ # @example Breadcrumb with elements:
15
+ # elements = [link_to('one','#'), link_to('two','#')]
16
+ # render Bulmacomp::BreadcrumbComponent.new(elements: elements)
24
17
  # <nav class="breadcrumb" aria-label="breadcrumbs">
25
18
  # <ul>
26
19
  # <li><a href="#">one</a></li>
@@ -39,16 +32,16 @@ module Bulmacomp
39
32
  # </ul>
40
33
  # </nav>
41
34
  class BreadcrumbComponent < ViewComponent::Base
42
- # @param [Array<String>] list
43
- # Any number of Objects to push into this collection
44
35
  # @param [Hash] opts
45
36
  # options to generate content
37
+ # @param [Array<String>] elements
38
+ # array of elements to push into this breadcrumbs collection
46
39
  # @option opts [String] :*
47
40
  # each other key going as tag option, default is class: 'breadcrumb', aria_label: 'breadcrumbs'
48
- # @yield [optional] card content
49
- def initialize(*list, **opts)
41
+ # @yield [optional] breadcrumb content
42
+ def initialize(elements: [], **opts)
50
43
  super
51
- @list = list
44
+ @elements = elements
52
45
  @opts = { class: 'breadcrumb', aria: { label: 'breadcrumbs' } }.merge(opts)
53
46
  end
54
47
 
@@ -57,9 +50,9 @@ module Bulmacomp
57
50
  tag.nav tag.ul(ul_content), **@opts
58
51
  end
59
52
 
60
- # @return [Text], safe join of list arguments and proc content
53
+ # @return [Text], safe join of elements arguments and proc content
61
54
  def ul_content
62
- safe_join(@list.map { |e| tag.li(e) }.<<(content))
55
+ safe_join(@elements.map { |e| tag.li(e) }.<<(content))
63
56
  end
64
57
  end
65
58
  end
@@ -8,10 +8,10 @@ module Bulmacomp
8
8
  #
9
9
  # <aside class='menu'></aside>
10
10
  #
11
- # @example menu with title and entries
11
+ # @example menu with title and elements
12
12
  # title = 'Menu title'
13
- # menu = [link_to('first entry', '#'), link_to('second entry', '#')
14
- # render Bulmacomp::MenuComponent.new(title,menu)
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,8 +21,9 @@ module Bulmacomp
21
21
  # </ul>
22
22
  # </aside>
23
23
  #
24
- # @example menu with title and annidate entries
25
- # = render Bulmacomp::MenuComponent.new('Uno',['Due',['Tre','Quattro']])
24
+ # @example menu with title and annidate elements
25
+ # elements = ['Uno',['Due',['Tre','Quattro']]]
26
+ # = render Bulmacomp::MenuComponent.new(elements: elements)
26
27
  #
27
28
  # <aside class='menu'>
28
29
  # <p class='menu-label'>Uno</p>
@@ -46,7 +47,8 @@ module Bulmacomp
46
47
  # </aside>
47
48
  #
48
49
  # @example with mixed conetent (arguments before)
49
- # = render Bulmacomp::MenuComponent.new('argument content',['argoument menu']) do
50
+ # elements = ['argument content',['argoument menu']]
51
+ # = render Bulmacomp::MenuComponent.new(elements: elements) do
50
52
  # %p yield content
51
53
  #
52
54
  # <aside class='menu'>
@@ -58,22 +60,22 @@ module Bulmacomp
58
60
  # </aside>
59
61
  #
60
62
  class MenuComponent < ViewComponent::Base
61
- # @param [Array<String,Array>] list
62
- # each entry is used to generate menu entries throug {first_level} method
63
63
  # @param [Hash] opts
64
64
  # options to generate content
65
+ # @option opts [Array<String>] elements
66
+ # each entry is used to generate menu elements throug {first_level} method
65
67
  # @option opts [String] :*
66
68
  # each key going as tag option, default is class: 'menu'
67
- def initialize(*list, **opts)
69
+ def initialize(elements: [], **opts)
68
70
  super
69
- @list = list
71
+ @elements = elements
70
72
  @opts = { class: 'menu' }.merge(opts)
71
73
  end
72
74
 
73
75
  # Generate an html safe string with full bulma menu.
74
76
  # @return [String] html string menu
75
77
  def call
76
- tag.aside first_level(@list) + content, **@opts
78
+ tag.aside first_level(@elements) + content, **@opts
77
79
  end
78
80
 
79
81
  # Generate a string with all bulma menu element from `values` param.
@@ -82,7 +84,7 @@ module Bulmacomp
82
84
  # * as `p.menu-title` tag if is not an Array
83
85
  # * as {map_menu} if is an Array
84
86
  # @return [String]
85
- # @param [Array] values menu entries
87
+ # @param [Array] values menu elements
86
88
  # @example
87
89
  # Bulmacomp::MenuComponent.new().first_level(['Uno',['Due','Tre']])
88
90
  #
@@ -93,14 +95,14 @@ module Bulmacomp
93
95
  )
94
96
  end
95
97
 
96
- # Generate a string with the "real" menu entries (no title)
97
- # from 'values' param. The menu entries are incapsulated in a ul tag
98
+ # Generate a string with the "real" menu elements (no title)
99
+ # from 'values' param. The menu elements are incapsulated in a ul tag
98
100
  #
99
101
  # Each element in 'values' is mapped:
100
102
  # * as li tag if is not an Array
101
103
  # * as {sub_menu} if is an Array
102
104
  # @return [String]
103
- # @param [Array] values menu entries
105
+ # @param [Array] values menu elements
104
106
  # @example
105
107
  # Bulmacomp::MenuComponent.new().map_menu(['Uno',['Due','Tre']])
106
108
  #
@@ -113,7 +115,7 @@ module Bulmacomp
113
115
  # The first array element is used as ancescor, other element
114
116
  # are used to make the sub menu with {map_menu} method.
115
117
  # @return [String]
116
- # @param [Array] values sub-menu entries
118
+ # @param [Array] values sub-menu elements
117
119
  # @example
118
120
  # Bulmacomp::MenuComponent.new().sub_menu(['Uno',['Due','Tre']])
119
121
  #
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulmacomp
4
+ # Make an html structure for a bulma message
5
+ #
6
+ # @example Empty message
7
+ # render Bulmacomp::MessageComponent.new()
8
+ #
9
+ # <article class="message"></article>
10
+ #
11
+ # @example Message with title
12
+ # render Bulmacomp::MessageComponent.new(title: 'test')
13
+ #
14
+ # <article class="message">
15
+ # <div class="message-header"><p>test</p></div>
16
+ # </article>
17
+ #
18
+ # @example Message with close button and option
19
+ # render Bulmacomp::MessageComponent.new(close: true, close_option: {id: 'close'})
20
+ #
21
+ # <article class="message">
22
+ # <div class="message-header"><button id="close" class="delete" aria-label="delete"></button></div>
23
+ # </article>
24
+ #
25
+ # @example Message with yield content
26
+ #
27
+ # <article class="message">
28
+ # <div class="message-body">test</div>
29
+ # </article>
30
+ class MessageComponent < ViewComponent::Base
31
+ # @param [Hash] opts
32
+ # options to generate content
33
+ # @option opts [String] title
34
+ # Title test, is added in 'article .message-header p' tag if present
35
+ # @option opts [Boolean] close
36
+ # if TRUE add close button in title
37
+ # @option opts [Hash] close_option
38
+ # parameters to close button tag
39
+ # @option opts [String] :*
40
+ # each key going as article tag option, default is class: 'message'
41
+ # @yield [optional] message content
42
+ def initialize(title: nil, close: false, close_option: {}, **opts)
43
+ super
44
+ @title = title
45
+ @close = close
46
+ @close_option = close_option
47
+ @opts = { class: 'message' }.merge opts
48
+ end
49
+
50
+ # return [String] generated bulma message
51
+ def call
52
+ tag.article safe_join([header, tag.div(content, class: 'message-body')]), **@opts
53
+ end
54
+
55
+ # return [String] div.message-header if @title or @close is present
56
+ def header
57
+ ret = []
58
+ ret << tag.p(@title) if @title.present?
59
+ ret << tag.button(**{ class: 'delete', aria: { label: 'delete' } }.merge(@close_option)) if @close
60
+ tag.div safe_join(ret), class: 'message-header' if ret.present?
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulmacomp
4
+ # Make an HTML strucrure for a bulma pagination
5
+ #
6
+ # @example Empty pagination
7
+ # render Bulmacomp::TabsComponent.new()
8
+ #
9
+ # <nav class="pagination" role="navigation" aria-label="pagination"></nav>
10
+ #
11
+ # @example pagination with elements
12
+ # elements = ['<a class="pagination-link" aria-label="Goto page 1">1</a>']
13
+ # render Bulmacomp::TabsComponent.new(elements: elements)
14
+ #
15
+ # <nav class="pagination" role="navigation" aria-label="pagination">
16
+ # <ul class='pagination-list'>
17
+ # <li><a class="pagination-link" aria-label="Goto page 1">1</a></li>
18
+ # </ul>
19
+ # </nav>
20
+ #
21
+ # @example with elements and pre
22
+ # pre = [
23
+ # link_to('Previus', '#', class: 'pagination-previous'),
24
+ # link_to('Next', '#', class: 'pagination-next')
25
+ # ]
26
+ # elements = ['<a class="pagination-link" aria-label="Goto page 1">1</a>']
27
+ # render Bulmacomp::TabsComponent.new(elements: elements, pre: pre)
28
+ #
29
+ # <nav class="pagination" role="navigation" aria-label="pagination">
30
+ # <a href="#" class="pagination-previous">Previous</a>
31
+ # <a href="#" class="pagination-next">Next</a>
32
+ # <ul class='pagination-list'>
33
+ # <li><a class="pagination-link" aria-label="Goto page 1">1</a></li>
34
+ # </ul>
35
+ # </nav>
36
+ #
37
+ # @example with yield
38
+ # = render Bulmacomp::TabsComponent.new() do
39
+ # %li= link_to 'test', '#'
40
+ #
41
+ # <nav class="pagination" role="navigation" aria-label="pagination">
42
+ # <ul class='pagination-list'>
43
+ # <li><a href='#'>test</a></li>
44
+ # </ul>
45
+ # </nav>
46
+ #
47
+ # @example full pagination
48
+ # pre = [
49
+ # link_to('Previus', '#', class: 'pagination-previous'),
50
+ # link_to('Next', '#', class: 'pagination-next')
51
+ # ]
52
+ # elements = ['<a class="pagination-link" aria-label="Goto page 1">1</a>']
53
+ #
54
+ # = render Bulmacomp::TabsComponent.new(elements: elements, pre: pre, id: 'ok') do
55
+ # %li= link_to 'test', '#'
56
+ #
57
+ # <nav class="pagination" role="navigation" aria-label="pagination" id="ok">
58
+ # <a href="#" class="pagination-previous">Previous</a>
59
+ # <a href="#" class="pagination-next">Next</a>
60
+ # <ul class='pagination-list'>
61
+ # <li><a class="pagination-link" aria-label="Goto page 1">1</a></li>
62
+ # <li><a href='#'>test</a></li>
63
+ # </ul>
64
+ # </nav>
65
+ class PaginationComponent < ViewComponent::Base
66
+ # @param [Hash] opts
67
+ # options to generate content
68
+ # @option opts [Array<String>] elements
69
+ # elements list for build tabs
70
+ # @option opts [Array<String>] pre
71
+ # element not in pagination list
72
+ # @option opts [String] :*
73
+ # each key going as tag option, default:
74
+ # * class: "pagination"
75
+ # * role: "navigation"
76
+ # * aria_label: "pagination"
77
+ # @yield [optional] modal content
78
+ def initialize(elements: [], pre: [], **opts)
79
+ super
80
+ @elements = elements
81
+ @pre = pre
82
+ @opts = { class: 'pagination', role: 'navigation', aria_label: 'pagination' }.merge opts
83
+ end
84
+
85
+ # Generate safe string with bulma pagination
86
+ # @return [String] html_safe generated bulma pagination
87
+ def call
88
+ tag.nav safe_join([@pre, ulify]), **@opts
89
+ end
90
+
91
+ # generate a ul tag with map_elements and content
92
+ # @return [String]
93
+ def ulify
94
+ tag.ul safe_join([map_elements, content])
95
+ end
96
+
97
+ # Map elements in a li tag
98
+ # @return [String]
99
+ # @example
100
+ # Bulmacomp::TabsComponent.new(elements: [1,2,3]).map_elements
101
+ #
102
+ # <li>1</li><li>2</li><li>3</li>
103
+ def map_elements
104
+ safe_join(@elements.map { |e| tag.li e })
105
+ end
106
+ end
107
+ end
@@ -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: 'breadcrumb', aria_label: 'breadcrumbs'
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
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulmacomp
4
+ # Make an HTML strucrure for a bulma tabs
5
+ #
6
+ # @example
7
+ # render Bulmacomp::TabsComponent.new()
8
+ #
9
+ # <div class="tabs">
10
+ # <ul></ul>
11
+ # </div>
12
+ #
13
+ # @example tabs with elements
14
+ # elements = [link_to('one','#'), link_to('two','#')]
15
+ # render Bulmacomp::TabsComponent.new(elements: elements)
16
+ #
17
+ # <div class="tabs">
18
+ # <ul>
19
+ # <li><a href='#'>one</li>
20
+ # <li><a href='#'>two</li>
21
+ # </ul>
22
+ # </div>
23
+ #
24
+ # @example tabs with yield content
25
+ # = render Bulmacomp::TabsComponent.new() do
26
+ # %li some text
27
+ #
28
+ # <div class="tabs">
29
+ # <ul>
30
+ # <li>some text</li>
31
+ # </ul>
32
+ # </div>
33
+ #
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
+ #
39
+ # <div class="tabs" id="ok">
40
+ # <ul>
41
+ # <li><a href='#'>one</li>
42
+ # <li><a href='#'>two</li>
43
+ # <li>some text</li>
44
+ # </ul>
45
+ # </div>
46
+ class TabsComponent < ViewComponent::Base
47
+ # @param [Hash] opts
48
+ # options to generate content
49
+ # @param [Array<String>] elements
50
+ # array of elements for tabs collection
51
+ # @option opts [String] :*
52
+ # each other key going as tag option, default is class: 'tabs'
53
+ # @yield [optional] tabs content
54
+ def initialize(elements: [], **opts)
55
+ super
56
+ @elements = elements
57
+ @opts = { class: 'tabs' }.merge(opts)
58
+ end
59
+
60
+ # @return [String] html_safe tabs
61
+ def call
62
+ tag.div tag.ul(ul_content), **@opts
63
+ end
64
+
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])
68
+ end
69
+ end
70
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulmacomp
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.2' # Costant of bulmacomp version
5
5
  end
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.1.0
4
+ version: 0.1.2
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-21 00:00:00.000000000 Z
11
+ date: 2023-03-23 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.4.2
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.4.2
26
+ version: '7.0'
27
27
  description: Collection of view components for bulma css framework
28
28
  email:
29
29
  - andrea.ranaldi@gmail.com
@@ -37,9 +37,12 @@ files:
37
37
  - app/components/bulmacomp/breadcrumb_component.rb
38
38
  - app/components/bulmacomp/card_component.rb
39
39
  - app/components/bulmacomp/menu_component.rb
40
+ - app/components/bulmacomp/message_component.rb
40
41
  - app/components/bulmacomp/modal_component.rb
41
42
  - app/components/bulmacomp/navbar_component.rb
43
+ - app/components/bulmacomp/pagination_component.rb
42
44
  - app/components/bulmacomp/panel_component.rb
45
+ - app/components/bulmacomp/tabs_component.rb
43
46
  - lib/bulmacomp.rb
44
47
  - lib/bulmacomp/engine.rb
45
48
  - lib/bulmacomp/version.rb