bulmacomp 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/bulmacomp/breadcrumb_component.rb +3 -10
- data/app/components/bulmacomp/menu_component.rb +6 -4
- data/app/components/bulmacomp/message_component.rb +63 -0
- data/app/components/bulmacomp/pagination_component.rb +107 -0
- data/app/components/bulmacomp/tabs_component.rb +82 -0
- data/lib/bulmacomp/version.rb +2 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5fe720844eeb9706a76791f3ded3fc1c010fa7442ea375ad69d071bf598bb6
|
4
|
+
data.tar.gz: 666b242522a9ee87094bf1b4f47e294e41403910b845b72d4594de7fe7bde296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8892fb3dbcce0a46f8ad1238b927e96d6bb0830875ba686600ac557f3446da9cccc64d34c90430f81fc438f0263c8acd0d7c02102410f3081d43813010db7334
|
7
|
+
data.tar.gz: ec3f10a435462824fd2f67e743daf9a0f978595c1a47fe3004821032d7c13a6951a605127b9ec12ea468bf64467b0e69367b1a366f110bcc9cfd87c6dbf13007
|
@@ -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
14
|
# @example Breadcrumb with list element:
|
23
|
-
#
|
15
|
+
# entries = link_to('one','#'), link_to('two','#')
|
16
|
+
# render Bulmacomp::BreadcrumbComponent.new(entries)
|
24
17
|
# <nav class="breadcrumb" aria-label="breadcrumbs">
|
25
18
|
# <ul>
|
26
19
|
# <li><a href="#">one</a></li>
|
@@ -46,7 +39,7 @@ module Bulmacomp
|
|
46
39
|
# @option opts [String] :*
|
47
40
|
# each other key going as tag option, default is class: 'breadcrumb', aria_label: 'breadcrumbs'
|
48
41
|
# @yield [optional] card content
|
49
|
-
def initialize(
|
42
|
+
def initialize(list = [], **opts)
|
50
43
|
super
|
51
44
|
@list = list
|
52
45
|
@opts = { class: 'breadcrumb', aria: { label: 'breadcrumbs' } }.merge(opts)
|
@@ -11,7 +11,7 @@ module Bulmacomp
|
|
11
11
|
# @example menu with title and entries
|
12
12
|
# title = 'Menu title'
|
13
13
|
# menu = [link_to('first entry', '#'), link_to('second entry', '#')
|
14
|
-
# render Bulmacomp::MenuComponent.new(title
|
14
|
+
# render Bulmacomp::MenuComponent.new(menu, title: title)
|
15
15
|
#
|
16
16
|
# <aside class='menu'>
|
17
17
|
# <p class='menu-label'>Menu title</p>
|
@@ -22,7 +22,8 @@ module Bulmacomp
|
|
22
22
|
# </aside>
|
23
23
|
#
|
24
24
|
# @example menu with title and annidate entries
|
25
|
-
# =
|
25
|
+
# entries = ['Uno',['Due',['Tre','Quattro']]]
|
26
|
+
# = render Bulmacomp::MenuComponent.new(entries)
|
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
|
-
# =
|
50
|
+
# entries = ['argument content',['argoument menu']]
|
51
|
+
# = render Bulmacomp::MenuComponent.new(entries) do
|
50
52
|
# %p yield content
|
51
53
|
#
|
52
54
|
# <aside class='menu'>
|
@@ -64,7 +66,7 @@ module Bulmacomp
|
|
64
66
|
# options to generate content
|
65
67
|
# @option opts [String] :*
|
66
68
|
# each key going as tag option, default is class: 'menu'
|
67
|
-
def initialize(
|
69
|
+
def initialize(list = [], **opts)
|
68
70
|
super
|
69
71
|
@list = list
|
70
72
|
@opts = { class: 'menu' }.merge(opts)
|
@@ -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
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bulmacomp
|
4
|
+
# Make an HTML strucrure for a bulma tabs
|
5
|
+
#
|
6
|
+
# @example Empty tabs
|
7
|
+
# render Bulmacomp::TabsComponent.new()
|
8
|
+
#
|
9
|
+
# <div class="tabs">
|
10
|
+
# <ul></ul>
|
11
|
+
# </div>
|
12
|
+
#
|
13
|
+
# @example Tabs with elements
|
14
|
+
# entries = [link_to('one','#'), link_to('two','#')]
|
15
|
+
# render Bulmacomp::TabsComponent.new(entries: entries)
|
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 yield
|
25
|
+
# = render Bulmacomp::TabsComponent.new() do
|
26
|
+
# <li class="active"><a href='#'>one</a></li>
|
27
|
+
#
|
28
|
+
# <div class="tabs">
|
29
|
+
# <ul>
|
30
|
+
# <li class="active"><a href='#'>one</a></li>
|
31
|
+
# </ul>
|
32
|
+
# </div>
|
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>
|
38
|
+
#
|
39
|
+
# <div class="tabs" id="ok">
|
40
|
+
# <ul>
|
41
|
+
# <li><a href='#'>one</li>
|
42
|
+
# <li><a href='#'>two</li>
|
43
|
+
# <li class="active"><a href='#'>three</a></li>
|
44
|
+
# </ul>
|
45
|
+
# </div>
|
46
|
+
class TabsComponent < ViewComponent::Base
|
47
|
+
# @param [Hash] opts
|
48
|
+
# options to generate content
|
49
|
+
# @option opts [Array<String>] element
|
50
|
+
# elements list for build tabs
|
51
|
+
# @option opts [String] :*
|
52
|
+
# each key going as tag option, default is class: 'tabs'
|
53
|
+
# @yield [optional] modal content
|
54
|
+
def initialize(elements: [], **opts)
|
55
|
+
super
|
56
|
+
@elements = elements
|
57
|
+
@opts = { class: 'tabs' }.merge opts
|
58
|
+
end
|
59
|
+
|
60
|
+
# Generate safe string with full bulma tabs
|
61
|
+
# @return [String] html_safe generated bulma tabs
|
62
|
+
def call
|
63
|
+
tag.div ulify, **@opts
|
64
|
+
end
|
65
|
+
|
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 })
|
80
|
+
end
|
81
|
+
end
|
82
|
+
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.1.
|
4
|
+
version: 0.1.1
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -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
|