Skip to content

Commit 7c56f8e

Browse files
committed
WIP 2.0 migration #2
1 parent 936c450 commit 7c56f8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+593
-493
lines changed

app/concepts/matestack/ui/bootstrap/apps/admin_template.rb

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
class Matestack::Ui::Bootstrap::Apps::AdminTemplate < Matestack::Ui::App
22

33
def response
4+
html do
5+
head do
6+
title "Matestack UI Addon Dummy App"
7+
8+
unescape csrf_meta_tags
9+
# unescape csp_meta_tag
10+
11+
meta charset: "utf-8"
12+
meta name: "viewport", content: "width=device-width, initial-scale=1"
13+
14+
# unescape stylesheet_pack_tag("application", media: "all")
15+
unescape javascript_pack_tag("application")
16+
# unescape Matestack::Ui::Core::Context.controller.view_context.stylesheet_pack_tag(:application)
17+
# unescape Matestack::Ui::Core::Context.controller.view_context.javascript_pack_tag(:application)
18+
end
19+
end
20+
body do
21+
matestack do
22+
body_response do
23+
yield
24+
end
25+
end
26+
end
27+
end
28+
29+
def body_response
430
div class: "d-flex flex-row" do
531
if should_show_sidebar?
6-
bs_sidebar sidebar_navigation_items: sidebar_navigation_items, slots: { sidebar_top: sidebar_top_slot }
32+
bs_sidebar sidebar_navigation_items: sidebar_navigation_items, slots: { sidebar_top: method(:sidebar_top_slot) }
733
end
834
div id: "content", class: "content-wrapper w-100 #{content_background_class}" do
935
if should_show_navbar?
@@ -16,7 +42,7 @@ def response
1642
end
1743
end
1844
bs_container class: "my-5 px-4 pt-5" do
19-
yield_page slots: { loading_state: loading_state_slot }
45+
yield if block_given?
2046
end
2147
end
2248
end
@@ -40,9 +66,7 @@ def should_show_navbar?
4066
end
4167

4268
def sidebar_top_slot
43-
slot do
44-
sidebar_top_partial if self.respond_to?(:sidebar_top_partial)
45-
end
69+
sidebar_top_partial if self.respond_to?(:sidebar_top_partial)
4670
end
4771

4872
def toasts_partial
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Matestack::Ui::Bootstrap::BaseComponent < Matestack::Ui::Component
2+
3+
include Matestack::Ui::Bootstrap::Registry
4+
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Matestack::Ui::Bootstrap::BaseVueJsComponent < Matestack::Ui::VueJsComponent
2+
3+
include Matestack::Ui::Bootstrap::Registry
4+
5+
end

app/concepts/matestack/ui/bootstrap/components/accordion.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Matestack::Ui::Bootstrap::Components::Accordion < Matestack::Ui::Component
1+
class Matestack::Ui::Bootstrap::Components::Accordion < Matestack::Ui::Bootstrap::BaseComponent
22

33
# [ {header: { class, id, text, size, btn_variant, btn_class }, body: { class, text, multi } } ]
44
optional :items # array with 2 Hashes: header and body
@@ -13,7 +13,7 @@ def prepare
1313
def response
1414
div accordion_attributes do
1515
accordion_content_partial if context.items.present?
16-
yield
16+
yield if block_given?
1717
end
1818
end
1919

