Written by Pascal Wengerter
A self-taught software developer, and digital all-rounder. Loves democracy ‘n’ open source software. Black lives matter supporter. Co-founded the open source startup Matestack. Working as a freelancer while looking for a role in (digital) product management.
Deeply in love with programming in Ruby and frustrated with the overly complex state of fullstack web development,
started experimenting in late 2017 and ended up creating a prototype that eventually grew into
matestack-ui-core and subsequent libraries.
Instead of rendering
.erb-views or introducing a separate single-page application (SPA)-framework to handle the frontend,
The gem is built using
Below is a simple example containing both a simple component and page. The
paragraph core components get orchestrated by the (custom)
Some::Component, which then gets called on the
# defining a component class Some::Component < Matestack::Ui::Component def prepare @some_data = "some data" end def response div id: "my-component" do paragraph text: @some_data end end end # using the component on a page (= web view) class ExamplePage < Matestack::Ui::Page def response div id: "div-on-page" do some_component end end end
<div id="div-on-page"> <div id="my-component"> <p>some data</p> </div> </div>
Leveraging the power of
matestack-ui-core gem has abstracted away quite a number of use cases and turned them into (arguably) straighforward solutions. Judge for yourself:
# app/matestack/components/some_component.rb class Components::SomeComponent < Matestack::Ui::Component def response onclick emit: "some_event" do button text: "click me" end toggle show_on: "some_event", hide_after: 5000 do plain "Oh yes! You clicked me!" end end end
<button tabindex="0">click me</button> <!-- only gets shown when the buttons is clicked & gets hidden after 5000ms <div class="matestack-toggle-component-root"><br>Oh yes! You clicked me!</div> -->
Please refer to the guides, this should only be a teaser ;)
The installation is quite straightforward and works with both the Asset Pipeline and Webpacker. Along with more information, there’s also a 10 step tutorial on how to set up & deploy your first matestack-powered Rails app to Heroku and the full Component API.
There’s a Discord server, Q&A calls twice a week and contribution opportunities for anyone that wants to get involved!
Feel free to reach out to Jonas Jabari if you got anything to share or ask :)