Skip to content

Commit 936c450

Browse files
committed
WIP 2.0 migration
1 parent 6b66965 commit 936c450

Some content is hidden

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

59 files changed

+869
-858
lines changed

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ gem 'redcarpet' # for markdown usage
99
gem 'rouge' # for syntax highlighting
1010

1111
gem 'bootsnap', require: false
12-
gem "trailblazer-cells"
13-
gem "cells-rails"
14-
gem "cells-haml"
12+
1513

1614
# Declare your gem's dependencies in matestack-ui-material.gemspec.
1715
# Bundler will treat runtime dependencies like base dependencies, and
@@ -25,6 +23,8 @@ gemspec
2523

2624
gem 'rails', '6.1.2'
2725

26+
gem 'matestack-ui-core', git: "https://github.com/matestack/matestack-ui-core", branch: "matestack-ui-core-2.0"
27+
2828
gem 'rspec-rails', '~> 4.0.2'
2929
gem 'capybara'
3030
gem 'webpacker', '~> 5.0'

Gemfile.lock

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
GIT
2+
remote: https://github.com/matestack/matestack-ui-core
3+
revision: 0bbd207c34dea89cc0056e4de563141ceb8aa284
4+
branch: matestack-ui-core-2.0
5+
specs:
6+
matestack-ui-core (2.0.0)
7+
rails (>= 5.2)
8+
19
PATH
210
remote: .
311
specs:
4-
matestack-ui-bootstrap (1.4.0)
5-
matestack-ui-core (~> 1.4.0)
12+
matestack-ui-bootstrap (1.5.1)
613

714
GEM
815
remote: https://rubygems.org/
@@ -81,26 +88,12 @@ GEM
8188
rack-test (>= 0.6.3)
8289
regexp_parser (>= 1.5, < 3.0)
8390
xpath (~> 3.2)
84-
cells (4.1.7)
85-
declarative-builder (< 0.2.0)
86-
declarative-option (< 0.2.0)
87-
tilt (>= 1.4, < 3)
88-
uber (< 0.2.0)
89-
cells-haml (0.0.10)
90-
cells (>= 4.0.1, <= 6.0.0)
91-
haml (>= 4.1.0.beta.1)
92-
cells-rails (0.1.3)
93-
actionpack (>= 5.0)
94-
cells (>= 4.1.6, < 5.0.0)
9591
childprocess (3.0.0)
9692
coderay (1.1.3)
9793
concurrent-ruby (1.1.8)
9894
crack (0.4.5)
9995
rexml
10096
crass (1.0.6)
101-
declarative-builder (0.1.0)
102-
declarative-option (< 0.2.0)
103-
declarative-option (0.1.0)
10497
devise (4.7.3)
10598
bcrypt (~> 3.0)
10699
orm_adapter (~> 0.1)
@@ -117,9 +110,6 @@ GEM
117110
railties (>= 3.0.0)
118111
globalid (0.4.2)
119112
activesupport (>= 4.2.0)
120-
haml (5.2.1)
121-
temple (>= 0.8.0)
122-
tilt
123113
hashdiff (1.0.1)
124114
i18n (1.8.9)
125115
concurrent-ruby (~> 1.0)
@@ -130,12 +120,6 @@ GEM
130120
mini_mime (>= 0.1.1)
131121
marcel (0.3.3)
132122
mimemagic (~> 0.3.2)
133-
matestack-ui-core (1.4.0)
134-
cells-haml (>= 0.0.10)
135-
cells-rails (>= 0.1.0)
136-
haml (>= 4.1.0.beta.1)
137-
rails (>= 5.2)
138-
trailblazer-cells (>= 0.0.3)
139123
method_source (1.0.0)
140124
mimemagic (0.3.5)
141125
mini_mime (1.0.2)
@@ -248,14 +232,9 @@ GEM
248232
actionpack (>= 4.0)
249233
activesupport (>= 4.0)
250234
sprockets (>= 3.0.0)
251-
temple (0.8.2)
252235
thor (1.1.0)
253-
tilt (2.0.10)
254-
trailblazer-cells (0.0.3)
255-
cells (>= 4.1.0.rc1, < 5.0.0)
256236
tzinfo (2.0.4)
257237
concurrent-ruby (~> 1.0)
258-
uber (0.1.0)
259238
warden (1.2.9)
260239
rack (>= 2.0.9)
261240
webmock (3.11.2)
@@ -281,12 +260,11 @@ DEPENDENCIES
281260
bootsnap
282261
byebug
283262
capybara
284-
cells-haml
285-
cells-rails
286263
devise
287264
faker
288265
generator_spec
289266
matestack-ui-bootstrap!
267+
matestack-ui-core!
290268
paper_trail
291269
pg (>= 0.18, < 2.0)
292270
pry-byebug
@@ -301,7 +279,6 @@ DEPENDENCIES
301279
rspec-wait
302280
selenium-webdriver
303281
simplecov
304-
trailblazer-cells
305282
webmock
306283
webpacker (~> 5.0)
307284

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ class Matestack::Ui::Bootstrap::Components::Accordion < Matestack::Ui::Component
44
optional :items # array with 2 Hashes: header and body
55
optional :open
66
optional :variant
7-
optional attributes: { as: :bs_attrs }, class: { as: :bs_class }, id: { as: :bs_id }
7+
optional :attributes, :class, :id
88

