matestack-ui-bootstrap ships all you need to build reactive AND styled UIs in pure Ruby orchestrating styled components (based on Bootstrap v5) with a simple Ruby DSL. Additionally smart CRUD components helps you building beautiful data-driven admin and application UIs.
All features of matestack-ui-core and matestack-ui-vuejs can be mixed in which gives you maximum flexibility while implementing your UIs.
Compatibility
matestack-ui-bootstrap requires matestack-ui-vuejs and matestack-ui-core
matestack-ui-bootstrap is tested against:
Rails 7.0.1 + Ruby 3.0.0 + Vue.js 3.2.26
Rails 6.1.1 + Ruby 3.0.0 + Vue.js 3.2.26
Rails 6.1.1 + Ruby 2.7.2 + Vue.js 3.2.26
Rails 6.0.3.4 + Ruby 2.6.6 + Vue.js 3.2.26
Rails 5.2.4.4 + Ruby 2.6.6 + Vue.js 3.2.26
Rails versions below 5.2 are not supported.
Vue.js 2.x is supported when using the Compat build of Vue.js
Documentation/Installation
Feature walk-through
You might want to have a look at the dummy app in oder to better understand what kind of results you get out of matestack-ui-bootstrap
Mix that with Matestack's core components, Bootstrap's utility classes or custom CSS for customized UI implementation. That means you're able to use Bootstrap and matestack-ui-boostrap components with a high level of abstraction for maximum productivity right next to core components like `div` with a lower level of abstraction for maximum flexibility!
On top of that, you're able to use all kinds of methods in order to render your UI based on conditions like `current_user.is_super_admin?`. Adjusting the UI to your custom rules based on pure Ruby is super easy. That's what we call flexible abstraction!
The following code snippet demonstrates the usage of components shippend in matestack-ui-bootstrap (bs_*) alongside using utility classes (mt-3) and matestack-ui-core components (small,b ...) and reactive components from matestack-ui-vuejs (transition):
Use our prebuilt app templates through class inheritance in order to quickly setup typical layouts including sidebar and header navigation. Styles can be customized via SCSS theming.
Thanks to the fact that you're dealing with pure Ruby classes, it's also pretty easy to modify prebuilt UI structures and appearance in order to tailor the admin app to your individual needs.
classMyAdmin::Layout<Matestack::Ui::Bootstrap::Layouts::AdminTemplate# the response method is defined by the parent class# you just need to pass in some configuration using the methods below# it's still possible to overwrite and adjust the response method# defined in the parent classdefsidebar_top_partial div class: "text-center"do transition path: root_path, delay: 300do h4 "Your Rails Backend"endend div class: "text-center my-5"do bs_avatar img_path: asset_pack_url('media/images/avatar-placeholder.png') div class: "my-3"do plain current_admin.emailendendenddefsidebar_navigation_items [ { type: :transition, path: dummy_dashboard_path, text: "Dashboard", icon: "columns-gap" }, { type: :transition, path: dummy_products_path, text: "Products", icon: "box" }, { type: :transition, path: dummy_customers_path, text: "Customers", icon: "people-fill" }, { type: :transition, path: dummy_orders_path, text: "Orders", icon: "cart-check-fill"}, ]enddeftoasts [ { show_on: "failure", class: "bg-danger text-white", body: "Error!" }, { show_on: "success", class: "bg-primary text-white", body: "Success!" }, ]end
leading to something like this (layout with sidebar and toasts tiggered on form and action submissions, page content is obviously defined somewhere else ;) -->
Powerful page layout components for great UI experience
Use components like bs_page_heading or bs_section_card together with grid components like bs_row and bs_col in order to quickly create a well structured, consistent and good looking UI.
Split rendering of complex, data-intesive UIs with Matestack's VueJs async component and increase initial page load performance! All without writing one line of JavaScript:
classMyAdmin::Components::Dashboard::Revenue<Matestack::Ui::Componentdefresponse section_card title: t("dashboard.revenue.title"), subtitle: t("dashboard.revenue.subtitle") do row do col xl: 6do text_kpis_partialend col xl: 6, class: "py-3"do chart_kpis_partialendendendend# ...end
leading to something like this -->
Chart.js components accessible in pure Ruby
Want to visualize some data in charts? Matestack UI Bootstrap let's you easily integrate chart.js (copy/paste once from example in documentation [or choose any other chart library]) which from then on allows you to use chart components in pure Ruby without thinking of the JavaScript side!
Choose from line, doughnut, bar or pie charts and use theme colors for consistent coloring of datasets without touching CSS:
classMyAdmin::Components::Dashboard::Products<Matestack::Ui::Componentdefresponse bs_section_card title: t("..."), subtitle: t("...") do bs_row do bs_col xl: 6do text_kpis_partialend bs_col xl: 6, class: "py-3"do chart_kpis_partialendendendendprotected# ...defchart_kpis_partial# Component available for copy/paste in matestack-ui-bootstrap docs!Components::ChartJs type: :doughnut, datasets: [ { data: top_5_product_values, backgroundColor: [:primary, :secondary, :blue, :indigo, :info] }, ], labels: top_5_product_namesenddeftop_5_productsOrderItem.group(:product_id).sum(:price_in_euro).sort_by{|k, v| v}.reverse.first(5)enddeftop_5_product_values top_5_products.map { |product_id, value| value }enddeftop_5_product_names top_5_products.map { |product_id, value|Product.find(product_id).name }endend
which leads to something like this -->
Reactive and styled forms in no time
matestack-ui-vuejs already ships reactive forms, usable with pure Ruby. Within matestack-ui-bootstrap you get styled form components, enabling you to create beautiful, reactive forms with a few lines of Ruby!
Create styled forms, with reactive error/success rendering without thinking of any implementation detail:
which results in something like this --> (errors are rendered dynamically after async form submission, a error toast would trigger as well if added to the layout)
Reactive, paginated, filterable tables, without the JavaScript hussle
Implementing a paginated, filterable collection is exhausting. And what about some reactivity when switching through the pages in order to avoid full page reloads? You don't want to build that yourself! That's why we've created the collection component, shipped within matestack-ui-core. The bs_smart_collection shipped with matestack-ui-bootstrap gives you even more:
A few lines of Ruby is enough to add a styled, reactive paginated table with filters to your UI! You can optionally modify column rendering and per-row actions via method injection:
classMyAdmin::Pages::Orders::Index<Matestack::Ui::Pagedefresponse# ... bs_section_card do bs_smart_collection collection_configend# ...enddefcollection_config { id: 'orders',# Active Record query: items: Order.includes(:customer, :order_items).all, paginate: 10, rerender_on: "success", columns: {# just render the ID: id: 'ID',# render an attribute of a child model:'customer.last_name': {# use a specific table column heading: heading: 'Customer Name' }, price_in_euro: { heading: 'Price in €',# transform the column content with a Proc: format: -> (column_data){ "#{column_data} €" }, text: :right } }, filters: {'customer.last_name': { placeholder: 'Filter by Customer Name', match: :starts_with, } }, slots: {# inject a method which defines the per row actions: table_item_actions: method(:table_item_actions) } }enddeftable_item_actionsorder transition path: edit_dummy_order_path(order), delay: 300do bs_btn outline: true, size: :sm, variant: :primary do bs_icon name: 'arrow-right', size: 20endendendend
which leads to something like this -->
...and if you're not into tables, you can adjust the collection content rendering with some custom ruby code while keeping all the reactivity: