matestack-ui-bootstrap 1.5.1 → 3.0.0.rc1
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 +36 -60
- data/lib/matestack/ui/bootstrap/base_component.rb +11 -0
- data/lib/matestack/ui/bootstrap/base_vue_js_component.rb +11 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/accordion.rb +18 -16
- data/lib/matestack/ui/bootstrap/components/alert.js +58 -0
- 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/{app/concepts → lib}/matestack/ui/bootstrap/components/breadcrumb.rb +12 -10
- 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/lib/matestack/ui/bootstrap/components/carousel.js +84 -0
- data/lib/matestack/ui/bootstrap/components/carousel.rb +103 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/close.rb +10 -9
- data/lib/matestack/ui/bootstrap/components/collapse.js +89 -0
- data/lib/matestack/ui/bootstrap/components/collapse.rb +54 -0
- data/lib/matestack/ui/bootstrap/components/dropdown.js +19 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.rb +29 -25
- data/lib/matestack/ui/bootstrap/components/icon.rb +21 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/list_group.rb +32 -29
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/modal.js +32 -28
- data/lib/matestack/ui/bootstrap/components/modal.rb +121 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/navbar.rb +39 -30
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/page_heading.rb +7 -5
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/pagination.rb +11 -9
- data/lib/matestack/ui/bootstrap/components/popover.js +30 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.rb +25 -21
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/progress.rb +19 -19
- 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/lib/matestack/ui/bootstrap/components/toast.js +89 -0
- data/lib/matestack/ui/bootstrap/components/toast.rb +113 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.js +9 -6
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.rb +20 -18
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/figure.rb +4 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/collection.rb +22 -16
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/collection.scss +0 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/content.rb +38 -21
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/filter.rb +6 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/paginate.rb +16 -11
- data/lib/matestack/ui/bootstrap/form/checkbox.rb +88 -0
- data/lib/matestack/ui/bootstrap/form/input.rb +116 -0
- data/lib/matestack/ui/bootstrap/form/radio.rb +55 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/form/select.rb +18 -10
- data/lib/matestack/ui/bootstrap/form/submit.rb +20 -0
- data/lib/matestack/ui/bootstrap/form/switch.rb +30 -0
- data/lib/matestack/ui/bootstrap/form/textarea.rb +47 -0
- data/lib/matestack/ui/bootstrap/index.js +40 -0
- data/lib/matestack/ui/bootstrap/initialize.rb +3 -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 +10 -6
- data/lib/matestack/ui/bootstrap/layout/sidebar.rb +43 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.scss +0 -0
- data/{app/concepts/matestack/ui/bootstrap/apps → lib/matestack/ui/bootstrap/layouts}/admin_template.rb +18 -13
- 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/matestack/ui/bootstrap.rb +99 -17
- metadata +85 -80
- 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/alert.js +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/button.rb +0 -69
- 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.js +0 -79
- data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +0 -86
- data/app/concepts/matestack/ui/bootstrap/components/collapse.js +0 -84
- data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +0 -43
- data/app/concepts/matestack/ui/bootstrap/components/dropdown.js +0 -14
- data/app/concepts/matestack/ui/bootstrap/components/icon.rb +0 -19
- data/app/concepts/matestack/ui/bootstrap/components/modal.rb +0 -106
- data/app/concepts/matestack/ui/bootstrap/components/popover.js +0 -26
- data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +0 -48
- 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 -83
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav_content.rb +0 -32
- data/app/concepts/matestack/ui/bootstrap/components/toast.js +0 -85
- data/app/concepts/matestack/ui/bootstrap/components/toast.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/form/input.rb +0 -112
- data/app/concepts/matestack/ui/bootstrap/form/radio.rb +0 -57
- data/app/concepts/matestack/ui/bootstrap/form/submit.rb +0 -21
- data/app/concepts/matestack/ui/bootstrap/form/switch.rb +0 -99
- 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/layout/sidebar.rb +0 -45
- data/app/concepts/matestack/ui/bootstrap/pages/devise/sign_in.rb +0 -40
- data/app/concepts/matestack/ui/bootstrap/registry.rb +0 -61
- data/app/helpers/matestack/ui/bootstrap/application_helper.rb +0 -17
- data/app/javascript/matestack-ui-bootstrap/index.js +0 -24
- data/app/javascript/packs/matestack-ui-bootstrap.js +0 -2
- data/app/matestack/bootstrap/form/submit.rb +0 -20
- data/config/routes.rb +0 -2
- data/config/webpack/development.js +0 -5
- data/config/webpack/environment.js +0 -29
- data/config/webpack/production.js +0 -33
- data/config/webpack/test.js +0 -5
- data/config/webpacker.yml +0 -96
- 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: abdcfa7de4dff11225bc3f28f07ebb516553f7bb926bd01c12a4b9017bbe0df8
|
4
|
+
data.tar.gz: 4efa8e3b466b0639168df39b658cd5af9bdea65cd73c58003de2da91f2adf65f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4412fc41a8a72b77a31e0a5e878be49119bc4b69616c8864ac0681676976c703e6056ecac310b63d33a0afa7f3eeade7d84e625be919dacb3e6fe829e250c296
|
7
|
+
data.tar.gz: cff3304c99d9b35e4969deb675580f257b8c5a15a2f18b93d9120216a42f3e9bdbca3166b088fd7eebbad7a8c2eba121451cc8071482053cc2d9d1d01bd11c54
|
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,84 +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
|
|
3
|
-
|
7
|
+
![matestack logo](./logo.png)
|
4
8
|
|
5
|
-
|
9
|
+
# matestack-ui-bootstrap | beautiful, reactive UIs in pure Ruby
|
6
10
|
|
7
|
-
|
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.
|
8
13
|
|
9
|
-
|
14
|
+
----
|
10
15
|
|
11
|
-
|
12
|
-
docker-compose build dummy
|
13
|
-
docker-compose run --rm dummy bash
|
14
|
-
```
|
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.
|
15
17
|
|
16
|
-
|
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.
|
17
19
|
|
18
|
-
|
19
|
-
bundle install
|
20
|
-
yarn install
|
21
|
-
cd spec/dummy
|
22
|
-
bundle install
|
23
|
-
npm install (npm and not yarn!)
|
24
|
-
rails app:db:setup
|
25
|
-
```
|
20
|
+
----
|
26
21
|
|
27
|
-
|
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.
|
28
23
|
|
29
|
-
|
30
|
-
```shell
|
31
|
-
docker-compose up dummy
|
32
|
-
```
|
24
|
+
Don't think about styling anymore and just create admin or application UIs faster than ever before!
|
33
25
|
|
34
|
-
|
26
|
+
[<img src="https://img.youtube.com/vi/bwsVgCb97v0/0.jpg" width="350">](https://www.youtube.com/watch?v=bwsVgCb97v0)
|
35
27
|
|
36
|
-
|
37
|
-
docker-compose run --rm dummy sh -c "cd spec/dummy && ./bin/webpack --watch"
|
38
|
-
```
|
28
|
+
## Compatibility
|
39
29
|
|
40
|
-
|
30
|
+
### Ruby/Rails
|
41
31
|
|
42
|
-
|
32
|
+
`matestack-ui-bootstrap` is tested against:
|
43
33
|
|
44
|
-
|
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
|
45
38
|
|
46
|
-
|
47
|
-
docker-compose build dummy
|
48
|
-
docker-compose run --rm dummy bash
|
49
|
-
```
|
39
|
+
Rails versions below 5.2 are not supported.
|
50
40
|
|
51
|
-
|
41
|
+
### Vue.js
|
52
42
|
|
53
|
-
|
54
|
-
bundle install
|
55
|
-
yarn install
|
56
|
-
cd spec/dummy
|
57
|
-
bundle install
|
58
|
-
npm install (npm and not yarn!)
|
59
|
-
rails app:db:setup
|
60
|
-
```
|
43
|
+
`matestack-ui-bootstrap` requires Vue.js and Vuex for its reactivity features. Following version ranges are supported:
|
61
44
|
|
62
|
-
|
45
|
+
- Vue.js ^2.6.0
|
46
|
+
- Vuex ^3.6.0
|
63
47
|
|
64
|
-
|
65
|
-
docker-compose run --rm builder bash
|
48
|
+
Vue 3 / Vuex 4 update is planned for Q2 2021.
|
66
49
|
|
67
|
-
|
50
|
+
## Documentation/Installation
|
68
51
|
|
69
|
-
|
52
|
+
Documentation can be found [here](https://docs.matestack.io/matestack-ui-bootstrap)
|
70
53
|
|
71
|
-
|
72
|
-
bundle exec rspec spec/test
|
73
|
-
```
|
54
|
+
## Changelog
|
74
55
|
|
75
|
-
|
56
|
+
Changelog can be found [here](./CHANGELOG.md)
|
76
57
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
gem release
|
81
|
-
npm bump ...
|
82
|
-
npm release
|
83
|
-
git tag ...
|
84
|
-
```
|
58
|
+
## License
|
59
|
+
|
60
|
+
`matestack-ui-bootstrap` is an Open Source project licensed under the terms of the [MIT license](./LICENSE)
|
@@ -1,33 +1,36 @@
|
|
1
|
-
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Accordion < Matestack::Ui::Bootstrap::BaseComponent
|
2
4
|
|
3
5
|
# [ {header: { class, id, text, size, btn_variant, btn_class }, body: { class, text, multi } } ]
|
4
6
|
optional :items # array with 2 Hashes: header and body
|
5
7
|
optional :open
|
6
8
|
optional :variant
|
7
|
-
optional attributes
|
9
|
+
optional :attributes, class: { as: :bs_class }
|
10
|
+
optional :id
|
8
11
|
|
9
|
-
def
|
10
|
-
@accordion_id = (
|
12
|
+
def prepare
|
13
|
+
@accordion_id = (context.id.present? ? context.id : "matestack-accordion-#{SecureRandom.hex(3)}")
|
11
14
|
end
|
12
15
|
|
13
16
|
def response
|
14
17
|
div accordion_attributes do
|
15
|
-
accordion_content_partial if items.present?
|
16
|
-
|
18
|
+
accordion_content_partial if context.items.present?
|
19
|
+
yield if block_given?
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
23
|
protected
|
21
24
|
|
22
25
|
def accordion_content_partial
|
23
|
-
items.each_with_index do | item, index |
|
26
|
+
context.items.each_with_index do | item, index |
|
24
27
|
div class: "accordion-item" do
|
25
28
|
heading class: "accordion-header #{item[:header][:class]}", id: (item[:header][:id] || "header-#{index}"), size: (item[:header][:size] || 2) do
|
26
29
|
button class: "accordion-button", text:item[:header][:text],
|
27
30
|
data: { "bs-toggle": "collapse", "bs-target": "#collapse-#{(item[:header][:id] || "header-#{index}") }" },
|
28
|
-
|
31
|
+
"aria-expanded": "false", "aria-controls": "collapse-#{(item[:header][:id] || "header-#{index}")}", type: "button"
|
29
32
|
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}"),
|
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}"),
|
31
34
|
parent: @accordion_id, multi: (item[:body][:multi] || false) do
|
32
35
|
div class: "accordion-body #{item[:body][:class]}" do
|
33
36
|
plain item[:body][:text]
|
@@ -38,19 +41,18 @@ class Matestack::Ui::Bootstrap::Components::Accordion < Matestack::Ui::Component
|
|
38
41
|
end
|
39
42
|
|
40
43
|
def accordion_attributes
|
41
|
-
|
44
|
+
options.merge(
|
42
45
|
id: @accordion_id,
|
43
|
-
class: accordion_classes
|
44
|
-
attributes
|
45
|
-
)
|
46
|
+
class: accordion_classes
|
47
|
+
).merge(context.attributes || {})
|
46
48
|
end
|
47
49
|
|
48
50
|
def accordion_classes
|
49
51
|
[].tap do |classes|
|
50
52
|
classes << 'accordion'
|
51
|
-
classes << 'open' if open
|
52
|
-
classes << 'accordion-flush' if variant == :flush
|
53
|
-
classes << bs_class
|
53
|
+
classes << 'open' if context.open
|
54
|
+
classes << 'accordion-flush' if context.variant == :flush
|
55
|
+
classes << context.bs_class
|
54
56
|
end.join(' ').strip
|
55
57
|
end
|
56
58
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import * as bootstrap from 'bootstrap'
|
2
|
+
|
3
|
+
import MatestackUiVueJs from 'matestack-ui-vuejs'
|
4
|
+
|
5
|
+
const alertComponent = {
|
6
|
+
mixins: [MatestackUiVueJs.componentMixin],
|
7
|
+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
|
8
|
+
|
9
|
+
data() {
|
10
|
+
return {
|
11
|
+
alertInstance: undefined,
|
12
|
+
};
|
13
|
+
},
|
14
|
+
|
15
|
+
methods: {
|
16
|
+
close: function (){
|
17
|
+
this.alertInstance.close()
|
18
|
+
},
|
19
|
+
dispose: function (){
|
20
|
+
this.alertInstance.dispose()
|
21
|
+
// this.alertInstance = new bootstrap.Alert(self.getElement())
|
22
|
+
}
|
23
|
+
},
|
24
|
+
|
25
|
+
mounted: function() {
|
26
|
+
const self = this
|
27
|
+
var alert = self.getElement()
|
28
|
+
self.alertInstance = new bootstrap.Alert(alert)
|
29
|
+
},
|
30
|
+
|
31
|
+
created: function() {
|
32
|
+
const self = this
|
33
|
+
// close_on event registration
|
34
|
+
if(self.props["close_on"] != undefined){
|
35
|
+
var close_events = self.props["close_on"].split(",")
|
36
|
+
close_events.forEach(close_event => MatestackUiVueJs.eventHub.$on(close_event.trim(), self.close));
|
37
|
+
}
|
38
|
+
// dispose_on event registration
|
39
|
+
if(self.props["dispose_on"] != undefined){
|
40
|
+
var dispose_events = self.props["dispose_on"].split(",")
|
41
|
+
dispose_events.forEach(dispose_event => MatestackUiVueJs.eventHub.$on(dispose_event.trim(), self.dispose));
|
42
|
+
}
|
43
|
+
},
|
44
|
+
|
45
|
+
beforeUnmount: function() {
|
46
|
+
const self = this
|
47
|
+
if(self.props["close_on"] != undefined){
|
48
|
+
var closen_events = self.props["close_on"].split(",")
|
49
|
+
closen_events.forEach(close_event => MatestackUiVueJs.eventHub.$off(close_event.trim(), self.close));
|
50
|
+
}
|
51
|
+
if(self.props["dispose_on"] != undefined){
|
52
|
+
var dispose_events = self.props["dispose_on"].split(",")
|
53
|
+
dispose_events.forEach(dispose_event => MatestackUiVueJs.eventHub.$off(dispose_event.trim(), self.dispose));
|
54
|
+
}
|
55
|
+
},
|
56
|
+
}
|
57
|
+
|
58
|
+
export default alertComponent
|
@@ -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
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Matestack::Ui::Bootstrap::Components::Avatar < Matestack::Ui::Bootstrap::BaseComponent
|
2
|
+
|
3
|
+
optional :bg_variant, :text_variant, :img_path, :size, class: { as: :bs_class }
|
4
|
+
|
5
|
+
def response
|
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.bs_class}",
|
8
|
+
style: "height: #{height}px; width: #{width}px; display: inline-block;" do
|
9
|
+
plain context.text
|
10
|
+
end
|
11
|
+
else
|
12
|
+
div class: "rounded-circle text-#{context.text_variant || 'white'} text-center p-2 #{context.bs_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
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def height
|
20
|
+
context.size || 40
|
21
|
+
end
|
22
|
+
|
23
|
+
def width
|
24
|
+
context.size || 40
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Badge < Matestack::Ui::Bootstrap::BaseComponent
|
4
|
+
|
5
|
+
optional class: { as: :bs_class }
|
6
|
+
optional :variant, :rounded, :visually_hidden
|
7
|
+
|
8
|
+
def response
|
9
|
+
span badge_attributes do
|
10
|
+
plain context.text if context.text
|
11
|
+
yield if block_given?
|
12
|
+
end
|
13
|
+
span context.visually_hidden, class: "visually-hidden" if context.visually_hidden.present?
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def badge_attributes
|
19
|
+
options.merge(
|
20
|
+
class: badge_classes
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def badge_classes
|
25
|
+
[].tap do |classes|
|
26
|
+
classes << 'badge'
|
27
|
+
classes << (context.variant.present? ? "bg-#{context.variant}" : "bg-secondary")
|
28
|
+
classes << "rounded-pill" if context.rounded
|
29
|
+
classes << context.bs_class
|
30
|
+
end.join(' ').strip
|
31
|
+
end
|
32
|
+
end
|
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Breadcrumb < Matestack::Ui::Bootstrap::BaseComponent
|
2
4
|
|
3
5
|
optional :items # list of items with path and text
|
4
|
-
optional class: { as:
|
6
|
+
optional class: { as: :bs_class } # adding custom class to breadcrumb list
|
5
7
|
optional :nav_class
|
6
8
|
|
7
9
|
def response
|
8
|
-
nav class: nav_class,
|
10
|
+
nav class: context.nav_class, "aria-label": "breadcrumb" do
|
9
11
|
ol breadcrumb_attributes do
|
10
|
-
items&.each_with_index do |item, index|
|
11
|
-
li link_attrs((items.size - 1) == index) do
|
12
|
+
context.items&.each_with_index do |item, index|
|
13
|
+
li link_attrs((context.items.size - 1) == index) do
|
12
14
|
case item[:type]
|
13
15
|
when :link
|
14
|
-
|
16
|
+
a item
|
15
17
|
when :transition
|
16
18
|
transition item
|
17
19
|
else
|
@@ -19,7 +21,7 @@ class Matestack::Ui::Bootstrap::Components::Breadcrumb < Matestack::Ui::Componen
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
22
|
-
|
24
|
+
yield if block_given?
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -29,12 +31,12 @@ class Matestack::Ui::Bootstrap::Components::Breadcrumb < Matestack::Ui::Componen
|
|
29
31
|
def link_attrs(last = false)
|
30
32
|
{}.tap do |hash|
|
31
33
|
hash[:class] = "breadcrumb-item #{'active' if last}"
|
32
|
-
hash[:
|
34
|
+
hash[:"aria-current"] = "page" if last
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
38
|
def breadcrumb_attributes
|
37
|
-
|
39
|
+
options.merge(
|
38
40
|
class: breadcrumb_classes
|
39
41
|
)
|
40
42
|
end
|
@@ -42,7 +44,7 @@ class Matestack::Ui::Bootstrap::Components::Breadcrumb < Matestack::Ui::Componen
|
|
42
44
|
def breadcrumb_classes
|
43
45
|
[].tap do |classes|
|
44
46
|
classes << "breadcrumb"
|
45
|
-
classes << bs_class
|
47
|
+
classes << context.bs_class
|
46
48
|
end.join(' ').strip
|
47
49
|
end
|
48
50
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Button < Matestack::Ui::Bootstrap::BaseComponent
|
4
|
+
|
5
|
+
optional :type, :variant, :size, :outline
|
6
|
+
optional :attributes, class: { as: :bs_class }
|
7
|
+
optional :transition
|
8
|
+
optional :action
|
9
|
+
optional :onclick
|
10
|
+
optional :link
|
11
|
+
|
12
|
+
def response(&block)
|
13
|
+
if context.transition.present? && context.transition.is_a?(Hash)
|
14
|
+
transition button_attributes.merge(context.transition.merge({role: "button"})) do
|
15
|
+
inner_response(&block)
|
16
|
+
end
|
17
|
+
elsif context.action.present? && context.action.is_a?(Hash)
|
18
|
+
action button_attributes.merge(context.action.merge({role: "button"})) do
|
19
|
+
inner_response(&block)
|
20
|
+
end
|
21
|
+
elsif context.onclick.present? && context.onclick.is_a?(Hash)
|
22
|
+
onclick button_attributes.merge(context.onclick.merge({role: "button"})) do
|
23
|
+
inner_response(&block)
|
24
|
+
end
|
25
|
+
elsif context.link.present? && context.link.is_a?(Hash)
|
26
|
+
a button_attributes.merge(context.link.merge({role: "button"})) do
|
27
|
+
inner_response(&block)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
button_response(&block)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def button_response(&block)
|
35
|
+
button button_attributes do
|
36
|
+
inner_response(&block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def inner_response(&block)
|
41
|
+
plain context.text if context.text
|
42
|
+
yield if block_given?
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def button_attributes
|
48
|
+
options.tap do |opts|
|
49
|
+
opts[:type] = context.type || 'button'
|
50
|
+
opts[:class] = button_classes
|
51
|
+
opts.merge(context.attributes || {})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def button_classes
|
56
|
+
[].tap do |classes|
|
57
|
+
classes << 'btn'
|
58
|
+
# btn variants outlined or solid background
|
59
|
+
if context.outline
|
60
|
+
classes << "btn-outline-#{context.variant.to_s.gsub('_', '-') || 'primary'}"
|
61
|
+
else
|
62
|
+
classes << (context.variant ? "btn-#{context.variant.to_s.gsub('_', '-')}" : 'btn-primary')
|
63
|
+
end
|
64
|
+
# btn size
|
65
|
+
classes << "btn-#{context.size}" if context.size
|
66
|
+
# custom classes
|
67
|
+
classes << context.bs_class
|
68
|
+
end.join(' ').strip
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::ButtonGroup < Matestack::Ui::Bootstrap::BaseComponent
|
4
|
+
|
5
|
+
optional class: { as: :bs_class }
|
6
|
+
optional :label
|
7
|
+
optional :toolbar, :size, :vertical
|
8
|
+
|
9
|
+
def response
|
10
|
+
div buttongroup_attributes do
|
11
|
+
yield if block_given?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def buttongroup_attributes
|
18
|
+
attributes = {}.tap do |hash|
|
19
|
+
hash[:class] = buttongroup_classes
|
20
|
+
hash[:role] = "#{context.toolbar ? :toolbar : :group}"
|
21
|
+
hash[:"aria-label"] = context.label
|
22
|
+
end
|
23
|
+
options.merge(
|
24
|
+
attributes
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def buttongroup_classes
|
29
|
+
[].tap do |classes|
|
30
|
+
classes << ("btn-#{context.toolbar ? :toolbar : :group}#{'-vertical' if context.vertical}")
|
31
|
+
classes << "btn-group-#{context.size}" if context.size.present?
|
32
|
+
classes << context.bs_class
|
33
|
+
end.join(' ').strip
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|