9-
def setup
10-
@accordion_id = (bs_id.present? ? bs_id : "matestack-accordion-#{SecureRandom.hex(3)}")
9+
def prepare
10+
@accordion_id = (context.id.present? ? context.id : "matestack-accordion-#{SecureRandom.hex(3)}")
1111
end
1212

1313
def response
1414
div accordion_attributes do
15-
accordion_content_partial if items.present?
16-
yield_components
15+
accordion_content_partial if context.items.present?
16+
yield
1717
end
1818
end
1919

2020
protected
2121

2222
def accordion_content_partial
23-
items.each_with_index do | item, index |
23+
context.items.each_with_index do | item, index |
2424
div class: "accordion-item" do
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}") }" },
2828
attributes: { "aria-expanded": "false", "aria-controls": "collapse-#{(item[:header][:id] || "header-#{index}")}", type: "button" }
2929
end
30-
bs_collapse class: "accordion-collapse #{ 'show' if open || item[:open] }", id: "collapse-#{(item[:header][:id] || "header-#{index}")}", labelledby: (item[:header][:id] || "header-#{index}"),
30+
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
3232
div class: "accordion-body #{item[:body][:class]}" do
3333
plain item[:body][:text]
@@ -38,19 +38,18 @@ def accordion_content_partial
3838
end
3939

4040
def accordion_attributes
41-
html_attributes.merge(
41+
options.merge(
4242
id: @accordion_id,
43-
class: accordion_classes,
44-
attributes: bs_attrs
45-
)
43+
class: accordion_classes
44+
).merge(context.attributes)
4645
end
4746

4847
def accordion_classes
4948
[].tap do |classes|
5049
classes << 'accordion'
51-
classes << 'open' if open
52-
classes << 'accordion-flush' if variant == :flush
53-
classes << bs_class
50+
classes << 'open' if context.open
51+
classes << 'accordion-flush' if context.variant == :flush
52+
classes << context.class
5453
end.join(' ').strip
5554
end
5655
end

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import * as bootstrap from 'bootstrap'
2+
import Vue from 'vue/dist/vue.esm'
23

3-
MatestackUiCore.Vue.component('matestack-ui-bootstrap-alert', {
4+
import MatestackUiCore from 'matestack-ui-core'
5+
6+
Vue.component('matestack-ui-bootstrap-alert', {
47
mixins: [MatestackUiCore.componentMixin],
58

69
data() {
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
class Matestack::Ui::Bootstrap::Components::Alert < Matestack::Ui::VueJsComponent
2-
vue_js_component_name "matestack-ui-bootstrap-alert"
2+
vue_name "matestack-ui-bootstrap-alert"
33

4-
optional :title, :text, :variant, :dismissible, :animate, :title_size, class: { as: :bs_class }
4+
optional :title, :text, :variant, :dismissible, :animate, :title_size, :class
55
optional :close_on, :dispose_on # event names on which occourences we close or dispose the modal
66

77
def response
88
div alert_attributes do
9-
heading size: (title_size || 4), class: 'alert-heading', text: title if title
10-
plain text if text
11-
yield_components
12-
bs_close dismiss: "alert" if dismissible
9+
heading context.title, size: (title_size || 4), class: 'alert-heading' if context.title
10+
plain context.text if context.text
11+
yield
12+
bs_close dismiss: "alert" if context.dismissible
1313
end
1414
end
1515

1616
protected
1717

1818
def alert_classes
1919
classes = ['alert']
20-
classes << "alert-#{variant || "primary"}"
21-
classes << "alert-dismissible" if dismissible
22-
classes << "fade show" if animate
23-
classes << bs_class
20+
classes << "alert-#{context.variant || "primary"}"
21+
classes << "alert-dismissible" if context.dismissible
22+
classes << "fade show" if context.animate
23+
classes << context.class
2424
classes.join(' ')
2525
end
2626

2727
def alert_attributes
28-
html_attributes.merge(
29-
class: alert_classes,
30-
attributes: { role: :alert }
31-
)
28+
{}.tap do |attrs|
29+
attrs.class = alert_classes,
30+
attrs.role = :alert
31+
end
3232
end
3333

3434
end

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
class Matestack::Ui::Bootstrap::Components::Avatar < Matestack::Ui::Component
22

3-
optional :text, :bg_variant, :text_variant, :img_path, :size, class: { as: :bs_class }
3+
optional :text, :bg_variant, :text_variant, :img_path, :size, :class
44

55
def response
6-
if text.present? && img_path.nil?
7-
div class: "rounded-circle bg-#{bg_variant || 'primary'} text-#{text_variant || 'white'} text-center p-2 #{bs_class}",
8-
attributes: { style: "height: #{height}px; width: #{width}px; display: inline-block;"} do
9-
plain text
6+
if context.text.present? && context.img_path.nil?
7+
div class: "rounded-circle bg-#{context.bg_variant || 'primary'} text-#{context.text_variant || 'white'} text-center p-2 #{context.class}",
8+
style: "height: #{height}px; width: #{width}px; display: inline-block;" do
9+
plain context.text
1010
end
1111
else
12-
div class: "rounded-circle text-#{text_variant || 'white'} text-center p-2 #{bs_class}",
13-
attributes: { style: "height: #{height}px; width: #{width}px; display: inline-block; background-image: url(#{img_path}); background-size: contain;"} do
14-
plain text
12+
div class: "rounded-circle text-#{context.text_variant || 'white'} text-center p-2 #{context.class}",
13+
style: "height: #{height}px; width: #{width}px; display: inline-block; background-image: url(#{context.img_path}); background-size: contain;" do
14+
plain context.text
1515
end
1616
end
1717
end
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
class Matestack::Ui::Bootstrap::Components::Badge < Matestack::Ui::Component
22

3-
optional class: { as: :bs_class }
3+
optional :class
44
optional :text, :variant, :rounded, :visually_hidden
55

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

1414
protected
1515

1616
def badge_attributes
17-
html_attributes.merge(
17+
options.merge(
1818
class: badge_classes
1919
)
2020
end
2121

2222
def badge_classes
2323
[].tap do |classes|
2424
classes << 'badge'
25-
classes << (variant.present? ? "bg-#{variant}" : "bg-secondary")
26-
classes << "rounded-pill" if rounded
27-
classes << bs_class
25+
classes << (context.variant.present? ? "bg-#{context.variant}" : "bg-secondary")
26+
classes << "rounded-pill" if context.rounded
27+
classes << context.class
2828
end.join(' ').strip
2929
end
3030
end
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
class Matestack::Ui::Bootstrap::Components::Breadcrumb < Matestack::Ui::Component
22

33
optional :items # list of items with path and text
4-
optional class: { as: :bs_class} # adding custom class to breadcrumb list
4+
optional :class # adding custom class to breadcrumb list
55
optional :nav_class
66

77
def response
8-
nav class: nav_class, attributes: { 'aria-label': "breadcrumb" } do
8+
nav class: context.nav_class, "aria-label": "breadcrumb" do
99
ol breadcrumb_attributes do
10-
items&.each_with_index do |item, index|
11-
li link_attrs((items.size - 1) == index) do
10+
context.items&.each_with_index do |item, index|
11+
li link_attrs((context.items.size - 1) == index) do
1212
case item[:type]
1313
when :link
1414
link item
@@ -19,7 +19,7 @@ def response
1919
end
2020
end
2121
end
22-
yield_components
22+
yield
2323
end
2424
end
2525
end
@@ -29,20 +29,20 @@ def response
2929
def link_attrs(last = false)
3030
{}.tap do |hash|
3131
hash[:class] = "breadcrumb-item #{'active' if last}"
32-
hash[:attributes] = { 'aria-current': "page" } if last
32+
hash["aria-current"] = "page" if last
3333
end
3434
end
3535

3636
def breadcrumb_attributes
37-
html_attributes.merge(
37+
options.merge(
3838
class: breadcrumb_classes
3939
)
4040
end
4141

4242
def breadcrumb_classes
4343
[].tap do |classes|
4444
classes << "breadcrumb"
45-
classes << bs_class
45+
classes << context.class
4646
end.join(' ').strip
4747
end
4848
end

0 commit comments

Comments
 (0)