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.
- checksums.yaml +4 -4
- data/LICENSE +17 -5
- data/README.md +53 -19
- data/lib/matestack/ui/bootstrap.rb +97 -17
- data/{app/concepts → lib}/matestack/ui/bootstrap/apps/admin_template.rb +14 -7
- data/lib/matestack/ui/bootstrap/base_component.rb +13 -0
- data/lib/matestack/ui/bootstrap/base_vue_js_component.rb +13 -0
- data/lib/matestack/ui/bootstrap/components/accordion.rb +58 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/alert.js +12 -9
- data/lib/matestack/ui/bootstrap/components/alert.rb +43 -0
- data/lib/matestack/ui/bootstrap/components/avatar.rb +27 -0
- data/lib/matestack/ui/bootstrap/components/badge.rb +32 -0
- data/lib/matestack/ui/bootstrap/components/breadcrumb.rb +50 -0
- data/lib/matestack/ui/bootstrap/components/button.rb +71 -0
- data/lib/matestack/ui/bootstrap/components/button_group.rb +36 -0
- data/lib/matestack/ui/bootstrap/components/card.rb +105 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/carousel.js +21 -18
- data/lib/matestack/ui/bootstrap/components/carousel.rb +103 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/close.rb +10 -9
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/collapse.js +20 -17
- data/lib/matestack/ui/bootstrap/components/collapse.rb +54 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.js +5 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.rb +31 -26
- data/lib/matestack/ui/bootstrap/components/icon.rb +21 -0
- data/lib/matestack/ui/bootstrap/components/list_group.rb +148 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/modal.js +24 -21
- data/lib/matestack/ui/bootstrap/components/modal.rb +121 -0
- data/lib/matestack/ui/bootstrap/components/navbar.rb +163 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/page_heading.rb +7 -5
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/pagination.rb +15 -13
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.js +4 -1
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.rb +26 -22
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/progress.rb +24 -24
- data/lib/matestack/ui/bootstrap/components/scrollspy.rb +50 -0
- data/lib/matestack/ui/bootstrap/components/section_card.rb +33 -0
- data/lib/matestack/ui/bootstrap/components/spinner.rb +35 -0
- data/lib/matestack/ui/bootstrap/components/tab_nav.rb +79 -0
- data/lib/matestack/ui/bootstrap/components/tab_nav_content.rb +35 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/toast.js +27 -18
- data/lib/matestack/ui/bootstrap/components/toast.rb +113 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.js +4 -1
- data/lib/matestack/ui/bootstrap/components/tooltip.rb +66 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/figure.rb +4 -2
- data/lib/matestack/ui/bootstrap/content/smart_collection/collection.rb +120 -0
- data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/collection.scss +0 -0
- data/lib/matestack/ui/bootstrap/content/smart_collection/content.rb +118 -0
- data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/filter.rb +7 -3
- data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/paginate.rb +19 -14
- data/lib/matestack/ui/bootstrap/form/checkbox.rb +90 -0
- data/lib/matestack/ui/bootstrap/form/input.rb +118 -0
- data/lib/matestack/ui/bootstrap/form/radio.rb +57 -0
- data/lib/matestack/ui/bootstrap/form/select.rb +63 -0
- data/lib/matestack/ui/bootstrap/form/submit.rb +20 -0
- data/lib/matestack/ui/bootstrap/form/switch.rb +32 -0
- data/lib/matestack/ui/bootstrap/form/textarea.rb +49 -0
- data/lib/matestack/ui/bootstrap/index.js +24 -0
- data/lib/matestack/ui/bootstrap/layout/column.rb +49 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/container.rb +12 -9
- data/lib/matestack/ui/bootstrap/layout/row.rb +25 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.js +5 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.rb +10 -10
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.scss +0 -0
- data/lib/matestack/ui/bootstrap/registry.rb +173 -0
- data/{app/javascript/matestack-ui-bootstrap → lib/matestack/ui/bootstrap}/stylesheets/matestack-ui-bootstrap.scss +0 -0
- data/lib/matestack/ui/bootstrap/version.rb +1 -1
- data/lib/tasks/matestack/ui/bootstrap_tasks.rake +25 -25
- metadata +68 -76
- data/app/assets/images/avatar-placeholder.png +0 -0
- data/app/assets/images/icons/bootstrap-icons.svg +0 -1
- data/app/concepts/matestack/ui/bootstrap/components/accordion.rb +0 -53
- data/app/concepts/matestack/ui/bootstrap/components/alert.rb +0 -34
- data/app/concepts/matestack/ui/bootstrap/components/avatar.rb +0 -27
- data/app/concepts/matestack/ui/bootstrap/components/badge.rb +0 -30
- data/app/concepts/matestack/ui/bootstrap/components/breadcrumb.rb +0 -46
- data/app/concepts/matestack/ui/bootstrap/components/button.rb +0 -54
- data/app/concepts/matestack/ui/bootstrap/components/button_group.rb +0 -36
- data/app/concepts/matestack/ui/bootstrap/components/card.rb +0 -100
- data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +0 -85
- data/app/concepts/matestack/ui/bootstrap/components/chart.js +0 -232
- data/app/concepts/matestack/ui/bootstrap/components/chart.rb +0 -71
- data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +0 -43
- data/app/concepts/matestack/ui/bootstrap/components/icon.rb +0 -19
- data/app/concepts/matestack/ui/bootstrap/components/list_group.rb +0 -83
- data/app/concepts/matestack/ui/bootstrap/components/modal.rb +0 -106
- data/app/concepts/matestack/ui/bootstrap/components/navbar.rb +0 -120
- data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +0 -33
- data/app/concepts/matestack/ui/bootstrap/components/section_card.rb +0 -31
- data/app/concepts/matestack/ui/bootstrap/components/spinner.rb +0 -31
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav.rb +0 -81
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav_content.rb +0 -32
- data/app/concepts/matestack/ui/bootstrap/components/toast.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/components/tooltip.rb +0 -82
- data/app/concepts/matestack/ui/bootstrap/content/collection/collection.rb +0 -112
- data/app/concepts/matestack/ui/bootstrap/content/collection/content.rb +0 -101
- data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +0 -90
- data/app/concepts/matestack/ui/bootstrap/form/date.js +0 -38
- data/app/concepts/matestack/ui/bootstrap/form/date.rb +0 -98
- data/app/concepts/matestack/ui/bootstrap/form/input.rb +0 -123
- data/app/concepts/matestack/ui/bootstrap/form/radio.rb +0 -65
- data/app/concepts/matestack/ui/bootstrap/form/select.haml +0 -11
- data/app/concepts/matestack/ui/bootstrap/form/select.rb +0 -74
- data/app/concepts/matestack/ui/bootstrap/form/submit.rb +0 -20
- data/app/concepts/matestack/ui/bootstrap/form/switch.rb +0 -90
- data/app/concepts/matestack/ui/bootstrap/layout/column.rb +0 -47
- data/app/concepts/matestack/ui/bootstrap/layout/row.rb +0 -15
- data/app/concepts/matestack/ui/bootstrap/pages/devise/sign_in.rb +0 -40
- data/app/concepts/matestack/ui/bootstrap/registry.rb +0 -63
- data/app/helpers/matestack/ui/bootstrap/application_helper.rb +0 -13
- data/app/javascript/matestack-ui-bootstrap/index.js +0 -26
- data/app/javascript/packs/matestack-ui-bootstrap.js +0 -2
- data/config/routes.rb +0 -2
- data/lib/matestack/ui/bootstrap/engine.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 765f0c5d8c9c1ff744e18f2f9cf03e988b45527941b13d420b777e304bd04149
|
4
|
+
data.tar.gz: 2b24f828ef784ce5c7f137a7354f3f6eeb6ee46679e38e8e6e1670089bd9d092
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4576738c13b40735fe220ad577416834b0adc0ec129426cb438843dc7513957d193de42948050e64d1309da6545cb1dbc38d24969d339c7e7b1f10e1ad81e615
|
7
|
+
data.tar.gz: 496c5eefd617f97462c4987a172a4510743f5c896d828f5bf5f7186e2cf8fd46977d049375ffd93be9c588ed1a34e51eb503dee8303632274f05aa66e5ae737c
|
data/LICENSE
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
Copyright (c) Matestack GmbH
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
6
10
|
|
7
|
-
|
8
|
-
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,26 +1,60 @@
|
|
1
|
-
|
1
|
+
[![Specs](https://github.com/matestack/matestack-ui-bootstrap/workflows/specs/badge.svg)](https://github.com/matestack/matestack-ui-bootstrap/actions)
|
2
|
+
[![Discord](https://img.shields.io/discord/771413294136426496.svg)](https://discord.com/invite/c6tQxFG)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/matestack-ui-bootstrap.svg)](https://badge.fury.io/rb/matestack-ui-bootstrap)
|
4
|
+
[![Docs](https://img.shields.io/badge/docs-matestack-blue.svg)](https://docs.matestack.io/matestack-ui-bootstrap)
|
5
|
+
[![Twitter Follow](https://img.shields.io/twitter/follow/matestack.svg?style=social)](https://twitter.com/matestack)
|
2
6
|
|
7
|
+
![matestack logo](./logo.png)
|
3
8
|
|
4
|
-
|
9
|
+
# matestack-ui-bootstrap | beautiful, reactive UIs in pure Ruby
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
yarn install
|
9
|
-
rake db:setup
|
10
|
-
rails s
|
11
|
-
./bin/webpack --watch
|
12
|
-
```
|
11
|
+
As an extension for [`matestack-ui-core`](https://github.com/matestack/matestack-ui-core), `matestack-ui-bootstrap` ships all you need to build beautiful,
|
12
|
+
reactive UIs in pure Ruby and smart CRUD components based on Bootstrap v5.
|
13
13
|
|
14
|
-
|
15
|
-
rails s
|
16
|
-
```
|
14
|
+
----
|
17
15
|
|
18
|
-
|
19
|
-
./bin/webpack --watch
|
20
|
-
```
|
16
|
+
`matestack-ui-core` enables you to craft maintainable web UIs in pure Ruby, skipping ERB and HTML. UI code becomes a native and fun part of your Rails app. Thanks to reactive core components, reactivity can be optionally added on top without writing JavaScript, just using a simple Ruby DSL.
|
21
17
|
|
22
|
-
|
18
|
+
You end up writing 50% less code while increasing productivity, maintainability and developer happiness. Work with pure Ruby. If necessary, extend with pure JavaScript. No Opal involved.
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
----
|
21
|
+
|
22
|
+
`matestack-ui-core` does not have an opinion on styling. In contrast, `matestack-ui-bootstrap` ships all Bootstrap v5 components as Matestack UI components usable in pure Ruby. Additionally layout and CRUD components help you to build a beautiful web app meeting typical requirements of a data driven web app.
|
23
|
+
|
24
|
+
Don't think about styling anymore and just create admin or application UIs faster than ever before!
|
25
|
+
|
26
|
+
[<img src="https://img.youtube.com/vi/bwsVgCb97v0/0.jpg" width="350">](https://www.youtube.com/watch?v=bwsVgCb97v0)
|
27
|
+
|
28
|
+
## Compatibility
|
29
|
+
|
30
|
+
### Ruby/Rails
|
31
|
+
|
32
|
+
`matestack-ui-bootstrap` is tested against:
|
33
|
+
|
34
|
+
- Rails 6.1.1 + Ruby 3.0.0
|
35
|
+
- Rails 6.1.1 + Ruby 2.7.2
|
36
|
+
- Rails 6.0.3.4 + Ruby 2.6.6
|
37
|
+
- Rails 5.2.4.4 + Ruby 2.6.6
|
38
|
+
|
39
|
+
Rails versions below 5.2 are not supported.
|
40
|
+
|
41
|
+
### Vue.js
|
42
|
+
|
43
|
+
`matestack-ui-bootstrap` requires Vue.js and Vuex for its reactivity features. Following version ranges are supported:
|
44
|
+
|
45
|
+
- Vue.js ^2.6.0
|
46
|
+
- Vuex ^3.6.0
|
47
|
+
|
48
|
+
Vue 3 / Vuex 4 update is planned for Q2 2021.
|
49
|
+
|
50
|
+
## Documentation/Installation
|
51
|
+
|
52
|
+
Documentation can be found [here](https://docs.matestack.io/matestack-ui-bootstrap)
|
53
|
+
|
54
|
+
## Changelog
|
55
|
+
|
56
|
+
Changelog can be found [here](./CHANGELOG.md)
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
`matestack-ui-bootstrap` is an Open Source project licensed under the terms of the [MIT license](./LICENSE)
|
@@ -1,27 +1,107 @@
|
|
1
|
-
# require 'trailblazer'
|
2
|
-
# require 'trailblazer/rails'
|
3
|
-
# require 'trailblazer/cell'
|
4
|
-
# require 'cell/rails'
|
5
|
-
# require 'cell/haml'
|
6
|
-
|
7
1
|
require "matestack/ui/core"
|
8
|
-
|
2
|
+
|
3
|
+
base_path = 'matestack/ui/bootstrap'
|
4
|
+
require "#{base_path}/version"
|
5
|
+
|
6
|
+
module Matestack
|
7
|
+
module Ui
|
8
|
+
module Bootstrap
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require "#{base_path}/base_component"
|
14
|
+
require "#{base_path}/base_vue_js_component"
|
15
|
+
|
16
|
+
module Matestack
|
17
|
+
module Ui
|
18
|
+
module Bootstrap
|
19
|
+
module Apps
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
require "#{base_path}/apps/admin_template"
|
9
25
|
|
10
26
|
module Matestack
|
11
27
|
module Ui
|
12
28
|
module Bootstrap
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
module Layout
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
require "#{base_path}/layout/row"
|
35
|
+
require "#{base_path}/layout/column"
|
36
|
+
require "#{base_path}/layout/container"
|
37
|
+
require "#{base_path}/layout/sidebar"
|
38
|
+
|
39
|
+
module Matestack
|
40
|
+
module Ui
|
41
|
+
module Bootstrap
|
42
|
+
module Components
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
require "#{base_path}/components/collapse"
|
48
|
+
require "#{base_path}/components/navbar"
|
49
|
+
require "#{base_path}/components/page_heading"
|
50
|
+
require "#{base_path}/components/section_card"
|
51
|
+
require "#{base_path}/components/carousel"
|
52
|
+
require "#{base_path}/components/tooltip"
|
53
|
+
require "#{base_path}/components/alert"
|
54
|
+
require "#{base_path}/components/breadcrumb"
|
55
|
+
require "#{base_path}/components/tab_nav"
|
56
|
+
require "#{base_path}/components/progress"
|
57
|
+
require "#{base_path}/components/toast"
|
58
|
+
require "#{base_path}/components/accordion"
|
59
|
+
require "#{base_path}/components/avatar"
|
60
|
+
require "#{base_path}/components/close"
|
61
|
+
require "#{base_path}/components/card"
|
62
|
+
require "#{base_path}/components/dropdown"
|
63
|
+
require "#{base_path}/components/modal"
|
64
|
+
require "#{base_path}/components/list_group"
|
65
|
+
require "#{base_path}/components/scrollspy"
|
66
|
+
require "#{base_path}/components/button"
|
67
|
+
require "#{base_path}/components/spinner"
|
68
|
+
require "#{base_path}/components/pagination"
|
69
|
+
require "#{base_path}/components/tab_nav_content"
|
70
|
+
require "#{base_path}/components/popover"
|
71
|
+
require "#{base_path}/components/badge"
|
72
|
+
require "#{base_path}/components/button_group"
|
73
|
+
require "#{base_path}/components/icon"
|
74
|
+
|
75
|
+
module Matestack
|
76
|
+
module Ui
|
77
|
+
module Bootstrap
|
78
|
+
module Content
|
79
|
+
module SmartCollection
|
23
80
|
end
|
24
81
|
end
|
25
82
|
end
|
26
83
|
end
|
27
84
|
end
|
85
|
+
require "#{base_path}/content/figure"
|
86
|
+
require "#{base_path}/content/smart_collection/collection"
|
87
|
+
require "#{base_path}/content/smart_collection/content"
|
88
|
+
require "#{base_path}/content/smart_collection/filter"
|
89
|
+
require "#{base_path}/content/smart_collection/paginate"
|
90
|
+
|
91
|
+
module Matestack
|
92
|
+
module Ui
|
93
|
+
module Bootstrap
|
94
|
+
module Form
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
require "#{base_path}/form/checkbox"
|
100
|
+
require "#{base_path}/form/input"
|
101
|
+
require "#{base_path}/form/textarea"
|
102
|
+
require "#{base_path}/form/radio"
|
103
|
+
require "#{base_path}/form/select"
|
104
|
+
require "#{base_path}/form/submit"
|
105
|
+
require "#{base_path}/form/switch"
|
106
|
+
|
107
|
+
require "#{base_path}/registry"
|
@@ -1,9 +1,19 @@
|
|
1
|
+
require_relative "../registry"
|
2
|
+
|
1
3
|
class Matestack::Ui::Bootstrap::Apps::AdminTemplate < Matestack::Ui::App
|
2
4
|
|
3
|
-
|
5
|
+
include Matestack::Ui::Bootstrap::Registry
|
6
|
+
|
7
|
+
def response(&block)
|
8
|
+
matestack do
|
9
|
+
body_response(&block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def body_response(&block)
|
4
14
|
div class: "d-flex flex-row" do
|
5
15
|
if should_show_sidebar?
|
6
|
-
bs_sidebar sidebar_navigation_items: sidebar_navigation_items, slots: { sidebar_top: sidebar_top_slot }
|
16
|
+
bs_sidebar sidebar_navigation_items: sidebar_navigation_items, slots: { sidebar_top: method(:sidebar_top_slot) }
|
7
17
|
end
|
8
18
|
div id: "content", class: "content-wrapper w-100 #{content_background_class}" do
|
9
19
|
if should_show_navbar?
|
@@ -16,7 +26,7 @@ class Matestack::Ui::Bootstrap::Apps::AdminTemplate < Matestack::Ui::App
|
|
16
26
|
end
|
17
27
|
end
|
18
28
|
bs_container class: "my-5 px-4 pt-5" do
|
19
|
-
|
29
|
+
yield if block_given?
|
20
30
|
end
|
21
31
|
end
|
22
32
|
end
|
@@ -40,9 +50,7 @@ class Matestack::Ui::Bootstrap::Apps::AdminTemplate < Matestack::Ui::App
|
|
40
50
|
end
|
41
51
|
|
42
52
|
def sidebar_top_slot
|
43
|
-
|
44
|
-
sidebar_top_partial if self.respond_to?(:sidebar_top_partial)
|
45
|
-
end
|
53
|
+
sidebar_top_partial if self.respond_to?(:sidebar_top_partial)
|
46
54
|
end
|
47
55
|
|
48
56
|
def toasts_partial
|
@@ -81,5 +89,4 @@ class Matestack::Ui::Bootstrap::Apps::AdminTemplate < Matestack::Ui::App
|
|
81
89
|
"bg-light"
|
82
90
|
end
|
83
91
|
|
84
|
-
|
85
92
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Accordion < Matestack::Ui::Bootstrap::BaseComponent
|
4
|
+
|
5
|
+
# [ {header: { class, id, text, size, btn_variant, btn_class }, body: { class, text, multi } } ]
|
6
|
+
optional :items # array with 2 Hashes: header and body
|
7
|
+
optional :open
|
8
|
+
optional :variant
|
9
|
+
optional :attributes, class: { as: :bs_class }
|
10
|
+
optional :id
|
11
|
+
|
12
|
+
def prepare
|
13
|
+
@accordion_id = (context.id.present? ? context.id : "matestack-accordion-#{SecureRandom.hex(3)}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def response
|
17
|
+
div accordion_attributes do
|
18
|
+
accordion_content_partial if context.items.present?
|
19
|
+
yield if block_given?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def accordion_content_partial
|
26
|
+
context.items.each_with_index do | item, index |
|
27
|
+
div class: "accordion-item" do
|
28
|
+
heading class: "accordion-header #{item[:header][:class]}", id: (item[:header][:id] || "header-#{index}"), size: (item[:header][:size] || 2) do
|
29
|
+
button class: "accordion-button", text:item[:header][:text],
|
30
|
+
data: { "bs-toggle": "collapse", "bs-target": "#collapse-#{(item[:header][:id] || "header-#{index}") }" },
|
31
|
+
"aria-expanded": "false", "aria-controls": "collapse-#{(item[:header][:id] || "header-#{index}")}", type: "button"
|
32
|
+
end
|
33
|
+
bs_collapse class: "accordion-collapse #{ 'show' if context.open || item[:open] }", id: "collapse-#{(item[:header][:id] || "header-#{index}")}", labelledby: (item[:header][:id] || "header-#{index}"),
|
34
|
+
parent: @accordion_id, multi: (item[:body][:multi] || false) do
|
35
|
+
div class: "accordion-body #{item[:body][:class]}" do
|
36
|
+
plain item[:body][:text]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def accordion_attributes
|
44
|
+
options.merge(
|
45
|
+
id: @accordion_id,
|
46
|
+
class: accordion_classes
|
47
|
+
).merge(context.attributes || {})
|
48
|
+
end
|
49
|
+
|
50
|
+
def accordion_classes
|
51
|
+
[].tap do |classes|
|
52
|
+
classes << 'accordion'
|
53
|
+
classes << 'open' if context.open
|
54
|
+
classes << 'accordion-flush' if context.variant == :flush
|
55
|
+
classes << context.bs_class
|
56
|
+
end.join(' ').strip
|
57
|
+
end
|
58
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import * as bootstrap from 'bootstrap'
|
2
|
+
import Vue from 'vue/dist/vue.esm'
|
2
3
|
|
3
|
-
MatestackUiCore
|
4
|
+
import MatestackUiCore from 'matestack-ui-core'
|
5
|
+
|
6
|
+
Vue.component('matestack-ui-bootstrap-alert', {
|
4
7
|
mixins: [MatestackUiCore.componentMixin],
|
5
8
|
|
6
9
|
data() {
|
@@ -28,25 +31,25 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-alert', {
|
|
28
31
|
created: function() {
|
29
32
|
const self = this
|
30
33
|
// close_on event registration
|
31
|
-
if(self.
|
32
|
-
var close_events = self.
|
34
|
+
if(self.props["close_on"] != undefined){
|
35
|
+
var close_events = self.props["close_on"].split(",")
|
33
36
|
close_events.forEach(close_event => MatestackUiCore.matestackEventHub.$on(close_event.trim(), self.close));
|
34
37
|
}
|
35
38
|
// dispose_on event registration
|
36
|
-
if(self.
|
37
|
-
var dispose_events = self.
|
39
|
+
if(self.props["dispose_on"] != undefined){
|
40
|
+
var dispose_events = self.props["dispose_on"].split(",")
|
38
41
|
dispose_events.forEach(dispose_event => MatestackUiCore.matestackEventHub.$on(dispose_event.trim(), self.dispose));
|
39
42
|
}
|
40
43
|
},
|
41
44
|
|
42
45
|
beforeDestroy: function() {
|
43
46
|
const self = this
|
44
|
-
if(self.
|
45
|
-
var closen_events = self.
|
47
|
+
if(self.props["close_on"] != undefined){
|
48
|
+
var closen_events = self.props["close_on"].split(",")
|
46
49
|
closen_events.forEach(close_event => MatestackUiCore.matestackEventHub.$off(close_event.trim(), self.close));
|
47
50
|
}
|
48
|
-
if(self.
|
49
|
-
var dispose_events = self.
|
51
|
+
if(self.props["dispose_on"] != undefined){
|
52
|
+
var dispose_events = self.props["dispose_on"].split(",")
|
50
53
|
dispose_events.forEach(dispose_event => MatestackUiCore.matestackEventHub.$off(dispose_event.trim(), self.dispose));
|
51
54
|
}
|
52
55
|
},
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative "../base_vue_js_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Alert < Matestack::Ui::Bootstrap::BaseVueJsComponent
|
4
|
+
vue_name "matestack-ui-bootstrap-alert"
|
5
|
+
|
6
|
+
optional :title, :variant, :dismissible, :animate, :title_size, class: { as: :bs_class }
|
7
|
+
optional :close_on, :dispose_on # event names on which occourences we close or dispose the modal
|
8
|
+
|
9
|
+
def response
|
10
|
+
div alert_attributes do
|
11
|
+
heading context.title, size: (context.title_size || 4), class: 'alert-heading' if context.title
|
12
|
+
plain context.text if context.text
|
13
|
+
yield if block_given?
|
14
|
+
bs_close dismiss: "alert" if context.dismissible
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def vue_props
|
21
|
+
{}.tap do |props|
|
22
|
+
props[:close_on] = context.close_on
|
23
|
+
props[:dispose_on] = context.dispose_on
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def alert_classes
|
28
|
+
classes = ['alert']
|
29
|
+
classes << "alert-#{context.variant || "primary"}"
|
30
|
+
classes << "alert-dismissible" if context.dismissible
|
31
|
+
classes << "fade show" if context.animate
|
32
|
+
classes << context.bs_class
|
33
|
+
classes.join(' ')
|
34
|
+
end
|
35
|
+
|
36
|
+
def alert_attributes
|
37
|
+
{}.tap do |attrs|
|
38
|
+
attrs[:class] = alert_classes,
|
39
|
+
attrs[:role] = :alert
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|