@@ -25,7 +25,7 @@ def accordion_content_partial
2525
heading class: "accordion-header #{item[:header][:class]}", id: (item[:header][:id] || "header-#{index}"), size: (item[:header][:size] || 2) do
2626
button class: "accordion-button", text:item[:header][:text],
2727
data: { "bs-toggle": "collapse", "bs-target": "#collapse-#{(item[:header][:id] || "header-#{index}") }" },
28-
attributes: { "aria-expanded": "false", "aria-controls": "collapse-#{(item[:header][:id] || "header-#{index}")}", type: "button" }
28+
"aria-expanded": "false", "aria-controls": "collapse-#{(item[:header][:id] || "header-#{index}")}", type: "button"
2929
end
3030
bs_collapse class: "accordion-collapse #{ 'show' if context.open || item[:open] }", id: "collapse-#{(item[:header][:id] || "header-#{index}")}", labelledby: (item[:header][:id] || "header-#{index}"),
3131
parent: @accordion_id, multi: (item[:body][:multi] || false) do
@@ -41,7 +41,7 @@ def accordion_attributes
4141
options.merge(
4242
id: @accordion_id,
4343
class: accordion_classes
44-
).merge(context.attributes)
44+
).merge(context.attributes || {})
4545
end
4646

4747
def accordion_classes

app/concepts/matestack/ui/bootstrap/components/alert.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Matestack::Ui::Bootstrap::Components::Alert < Matestack::Ui::VueJsComponent
1+
class Matestack::Ui::Bootstrap::Components::Alert < Matestack::Ui::Bootstrap::BaseVueJsComponent
22
vue_name "matestack-ui-bootstrap-alert"
33

44
optional :title, :text, :variant, :dismissible, :animate, :title_size, :class
@@ -8,7 +8,7 @@ def response
88
div alert_attributes do
99
heading context.title, size: (title_size || 4), class: 'alert-heading' if context.title
1010
plain context.text if context.text
11-
yield
11+
yield if block_given?
1212
bs_close dismiss: "alert" if context.dismissible
1313
end
1414
end
@@ -26,8 +26,8 @@ def alert_classes
2626

2727
def alert_attributes
2828
{}.tap do |attrs|
29-
attrs.class = alert_classes,
30-
attrs.role = :alert
29+
attrs[:class] = alert_classes,
30+
attrs[:role] = :alert
3131
end
3232
end
3333

app/concepts/matestack/ui/bootstrap/components/avatar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Matestack::Ui::Bootstrap::Components::Avatar < Matestack::Ui::Component
1+
class Matestack::Ui::Bootstrap::Components::Avatar < Matestack::Ui::Bootstrap::BaseComponent
22

33
optional :text, :bg_variant, :text_variant, :img_path, :size, :class
44

app/concepts/matestack/ui/bootstrap/components/badge.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
class Matestack::Ui::Bootstrap::Components::Badge < Matestack::Ui::Component
1+
class Matestack::Ui::Bootstrap::Components::Badge < Matestack::Ui::Bootstrap::BaseComponent
22

33
optional :class
44
optional :text, :variant, :rounded, :visually_hidden
55

66
def response
77
span badge_attributes do
88
plain context.text if context.text
9-
yield
9+
yield if block_given?
1010
end
11-
span class: "visually-hidden", text: context.visually_hidden if context.visually_hidden.present?
11+
span context.visually_hidden, class: "visually-hidden" if context.visually_hidden.present?
1212
end
1313

1414
protected

app/concepts/matestack/ui/bootstrap/components/breadcrumb.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Matestack::Ui::Bootstrap::Components::Breadcrumb < Matestack::Ui::Component
1+
class Matestack::Ui::Bootstrap::Components::Breadcrumb < Matestack::Ui::Bootstrap::BaseComponent
22

33
optional :items # list of items with path and text
44
optional :class # adding custom class to breadcrumb list
@@ -19,7 +19,7 @@ def response
1919
end
2020
end
2121
end
22-
yield
22+
yield if block_given?
2323
end
2424
end
2525
end
@@ -29,7 +29,7 @@ def response
2929
def link_attrs(last = false)
3030
{}.tap do |hash|
3131
hash[:class] = "breadcrumb-item #{'active' if last}"
32-
hash["aria-current"] = "page" if last
32+
hash[:"aria-current"] = "page" if last
3333
end
3434
end
3535

app/concepts/matestack/ui/bootstrap/components/button.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Matestack::Ui::Bootstrap::Components::Button < Matestack::Ui::Component
1+
class Matestack::Ui::Bootstrap::Components::Button < Matestack::Ui::Bootstrap::BaseComponent
22

33
optional :text, :type, :variant, :size, :outline
44
optional :attributes, :class
@@ -37,16 +37,17 @@ def button_response
3737

3838
def inner_response
3939
plain text if text
40-
yield
40+
yield if block_given?
4141
end
4242

4343
protected
4444

4545
def button_attributes
46-
options.merge(
47-
type: context.type || 'button',
48-
class: button_classes,
49-
).merge(context.attributes)
46+
options.tap do |opts|
47+
opts[:type] = context.type || 'button'
48+
opts[:class] = button_classes
49+
opts.merge(context.attributes || {})
50+
end
5051
end
5152

5253
def button_classes

app/concepts/matestack/ui/bootstrap/components/button_group.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
class Matestack::Ui::Bootstrap::Components::ButtonGroup < Matestack::Ui::Component
1+
class Matestack::Ui::Bootstrap::Components::ButtonGroup < Matestack::Ui::Bootstrap::BaseComponent
22

33
optional :class
44
optional :label
55
optional :toolbar, :size, :vertical
66

77
def response
88
div buttongroup_attributes do
9-
yield
9+
yield if block_given?
1010
end
1111
end
1212

@@ -16,7 +16,7 @@ def buttongroup_attributes
1616
attributes = {}.tap do |hash|
1717
hash[:class] = buttongroup_classes
1818
hash[:role] = "#{context.toolbar ? :toolbar : :group}"
19-
hash["aria-label"] = 'aria-label': context.label
19+
hash[:"aria-label"] = 'aria-label': context.label
2020
end
2121
options.merge(
2222
attributes

0 commit comments

Comments
 (0)