matestack-ui-bootstrap 1.4.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +17 -5
  3. data/README.md +53 -19
  4. data/lib/matestack/ui/bootstrap.rb +97 -17
  5. data/{app/concepts → lib}/matestack/ui/bootstrap/apps/admin_template.rb +14 -7
  6. data/lib/matestack/ui/bootstrap/base_component.rb +13 -0
  7. data/lib/matestack/ui/bootstrap/base_vue_js_component.rb +13 -0
  8. data/lib/matestack/ui/bootstrap/components/accordion.rb +58 -0
  9. data/{app/concepts → lib}/matestack/ui/bootstrap/components/alert.js +12 -9
  10. data/lib/matestack/ui/bootstrap/components/alert.rb +43 -0
  11. data/lib/matestack/ui/bootstrap/components/avatar.rb +27 -0
  12. data/lib/matestack/ui/bootstrap/components/badge.rb +32 -0
  13. data/lib/matestack/ui/bootstrap/components/breadcrumb.rb +50 -0
  14. data/lib/matestack/ui/bootstrap/components/button.rb +71 -0
  15. data/lib/matestack/ui/bootstrap/components/button_group.rb +36 -0
  16. data/lib/matestack/ui/bootstrap/components/card.rb +105 -0
  17. data/{app/concepts → lib}/matestack/ui/bootstrap/components/carousel.js +21 -18
  18. data/lib/matestack/ui/bootstrap/components/carousel.rb +103 -0
  19. data/{app/concepts → lib}/matestack/ui/bootstrap/components/close.rb +10 -9
  20. data/{app/concepts → lib}/matestack/ui/bootstrap/components/collapse.js +20 -17
  21. data/lib/matestack/ui/bootstrap/components/collapse.rb +54 -0
  22. data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.js +5 -2
  23. data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.rb +31 -26
  24. data/lib/matestack/ui/bootstrap/components/icon.rb +21 -0
  25. data/lib/matestack/ui/bootstrap/components/list_group.rb +148 -0
  26. data/{app/concepts → lib}/matestack/ui/bootstrap/components/modal.js +24 -21
  27. data/lib/matestack/ui/bootstrap/components/modal.rb +121 -0
  28. data/lib/matestack/ui/bootstrap/components/navbar.rb +163 -0
  29. data/{app/concepts → lib}/matestack/ui/bootstrap/components/page_heading.rb +7 -5
  30. data/{app/concepts → lib}/matestack/ui/bootstrap/components/pagination.rb +15 -13
  31. data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.js +4 -1
  32. data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.rb +26 -22
  33. data/{app/concepts → lib}/matestack/ui/bootstrap/components/progress.rb +24 -24
  34. data/lib/matestack/ui/bootstrap/components/scrollspy.rb +50 -0
  35. data/lib/matestack/ui/bootstrap/components/section_card.rb +33 -0
  36. data/lib/matestack/ui/bootstrap/components/spinner.rb +35 -0
  37. data/lib/matestack/ui/bootstrap/components/tab_nav.rb +79 -0
  38. data/lib/matestack/ui/bootstrap/components/tab_nav_content.rb +35 -0
  39. data/{app/concepts → lib}/matestack/ui/bootstrap/components/toast.js +27 -18
  40. data/lib/matestack/ui/bootstrap/components/toast.rb +113 -0
  41. data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.js +4 -1
  42. data/lib/matestack/ui/bootstrap/components/tooltip.rb +66 -0
  43. data/{app/concepts → lib}/matestack/ui/bootstrap/content/figure.rb +4 -2
  44. data/lib/matestack/ui/bootstrap/content/smart_collection/collection.rb +120 -0
  45. data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/collection.scss +0 -0
  46. data/lib/matestack/ui/bootstrap/content/smart_collection/content.rb +118 -0
  47. data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/filter.rb +7 -3
  48. data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/paginate.rb +19 -14
  49. data/lib/matestack/ui/bootstrap/form/checkbox.rb +90 -0
  50. data/lib/matestack/ui/bootstrap/form/input.rb +118 -0
  51. data/lib/matestack/ui/bootstrap/form/radio.rb +57 -0
  52. data/lib/matestack/ui/bootstrap/form/select.rb +63 -0
  53. data/lib/matestack/ui/bootstrap/form/submit.rb +20 -0
  54. data/lib/matestack/ui/bootstrap/form/switch.rb +32 -0
  55. data/lib/matestack/ui/bootstrap/form/textarea.rb +49 -0
  56. data/lib/matestack/ui/bootstrap/index.js +24 -0
  57. data/lib/matestack/ui/bootstrap/layout/column.rb +49 -0
  58. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/container.rb +12 -9
  59. data/lib/matestack/ui/bootstrap/layout/row.rb +25 -0
  60. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.js +5 -2
  61. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.rb +10 -10
  62. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.scss +0 -0
  63. data/lib/matestack/ui/bootstrap/registry.rb +173 -0
  64. data/{app/javascript/matestack-ui-bootstrap → lib/matestack/ui/bootstrap}/stylesheets/matestack-ui-bootstrap.scss +0 -0
  65. data/lib/matestack/ui/bootstrap/version.rb +1 -1
  66. data/lib/tasks/matestack/ui/bootstrap_tasks.rake +25 -25
  67. metadata +68 -76
  68. data/app/assets/images/avatar-placeholder.png +0 -0
  69. data/app/assets/images/icons/bootstrap-icons.svg +0 -1
  70. data/app/concepts/matestack/ui/bootstrap/components/accordion.rb +0 -53
  71. data/app/concepts/matestack/ui/bootstrap/components/alert.rb +0 -34
  72. data/app/concepts/matestack/ui/bootstrap/components/avatar.rb +0 -27
  73. data/app/concepts/matestack/ui/bootstrap/components/badge.rb +0 -30
  74. data/app/concepts/matestack/ui/bootstrap/components/breadcrumb.rb +0 -46
  75. data/app/concepts/matestack/ui/bootstrap/components/button.rb +0 -54
  76. data/app/concepts/matestack/ui/bootstrap/components/button_group.rb +0 -36
  77. data/app/concepts/matestack/ui/bootstrap/components/card.rb +0 -100
  78. data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +0 -85
  79. data/app/concepts/matestack/ui/bootstrap/components/chart.js +0 -232
  80. data/app/concepts/matestack/ui/bootstrap/components/chart.rb +0 -71
  81. data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +0 -43
  82. data/app/concepts/matestack/ui/bootstrap/components/icon.rb +0 -19
  83. data/app/concepts/matestack/ui/bootstrap/components/list_group.rb +0 -83
  84. data/app/concepts/matestack/ui/bootstrap/components/modal.rb +0 -106
  85. data/app/concepts/matestack/ui/bootstrap/components/navbar.rb +0 -120
  86. data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +0 -33
  87. data/app/concepts/matestack/ui/bootstrap/components/section_card.rb +0 -31
  88. data/app/concepts/matestack/ui/bootstrap/components/spinner.rb +0 -31
  89. data/app/concepts/matestack/ui/bootstrap/components/tab_nav.rb +0 -81
  90. data/app/concepts/matestack/ui/bootstrap/components/tab_nav_content.rb +0 -32
  91. data/app/concepts/matestack/ui/bootstrap/components/toast.rb +0 -99
  92. data/app/concepts/matestack/ui/bootstrap/components/tooltip.rb +0 -82
  93. data/app/concepts/matestack/ui/bootstrap/content/collection/collection.rb +0 -112
  94. data/app/concepts/matestack/ui/bootstrap/content/collection/content.rb +0 -101
  95. data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +0 -90
  96. data/app/concepts/matestack/ui/bootstrap/form/date.js +0 -38
  97. data/app/concepts/matestack/ui/bootstrap/form/date.rb +0 -98
  98. data/app/concepts/matestack/ui/bootstrap/form/input.rb +0 -123
  99. data/app/concepts/matestack/ui/bootstrap/form/radio.rb +0 -65
  100. data/app/concepts/matestack/ui/bootstrap/form/select.haml +0 -11
  101. data/app/concepts/matestack/ui/bootstrap/form/select.rb +0 -74
  102. data/app/concepts/matestack/ui/bootstrap/form/submit.rb +0 -20
  103. data/app/concepts/matestack/ui/bootstrap/form/switch.rb +0 -90
  104. data/app/concepts/matestack/ui/bootstrap/layout/column.rb +0 -47
  105. data/app/concepts/matestack/ui/bootstrap/layout/row.rb +0 -15
  106. data/app/concepts/matestack/ui/bootstrap/pages/devise/sign_in.rb +0 -40
  107. data/app/concepts/matestack/ui/bootstrap/registry.rb +0 -63
  108. data/app/helpers/matestack/ui/bootstrap/application_helper.rb +0 -13
  109. data/app/javascript/matestack-ui-bootstrap/index.js +0 -26
  110. data/app/javascript/packs/matestack-ui-bootstrap.js +0 -2
  111. data/config/routes.rb +0 -2
  112. data/lib/matestack/ui/bootstrap/engine.rb +0 -26
