|
| 1 | +--- |
| 2 | +description: 'Matestack Ui Bootstrap - Beautiful, reactive web UIs, Ruby and you!' |
| 3 | +--- |
| 4 | + |
1 | 5 | # Welcome |
2 | 6 |
|
3 | 7 | As an extension for `matestack-ui-core`, `matestack-ui-bootstrap`ships all you need to build beautiful, reactive UIs in pure Ruby and smart CRUD components based on Bootstrap v5. Don't think about styling anymore and just create admin or application UIs faster than ever before! |
4 | 8 |
|
5 | | -## Live Demo <a id="live-demo"></a> |
6 | | - |
7 | | -Based on `matestack-ui-core` and `matestack-ui-bootstrap` this reactive dummy app was created in pure Ruby without writing any JavaScript, ERB/HAML/SLIM and CSS: \([check it out](https://dummy.matestack.io/) \| [source code](https://github.com/matestack/matestack-ui-bootstrap/tree/main/spec/dummy)\) |
8 | | - |
9 | | - |
10 | | - |
11 | 9 | {% hint style="info" %} |
12 | | -We do not offer Sprocktes Support in order to include the JavaScript part of `matestack-ui-bootstrap`. Please use something like Webpacker instead! Sprockets support will be dropped soon for `matestack-ui-core` as well! |
| 10 | +Read about `matestack-ui-core` here: [https://docs.matestack.io/matestack-ui-core](https://docs.matestack.io/matestack-ui-core) |
13 | 11 | {% endhint %} |
14 | 12 |
|
15 | | -## Webpacker Installation |
| 13 | +## Why? |
16 | 14 |
|
17 | | -```text |
18 | | -bundle add 'matestack-ui-bootstrap' |
19 | | -yarn add 'matestack-ui-bootstrap' |
20 | | -``` |
| 15 | +How much do you enjoy copy&pasting complex DOM structures and giant chains of CSS classes across your APP in order to create a decent looking UI? |
21 | 16 |
|
22 | | -`app/views/layouts/application.html.erb` |
23 | | - |
24 | | -```text |
25 | | -<!DOCTYPE html> |
26 | | -<html> |
27 | | - <head> |
28 | | - <title>Your App</title> |
29 | | - <meta name="viewport" content="width=device-width,initial-scale=1"> |
30 | | - <%= csrf_meta_tags %> |
31 | | - <%= csp_meta_tag %> |
32 | | -
|
33 | | - <%= stylesheet_link_tag 'application', media: 'all'%> |
34 | | - <%= javascript_pack_tag 'application'%> |
35 | | - </head> |
36 | | -
|
37 | | - <body> |
38 | | - <div id="matestack-ui"> |
39 | | - <%= yield %> |
40 | | - </div> |
41 | | - </body> |
42 | | -</html> |
43 | | -``` |
| 17 | +With `matestack-ui-core` you're luckily able to build complex DOM structures ONCE in pure Ruby in a Matestack component and reuse it across your app without copy&pasting. So this component may look like this: |
| 18 | + |
| 19 | +{% code title="app/matestack/components/card\_component.rb" %} |
| 20 | +```ruby |
| 21 | +class Components::CardComponent < Matestack::Ui::Component |
44 | 22 |
|
45 | | -`app/javascript/packs/stylesheets/application.scss` |
| 23 | + def response |
| 24 | + div class: "card shadow-sm border-0 bg-light" do |
| 25 | + img path: "...", class: "w-100" |
| 26 | + body_partial # calling the below defined instance method |
| 27 | + end |
| 28 | + end |
46 | 29 |
|
47 | | -```css |
48 | | -@import "~bootstrap/scss/bootstrap.scss"; |
49 | | -``` |
| 30 | + private |
50 | 31 |
|
51 | | -`app/javascript/packs/application.js` |
| 32 | + def body_partial |
| 33 | + div class: "card-body" do |
| 34 | + h5 "foo", class: "card-title" |
| 35 | + paragraph "bar", class: "card-text" |
| 36 | + end |
| 37 | + end |
52 | 38 |
|
53 | | -```javascript |
54 | | -import Rails from "@rails/ujs" |
55 | | -// import Turbolinks from "turbolinks" |
56 | | -import * as ActiveStorage from "@rails/activestorage" |
57 | | -import "channels" |
| 39 | +end |
| 40 | +``` |
| 41 | +{% endcode %} |
58 | 42 |
|
59 | | -import "./stylesheets/application.scss"; |
| 43 | +`matestack-ui-core` has no opinion about styling. That's why you need to build a Bootstrap card component \(or whatever CSS approach you prefer\) yourself. In case you're into Bootstrap: Wouldn’t it be cool to have all Bootstrap components available like that in pure Ruby? |
60 | 44 |
|
61 | | -import Vue from 'vue/dist/vue.esm' |
62 | | -import Vuex from 'vuex' |
| 45 | +That's at least what we thought and why we've created `matestack-ui-bootstrap`shipping all you need to build beautiful, reactive UIs in pure Ruby and smart CRUD components based on Bootstrap v5. |
63 | 46 |
|
64 | | -import MatestackUiCore from 'matestack-ui-core' |
65 | | -import MatestackUiBootstrap from "matestack-ui-bootstrap" |
| 47 | +So a card is already implemented and would be used like that: |
66 | 48 |
|
67 | | -let matestackUiApp = undefined |
| 49 | +```ruby |
| 50 | +bs_card title: "foo", body: "bar" |
| 51 | +``` |
68 | 52 |
|
69 | | -document.addEventListener('DOMContentLoaded', () => { |
70 | | - matestackUiApp = new Vue({ |
71 | | - el: "#matestack-ui", |
72 | | - store: MatestackUiCore.store |
73 | | - }) |
74 | | -}) |
| 53 | +which renders: |
75 | 54 |
|
76 | | -Rails.start() |
77 | | -// Turbolinks.start() |
78 | | -ActiveStorage.start() |
| 55 | +```markup |
| 56 | +<div class="card"> |
| 57 | + <div class="card-body"> |
| 58 | + <h5 class="card-title">foo</h5> |
| 59 | + <p class="card-text">bar</p> |
| 60 | + </div> |
| 61 | +</div> |
79 | 62 | ``` |
80 | 63 |
|
81 | | -`app/assets/images/icons` |
| 64 | +{% page-ref page="api/components/card.md" %} |
82 | 65 |
|
83 | | -* download latest compatible icons: [https://github.com/twbs/icons/releases/tag/v1.3.0](https://github.com/twbs/icons/releases/tag/v1.3.0) |
84 | | -* extract the bootstrap-icons.svg to this path: app/assets/images/icons \(served via assets pipeline\) |
| 66 | +You can see, how the prebuilt card component save you from writing 6 lines of HTML. And that's just a simple example. When using all kinds prebuilt components, you will stop writing a ton of HTML or copy&pasting DOM structure around. Do you what that makes with the readability and maintainability of your app? Not to speak about developer happiness... |
85 | 67 |
|
86 | | -## Usage |
87 | 68 |
|
88 | | -Create Matestack apps, pages and components as described in the docs of `matestack-ui-core` and utilize the components described in the API section in order to create your UI. Just make sure to include the additional Registry in your desired controllers |
89 | 69 |
|
90 | | -`app/controllers/application_controller.rb` |
| 70 | +## Live Demo <a id="live-demo"></a> |
91 | 71 |
|
92 | | -```ruby |
93 | | -class ApplicationController < ActionController::Base |
| 72 | +Based on `matestack-ui-core` and `matestack-ui-bootstrap` this reactive dummy app was created in pure Ruby without writing any JavaScript, ERB/HAML/SLIM and CSS: \([check it out](https://dummy.matestack.io/) \| [source code](https://github.com/matestack/matestack-ui-bootstrap/tree/main/spec/dummy)\) |
94 | 73 |
|
95 | | - include Matestack::Ui::Core::Helper # described in Core docs |
| 74 | + |
96 | 75 |
|
97 | | -end |
98 | | -``` |
| 76 | +## Getting Started |
99 | 77 |
|
100 | | -and include the registry wherever you want to use the components via methods like "bs\_btn" instead of calling the namespaced classes |
| 78 | +Before you dive into `matestack-ui-bootstrap`, make sure to have a solid understanding of `matestack-ui-core` first: [https://docs.matestack.io/matestack-ui-core/getting-started/concepts-rails-integration](https://docs.matestack.io/matestack-ui-core/getting-started/concepts-rails-integration) |
101 | 79 |
|
102 | | -`app/matestack/application_component.rb` |
| 80 | +After that, it might be a good idea to get into using `matestack-ui-bootstrap` following the quick start guide: |
103 | 81 |
|
104 | | -```ruby |
105 | | -class ApplicationComponent < Matestack::Ui::Component |
| 82 | +{% page-ref page="getting-started/quick-start.md" %} |
106 | 83 |
|
107 | | - include Matestack::Ui::Bootstrap::Registry # use methods like "bs_btn" instead of calling the namespaced classes |
| 84 | +If you know how to use matestack-ui-bootstrap, the API documentation should serve you well: |
108 | 85 |
|
109 | | -end |
110 | | -``` |
| 86 | +## Roadmap |
| 87 | + |
| 88 | +Do you want to know what we're currently working on and what's planned for the next releases? Check out our GitHub Project board: [https://github.com/orgs/matestack/projects/1](https://github.com/orgs/matestack/projects/1) |
111 | 89 |
|
0 commit comments