bulmacomp 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b5fe720844eeb9706a76791f3ded3fc1c010fa7442ea375ad69d071bf598bb6
4
- data.tar.gz: 666b242522a9ee87094bf1b4f47e294e41403910b845b72d4594de7fe7bde296
3
+ metadata.gz: cca92c1cfc4fc572cea80c7ee338c832a08aa6f0c7d04440a8ac97a4195c646a
4
+ data.tar.gz: 27ec3921e02f138e0b15899c0f2b692df1ab04acc404af28625bbb50a07d0c5a
5
5
  SHA512:
6
- metadata.gz: 8892fb3dbcce0a46f8ad1238b927e96d6bb0830875ba686600ac557f3446da9cccc64d34c90430f81fc438f0263c8acd0d7c02102410f3081d43813010db7334
7
- data.tar.gz: ec3f10a435462824fd2f67e743daf9a0f978595c1a47fe3004821032d7c13a6951a605127b9ec12ea468bf64467b0e69367b1a366f110bcc9cfd87c6dbf13007
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,9 +11,9 @@ module Bulmacomp
11
11
  # </ul>
12
12
  # </nav>
13
13
  #
14
- # @example Breadcrumb with list element:
15
- # entries = link_to('one','#'), link_to('two','#')
16
- # render Bulmacomp::BreadcrumbComponent.new(entries)
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] card content
42
- def initialize(list = [], **opts)
41
+ # @yield [optional] breadcrumb content
42
+ def initialize(elements: [], **opts)
43
43
  super
44
- @list = list
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 list arguments and proc content
53
+ # @return [Text], safe join of elements arguments and proc content
54
54
  def ul_content
55
- safe_join(@list.map { |e| tag.li(e) }.<<(content))
55
+ safe_join(@elements.map { |e| tag.li(e) }.<<(content))
56
56
  end
57
57
  end
58
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(menu, title: title)
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 entries
25
- # entries = ['Uno',['Due',['Tre','Quattro']]]
26
- # = render Bulmacomp::MenuComponent.new(entries)
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
- # entries = ['argument content',['argoument menu']]
51
- # = render Bulmacomp::MenuComponent.new(entries) do
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(list = [], **opts)
69
+ def initialize(elements: [], **opts)
70
70
  super
71
- @list = list
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(@list) + content, **@opts
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 entries
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 entries (no title)
99
- # 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
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 entries
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 entries
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: '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
@@ -3,16 +3,16 @@
3
3
  module Bulmacomp
4
4
  # Make an HTML strucrure for a bulma tabs
5
5
  #
6
- # @example Empty tabs
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 Tabs with elements
14
- # entries = [link_to('one','#'), link_to('two','#')]
15
- # render Bulmacomp::TabsComponent.new(entries: entries)
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
- # <li class="active"><a href='#'>one</a></li>
26
+ # %li some text
27
27
  #
28
28
  # <div class="tabs">
29
29
  # <ul>
30
- # <li class="active"><a href='#'>one</a></li>
30
+ # <li>some text</li>
31
31
  # </ul>
32
32
  # </div>
33
33
  #
34
- # @example Full tabs
35
- # entries = [link_to('one','#'), link_to('two','#')]
36
- # = render Bulmacomp::TabsComponent.new(entries: entries, id: 'ok') do
37
- # <li class="active"><a href='#'>three</a></li>
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 class="active"><a href='#'>three</a></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
- # @option opts [Array<String>] element
50
- # elements list for build tabs
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] modal content
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 opts
57
+ @opts = { class: 'tabs' }.merge(opts)
58
58
  end
59
59
 
60
- # Generate safe string with full bulma tabs
61
- # @return [String] html_safe generated bulma tabs
60
+ # @return [String] html_safe tabs
62
61
  def call
63
- tag.div ulify, **@opts
62
+ tag.div tag.ul(ul_content), **@opts
64
63
  end
65
64
 
66
- # generate a ul tag with map_elements and content
67
- # @return [String]
68
- def ulify
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
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulmacomp
4
- # Costant of bulmacomp version
5
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2' # Costant of bulmacomp version
6
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.1
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-22 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