@@ -1,6 +1,9 @@
1
1
  import * as bootstrap from 'bootstrap'
2
+ import Vue from 'vue/dist/vue.esm'
2
3
 
3
- MatestackUiCore.Vue.component('matestack-ui-bootstrap-modal', {
4
+ import MatestackUiCore from 'matestack-ui-core'
5
+
6
+ Vue.component('matestack-ui-bootstrap-modal', {
4
7
  mixins: [MatestackUiCore.componentMixin],
5
8
 
6
9
  data() {
@@ -37,28 +40,28 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-modal', {
37
40
  const self = this
38
41
  var eventHub = MatestackUiCore.matestackEventHub;
39
42
  // toggle_on event registration
40
- if(self.componentConfig["toggle_on"] != undefined){
41
- var toggle_events = self.componentConfig["toggle_on"].split(",")
43
+ if(self.props["toggle_on"] != undefined){
44
+ var toggle_events = self.props["toggle_on"].split(",")
42
45
  toggle_events.forEach(toggle_event => eventHub.$on(toggle_event.trim(), self.toggle));
43
46
  }
44
47
  // show_on event registration
45
- if(self.componentConfig["show_on"] != undefined){
46
- var show_events = self.componentConfig["show_on"].split(",")
48
+ if(self.props["show_on"] != undefined){
49
+ var show_events = self.props["show_on"].split(",")
47
50
  show_events.forEach(show_event => eventHub.$on(show_event.trim(), self.show));
48
51
  }
49
52
  // hide_on event registration
50
- if(self.componentConfig["hide_on"] != undefined){
51
- var hide_events = self.componentConfig["hide_on"].split(",")
53
+ if(self.props["hide_on"] != undefined){
54
+ var hide_events = self.props["hide_on"].split(",")
52
55
  hide_events.forEach(hide_event => eventHub.$on(hide_event.trim(), self.hide));
53
56
  }
54
57
  // handle_update_on event registration
55
- if(self.componentConfig["handle_update_on"] != undefined){
56
- var handle_update_events = self.componentConfig["handle_update_on"].split(",")
58
+ if(self.props["handle_update_on"] != undefined){
59
+ var handle_update_events = self.props["handle_update_on"].split(",")
57
60
  handle_update_events.forEach(handle_update_event => eventHub.$on(handle_update_event.trim(), self.handle_update));
58
61
  }
59
62
  // dispose_on event registration
60
- if(self.componentConfig["dispose_on"] != undefined){
61
- var dispose_events = self.componentConfig["dispose_on"].split(",")
63
+ if(self.props["dispose_on"] != undefined){
64
+ var dispose_events = self.props["dispose_on"].split(",")
62
65
  dispose_events.forEach(dispose_event => eventHub.$on(dispose_event.trim(), self.dispose));
63
66
  }
64
67
  },
@@ -66,24 +69,24 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-modal', {
66
69
  beforeDestroy: function() {
67
70
  const self = this
68
71
  var eventHub = MatestackUiCore.matestackEventHub;
69
- if(self.componentConfig["toggle_on"] != undefined){
70
- var toggle_events = self.componentConfig["toggle_on"].split(",")
72
+ if(self.props["toggle_on"] != undefined){
73
+ var toggle_events = self.props["toggle_on"].split(",")
71
74
  toggle_events.forEach(toggle_event => eventHub.$off(toggle_event.trim(), self.toggle));
72
75
  }
73
- if(self.componentConfig["show_on"] != undefined){
74
- var show_events = self.componentConfig["show_on"].split(",")
76
+ if(self.props["show_on"] != undefined){
77
+ var show_events = self.props["show_on"].split(",")
75
78
  show_events.forEach(show_event => eventHub.$off(show_event.trim(), self.show));
76
79
  }
77
- if(self.componentConfig["hide_on"] != undefined){
78
- var hide_events = self.componentConfig["hide_on"].split(",")
80
+ if(self.props["hide_on"] != undefined){
81
+ var hide_events = self.props["hide_on"].split(",")
79
82
  hide_events.forEach(hide_event => eventHub.$off(hide_event.trim(), self.hide));
80
83
  }
81
- if(self.componentConfig["handle_update_on"] != undefined){
82
- var handle_update_events = self.componentConfig["handle_update_on"].split(",")
84
+ if(self.props["handle_update_on"] != undefined){
85
+ var handle_update_events = self.props["handle_update_on"].split(",")
83
86
  handle_update_events.forEach(handle_update_event => eventHub.$off(handle_update_event.trim(), self.handle_update));
84
87
  }
85
- if(self.componentConfig["dispose_on"] != undefined){
86
- var dispose_events = self.componentConfig["dispose_on"].split(",")
88
+ if(self.props["dispose_on"] != undefined){
89
+ var dispose_events = self.props["dispose_on"].split(",")
87
90
  dispose_events.forEach(dispose_event => eventHub.$off(dispose_event.trim(), self.dispose));
88
91
  }
89
92
  },
@@ -0,0 +1,121 @@
1
+ require_relative "../base_vue_js_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Modal < Matestack::Ui::Bootstrap::BaseVueJsComponent
4
+ vue_name 'matestack-ui-bootstrap-modal'
5
+
6
+ # header attributes, expects a hash or string
7
+ # possible keys `:class, :text, :size`
8
+ optional :header
9
+ # body attributes, expects a hash or string
10
+ # possible keys `:class, :text`
11
+ optional :body
12
+ # footer is a dismiss button, expects a hash or string for button text
13
+ # possible keys `:class, :text`
14
+ optional :footer
15
+ optional :fade, :size
16
+ optional :fullscreen # fullscreen attribute, expects boolean or bootstrap breakpoint
17
+ optional :static, :keyboard, :scrollable, :centered
18
+ optional :modal_dialog_class
19
+ optional :id
20
+ # event trigger
21
+ optional :toggle_on, :show_on, :hide_on, :handle_update_on, :dispose_on
22
+
23
+
24
+
25
+ def response
26
+ div modal_attributes do
27
+ div class: dialog_classes do
28
+ div class: "modal-content" do
29
+ header_partial if context.header || (slots && slots[:header])
30
+ body_partial if context.body || slots && slots[:body]
31
+ footer_partial if context.footer || (slots && slots[:footer])
32
+ yield if block_given?
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ protected
39
+
40
+ def vue_props
41
+ {}.tap do |props|
42
+ props[:toggle_on] = context.toggle_on
43
+ props[:show_on] = context.show_on
44
+ props[:hide_on] = context.hide_on
45
+ props[:handle_update_on] = context.handle_update_on
46
+ props[:dispose_on] = context.dispose_on
47
+ end
48
+ end
49
+
50
+ def header_partial
51
+ header = context.header.is_a?(Hash) ? context.header : { text: context.header }
52
+ div class: "modal-header" do
53
+ if slots && slots[:header]
54
+ slot :header
55
+ else
56
+ heading header[:text], size: (header[:size] || 5), class: "modal-title #{header[:class]}" if header[:text].present?
57
+ bs_close dismiss: 'modal'
58
+ end
59
+ end
60
+ end
61
+
62
+ def body_partial
63
+ body = context.body.is_a?(Hash) ? context.body : { text: context.body }
64
+ div class: "modal-body #{body[:class]}".strip do
65
+ if slots && slots[:body]
66
+ slot :body
67
+ else
68
+ plain body[:text] if body[:text].present?
69
+ end
70
+ end
71
+ end
72
+
73
+ def footer_partial
74
+ footer = context.footer.is_a?(Hash) ? context.footer : { text: context.footer }
75
+ div class: "modal-footer" do
76
+ slot :footer if slots && slots[:footer]
77
+ if footer[:text].present?
78
+ button class: "btn #{footer[:class].present? ? footer[:class] : 'btn-secondary'}",
79
+ data: { "bs-dismiss": 'modal' }, type: 'button' do
80
+ plain footer[:text]
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ def modal_attributes
87
+ attributes = {}.tap do |hash|
88
+ hash[:id] = context.id
89
+ hash[:class] = modal_classes
90
+ hash[:attributes] = { 'tabindex': "-1", 'aria-labelledby': "#{context.id}Label", 'aria-hidden': "true" }
91
+ hash[:data] = {}.tap do |data|
92
+ data[:backdrop] = "static" if context.static
93
+ data[:keyboard] = "false" if context.keyboard
94
+ end
95
+ end
96
+ options.merge(
97
+ attributes
98
+ )
99
+ end
100
+
101
+ def modal_classes
102
+ [].tap do |classes|
103
+ classes << 'modal'
104
+ classes << 'fade' if context.fade || !context.fade.present?
105
+ classes << context.bs_class
106
+ end.join(' ').strip
107
+ end
108
+
109
+ def dialog_classes
110
+ [].tap do |classes|
111
+ classes << 'modal-dialog'
112
+ classes << 'modal-dialog-centered' if context.centered
113
+ classes << 'modal-dialog-scrollable' if context.scrollable
114
+ classes << "modal-#{context.size}" if context.size
115
+ if context.fullscreen.present?
116
+ classes << (context.fullscreen == true ? 'modal-fullscreen' : "modal-fullscreen-#{context.fullscreen}-down")
117
+ end
118
+ classes << context.modal_dialog_class
119
+ end.join(' ').strip
120
+ end
121
+ end
@@ -0,0 +1,163 @@
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Navbar < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ POS_ATTRIBUTES = %i[fixed_top fixed_bottom sticky_top]
6
+ optional *POS_ATTRIBUTES
7
+
8
+ optional class: { as: :bs_class }
9
+ optional :items, :items_class, :theme, :expand_at, :color, :container_size
10
+ optional :collapse_class
11
+ # brand expect hash or string, possible keys for hash: text, path, img
12
+ optional :brand
13
+ # toogle expect hash or a symbol (:left or :right),
14
+ # possible keys for hash: position, class
15
+ optional :toggle
16
+
17
+
18
+ def prepare
19
+ @toggle = context.toggle.is_a?(Hash) ? context.toggle : { position: context.toggle }
20
+ end
21
+
22
+ def response(&block)
23
+ nav navbar_attributes do
24
+ bs_container size: "#{context.container_size.present? ? context.container_size : "fluid" }" do
25
+ # custom elements for navbar
26
+ if slots && slots[:custom_items]
27
+ slot :custom_items
28
+ else
29
+ toggle_button if @toggle[:position] == :left
30
+ brand_partial
31
+ toggle_button if !@toggle[:position].present? || @toggle[:position] == :right
32
+ navbar_content_partial(&block)
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ protected
39
+
40
+ def brand_partial
41
+ brand = context.brand.is_a?(Hash) ? context.brand : { text: context.brand }
42
+ path = brand[:path].present? ? brand[:path] : "/"
43
+ brand[:path] = path
44
+ case brand[:type]
45
+ when :link
46
+ a brand.except(:text).merge(class: "navbar-brand") do
47
+ img height: 40, path: brand[:img], loading: "lazy" if brand[:img].present?
48
+ plain brand[:text]
49
+ end
50
+ else
51
+ transition brand.except(:text).merge(class: "navbar-brand") do
52
+ img height: 40, path: brand[:img], loading: "lazy" if brand[:img].present?
53
+ plain brand[:text]
54
+ end
55
+ end
56
+ end
57
+
58
+ def navbar_content_partial(&block)
59
+ div class: "collapse navbar-collapse #{context.collapse_class}", id: 'matestackNavbarContent' do
60
+ if context.items.present?
61
+ ul class: items_classes do
62
+ context.items.each do |item|
63
+ li class: "nav-item" do
64
+ case item[:type]
65
+ when :link
66
+ a link_config(item) do
67
+ bs_icon name: item[:icon], size: 20 if item[:icon]
68
+ span class: "ps-3" do
69
+ plain item[:text] if item[:text]
70
+ end
71
+ end
72
+ when :action
73
+ action action_config(item) do
74
+ bs_icon name: item[:icon], size: 20 if item[:icon]
75
+ span class: "ps-3" do
76
+ plain item[:text] if item[:text]
77
+ end
78
+ end
79
+ else
80
+ transition transition_config(item) do
81
+ bs_icon name: item[:icon], size: 20 if item[:icon]
82
+ span class: "ps-3" do
83
+ plain item[:text] if item[:text]
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ yield if block_given?
92
+ end
93
+ end
94
+
95
+ def link_config(item)
96
+ config = item.except(:text)
97
+ config[:class] = "nav-link"
98
+ config
99
+ end
100
+
101
+ def transition_config(item)
102
+ config = item.except(:text)
103
+ config[:class] = "nav-link"
104
+ config
105
+ end
106
+
107
+ def action_config(item)
108
+ config = item.except(:text)
109
+ config[:class] = "nav-link"
110
+ config
111
+ end
112
+
113
+ def navbar_attributes
114
+ options.merge(
115
+ class: navbar_classes
116
+ )
117
+ end
118
+
119
+ def navbar_classes
120
+ [].tap do |classes|
121
+ classes << "navbar"
122
+ POS_ATTRIBUTES.each do |pos|
123
+ classes << "#{pos}".gsub('_','-') if context.send("#{pos}")
124
+ end
125
+ classes << "navbar-expand-#{ (context.expand_at.present? ? context.expand_at : "lg") }"
126
+ classes << "navbar-#{context.theme}" if context.theme.present?
127
+ classes << (context.color.present? ? "bg-#{context.color}" : "bg-#{context.theme}") if context.theme || context.color
128
+ classes << context.bs_class
129
+ end.join(' ').strip
130
+ end
131
+
132
+ def toggle_button
133
+ button toggle_attributes do
134
+ bs_icon name: "list", size: 25, class: "text-muted"
135
+ end
136
+ # button toggle_attributes do
137
+ # span class: "navbar-toggler-icon"
138
+ # end
139
+ end
140
+
141
+ def toggle_attributes
142
+ toggle_classes = [].tap do |classes|
143
+ classes << 'btn btn-link navbar-toggler'
144
+ classes << "ms-auto" if @toggle[:position] == :right
145
+ classes << "me-auto" if @toggle[:position] == :left
146
+ classes << @toggle[:class] if @toggle[:class]
147
+ end.join(' ').strip
148
+
149
+ {}.tap do |hash|
150
+ hash[:class] = toggle_classes
151
+ hash[:data] = { "bs-toggle": 'collapse', "bs-target": '#matestackNavbarContent' }
152
+ hash[:attributes] = { 'aria-controls': 'matestackNavbarContent', 'aria-expanded': 'false', 'aria-label': 'Toggle navigation' }
153
+ end
154
+ end
155
+
156
+ def items_classes
157
+ [].tap do |classes|
158
+ classes << 'navbar-nav'
159
+ classes << (context.items_class.present? ? context.items_class : "ms-auto mb-2 mb-lg-0")
160
+ # classes << "ms-auto" unless items_class.present?
161
+ end.join(' ').strip
162
+ end
163
+ end
@@ -1,4 +1,6 @@
1
- class Matestack::Ui::Bootstrap::Components::PageHeading < Matestack::Ui::Component
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::PageHeading < Matestack::Ui::Bootstrap::BaseComponent
2
4
 
3
5
  optional :title, :subtitle, :icon
4
6
 
@@ -8,17 +10,17 @@ class Matestack::Ui::Bootstrap::Components::PageHeading < Matestack::Ui::Compone
8
10
  bs_col do
9
11
  div class: "page-heading-heading" do
10
12
  heading size: 2 do
11
- bs_icon name: icon, size: "35" if icon.present?
12
- plain title
13
+ bs_icon name: context.icon, size: "35" if context.icon.present?
14
+ plain context.title
13
15
  end
14
16
  heading size: 6, class: "text-muted" do
15
- plain subtitle
17
+ plain context.subtitle
16
18
  end
17
19
  end
18
20
  end
19
21
  bs_col md: 12, xl: 4, class: "text-xl-end mt-3" do
20
22
  div class: "page-heading-actions text-xl-end" do
21
- yield_components
23
+ yield if block_given?
22
24
  end
23
25
  end
24
26
  end
@@ -1,23 +1,25 @@
1
- class Matestack::Ui::Bootstrap::Components::Pagination < Matestack::Ui::Component
2
-
3
- optional :aria_label, :size, class: { as: :bs_class }
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Pagination < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ optional :aria_label, :size
4
6
  optional :items
5
7
 
6
- def response
8
+ def response
7
9
  nav pagination_attributes do
8
10
  ul class: ul_classes do
9
- if items.present?
10
- items.each do |item|
11
+ if context.items.present?
12
+ context.items.each do |item|
11
13
  li class: "page-item #{ 'active' if item[:active] }" do
12
14
  if item[:type] == :link
13
- link path: item[:path], text: item[:text], class: 'page-link'
15
+ a item.merge({ class: 'page-link' })
14
16
  else
15
- transition path: item[:path], text: item[:text], class: 'page-link'
17
+ transition item.merge({ class: 'page-link' })
16
18
  end
17
19
  end
18
20
  end
19
21
  end
20
- yield_components
22
+ yield if block_given?
21
23
  end
22
24
  end
23
25
  end
@@ -25,16 +27,16 @@ class Matestack::Ui::Bootstrap::Components::Pagination < Matestack::Ui::Componen
25
27
  protected
26
28
 
27
29
  def pagination_attributes
28
- html_attributes.merge(
29
- attributes: { 'aria-label': "#{aria_label || 'Page navigation'}" }
30
+ options.merge(
31
+ 'aria-label': "#{context.aria_label || 'Page navigation'}"
30
32
  )
31
33
  end
32
34
 
33
35
  def ul_classes
34
36
  [].tap do |classes|
35
37
  classes << "pagination"
36
- classes << "pagination-#{size}" if size.present?
38
+ classes << "pagination-#{context.size}" if context.size.present?
37
39
  end.join(' ').strip
38
40
  end
39
41
 
40
- end
42
+ end