{"id":19760796,"url":"https://github.com/matestack/matestack-ui-vuejs","last_synced_at":"2025-04-30T13:33:06.668Z","repository":{"id":37941511,"uuid":"454351204","full_name":"matestack/matestack-ui-vuejs","owner":"matestack","description":"Vue.js 3 based reactivity system for Rails. Boost your productivity \u0026 easily create reactive web UIs in pure Ruby. Easily extend with pure JavaScript if required. No Opal involved.","archived":false,"fork":false,"pushed_at":"2023-05-10T22:12:43.000Z","size":19553,"stargazers_count":3,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-26T07:22:47.535Z","etag":null,"topics":["fullstack","hotwire","hotwire-turbo","rails","ruby","ruby-gem","ruby-on-rails","stimulus-reflex","vuejs","vuejs3"],"latest_commit_sha":null,"homepage":"https://www.matestack.io","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matestack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["matestack"]}},"created_at":"2022-02-01T10:52:54.000Z","updated_at":"2022-08-02T11:32:56.000Z","dependencies_parsed_at":"2023-01-23T06:30:11.496Z","dependency_job_id":null,"html_url":"https://github.com/matestack/matestack-ui-vuejs","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matestack%2Fmatestack-ui-vuejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matestack%2Fmatestack-ui-vuejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matestack%2Fmatestack-ui-vuejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matestack%2Fmatestack-ui-vuejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matestack","download_url":"https://codeload.github.com/matestack/matestack-ui-vuejs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224214227,"owners_count":17274524,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fullstack","hotwire","hotwire-turbo","rails","ruby","ruby-gem","ruby-on-rails","stimulus-reflex","vuejs","vuejs3"],"created_at":"2024-11-12T03:38:45.179Z","updated_at":"2024-11-12T03:38:45.765Z","avatar_url":"https://github.com/matestack.png","language":"Ruby","funding_links":["https://github.com/sponsors/matestack"],"categories":[],"sub_categories":[],"readme":"[![Specs](https://github.com/matestack/matestack-ui-vuejs/workflows/specs/badge.svg)](https://github.com/matestack/matestack-ui-vuejs/actions)\n[![Discord](https://img.shields.io/discord/771413294136426496.svg)](https://discord.com/invite/c6tQxFG)\n[![Gem Version](https://badge.fury.io/rb/matestack-ui-vuejs.svg)](https://badge.fury.io/rb/matestack-ui-vuejs)\n[![Docs](https://img.shields.io/badge/docs-matestack-blue.svg)](https://docs.matestack.io)\n[![Twitter Follow](https://img.shields.io/twitter/follow/matestack.svg?style=social)](https://twitter.com/matestack)\n\n![matestack logo](./logo.png)\n\n# matestack-ui-vuejs | Vue.js 3 based reactivity system for Rails\n\nBoost your productivity \u0026 easily create reactive web UIs in pure Ruby. Easily extend with pure JavaScript if required. No Opal involved.\n\n**New repo, old git history? This repo was duplicated from `matestack-ui-core` in order to extract Vue.js features into `matestack-ui-vuejs` in Feburary 2022**\n\n## About\n\n`matestack-ui-vuejs` ships all you need to build **reactive** UIs in **pure Ruby** orchestrating prebuilt Vue.js components with a simple Ruby DSL.\n\nThe prebuilt reactive components built **on top of Vue.js** are covering typical features of a reactive web UI, such as async form submission, dynamic page transitions or async partial UI updates. **No Opal involved**\n\nIf required, it can be easily extended with pure JavaScript.\n\n### Why matestack-ui-vuejs?\n\n`matestack-ui-vuejs` was created because modern web app development became more and more complex due to the rise of JavaScript frontend frameworks and the SPA frontend/REST API/JSON backend architecture. This sophisticated approach might be suitable for big teams and applications but is way to complex for most of small to medium sized teams and application scopes.\n\nIn contrast, `matestack-ui-vuejs` helps Rails developers creating modern, reactive web apps while focusing on **simplicity**, **developer happiness** and **productivity**:\n\n* [x] Use Ruby’s amazing language features while creating your UI\n* [x] Skip using templating engine syntax and write pure Ruby instead\n* [x] Reduce the amount of required JavaScript in order to build reactive web UIs\n* [x] Create a single application, managing the full stack from database to a reactive UI in pure Ruby\n* [x] **Drastically reduce the complexity of building reactive web applications**\n\n### What makes matestack-ui-vuejs different?\n\n[Hotwire](https://hotwire.dev) and [Stimulus Reflex](https://docs.stimulusreflex.com) are awesome gems. They reduce the amount of required JavaScript when implementing reactive web UIs. They allow us to use more Rails and less JavaScript. **Great!**\n\nMatestack, developed since 2018, goes even one step further: **Use more Ruby and less of everything else** (JavaScript, ERB/HAML/SLIM, CSS).\n\n**Why?** Because Ruby is just beautiful! More Ruby = More developer happiness = Higher productivity\n\nAdditionally, most of `matestack-ui-vuejs` does not require Action Cable or Redis, but can optionally use the power of these tools.\n\n## Compatibility\n\n`matestack-ui-vuejs` requires `matestack-ui-core`\n\n`matestack-ui-vuejs` is tested against:\n\n* Rails 7.0.1 + Ruby 3.0.0 + Vue.js 3.2.26\n* Rails 6.1.1 + Ruby 3.0.0 + Vue.js 3.2.26\n* Rails 6.1.1 + Ruby 2.7.2 + Vue.js 3.2.26\n* Rails 6.0.3.4 + Ruby 2.6.6 + Vue.js 3.2.26\n* Rails 5.2.4.4 + Ruby 2.6.6 + Vue.js 3.2.26\n\nRails versions below 5.2 are not officially supported.\n\nVue.js 2.x is supported when using the Compat build of Vue.js\n\n## Documentation/Installation\n\nDocumentation can be found [here](https://docs.matestack.io/matestack-ui-vuejs)\n\n## Getting started\n\nA getting started guide can be found [here](https://docs.matestack.io/matestack-ui-vuejs/getting-started/hello-world)\n\n## Changelog\n\nChangelog can be found [here](./CHANGELOG.md)\n\n## Community\n\nAs a low-barrier feedback channel for our early users, we have set up a Discord server that can be found [here](https://discord.com/invite/c6tQxFG). You are very welcome to ask questions and send us feedback there!\n\n## Contribution\n\nWe are happy to accept contributors of any kind! In order to make it as easy and fun as possible to contribute to `matestack-ui-vuejs`, we would like to onboard contributors personally! Best way to become a contributor: Ping us on Discord! We will schedule a video call with you and show you, how and what to work on :)\n\n## Feature walk-through\n\n### 1. Use reactive UI components in pure Ruby\n\nMatestack's generic, reactive components can be placed on your UI with a simple Ruby DSL. While putting these generic components in your UI code, you inject some configuration in order to adjust the behaviour to your needs. This enables you to create reactive UIs without touching JavaScript!\n\n*Behind the scenes:* When calling a reactive component with the Ruby DSL, Matestack will render a special component tag with a bunch of attributes to the resulting, server-side rendered HTML. Within the browser, Vue.js will pick up these component tags and mount the JavaScript driven components on it.\n\n**Toggle parts of the UI based on events**\n\n`matestack-ui-vuejs` offers an event hub. Reactive components can emit and receive events through this event hub. \"onclick\" and \"toggle\" calling two of these reactive core components. \"onclick\" emits an event which causes the body of the \"toggle\" component to be visible for 5 seconds in this example.\n\n`app/matestack/components/some_component.rb`\n\n```ruby\nclass Components::SomeComponent \u003c Matestack::Ui::Component\n\n  def response\n    onclick emit: \"some_event\" do\n      button \"click me\"\n    end\n    toggle show_on: \"some_event\", hide_after: 5000 do\n      plain \"Oh yes! You clicked me!\"\n    end\n  end\n\nend\n```\n\n**Call controller actions without JavaScript**\n\nCore components offer basic dynamic behaviour and let you easily call controller actions and react to server responses on the client side without full page reload. The \"action\" component is configured to emit an event after successfully performed an HTTP request against a Rails controller action, which is received by the \"toggle\" component, displaying the success message.\n\n`app/matestack/components/some_component.rb`\n\n```ruby\nclass Components::SomeComponent \u003c Matestack::Ui::Component\n\n  def response\n    action my_action_config do\n      button \"click me\"\n    end\n    toggle show_on: \"some_event\", hide_after: 5000 do\n      plain \"Success!\"\n    end\n  end\n\n  def my_action_config\n    {\n      path: some_rails_route_path,\n      method: :post,\n      success: {\n        emit: \"some_event\"\n      }\n    }\n  end\n\nend\n```\n\n#### Dynamically handle form input without JavaScript\n\nCreate dynamic forms for ActiveRecord Models (or plain objects) and display server side responses, like validation errors or success messages, without relying on a full page reload. Events emitted by the \"form\" component can be used to toggle parts of the UI.\n\n`app/matestack/components/some_component.rb`\n\n```ruby\nclass Components::SomeComponent \u003c Matestack::Ui::Component\n\n  def response\n    matestack_form my_form_config do\n      form_input key: :some_model_attribute, type: :text\n      button \"click me\", type: :submit\n    end\n    toggle show_on: \"submitted\", hide_after: 5000 do\n      span class: \"message success\" do\n        plain \"created successfully\"\n      end\n    end\n    toggle show_on: \"failed\", hide_after: 5000 do\n      span class: \"message failure\" do\n        plain \"data was not saved, please check form\"\n      end\n    end\n  end\n\n  def my_form_config\n    {\n      for: MyActiveRecordModel.new,\n      path: some_rails_route_path,\n      method: :post,\n      success: {\n        emit: \"submitted\"\n      },\n      failure: {\n        emit: \"failed\"\n      }\n    }\n  end\n\nend\n```\n\n**Implement asynchronous, event-based UI rerendering in pure Ruby**\n\nUsing Matestack's built-in event system, you can rerender parts of the UI on client side events, such as form or action submissions. Even server side events pushed via ActionCable may be received! The \"async\" component requests a new version of its body at the server via an HTTP GET request after receiving the configured event. After successful server response, the DOM of the \"async\" component gets updated. Everything else stays untouched.\n\n`app/matestack/components/some_component.rb`\n\n```ruby\nclass Components::SomeComponent \u003c Matestack::Ui::Component\n\n  def response\n    matestack_form my_form_config do\n      #...\n    end\n    #...\n    async rerender_on: \"submitted\", id: \"my-model-list\" do\n      ul do\n        MyActiveRecordModel.last(5).each do |model|\n          li model.some_attribute\n        end\n      end\n    end\n  end\n\n  def my_form_config\n    {\n      #...\n      success: {\n        emit: \"submitted\"\n      },\n      failure: {\n        emit: \"failed\"\n      }\n    }\n  end\n\nend\n```\n\n**Manipulate parts of the UI via ActionCable**\n\n\"async\" rerenders its whole body - but what about just appending the element to the list after successful form submission? The \"cable\" component can be configured to receive events and data pushed via ActionCable from the server side and just append/prepend new chunks of HTML (ideally rendered through a component) to the current \"cable\" component body. Updating and deleting is also supported!\n\n`app/matestack/components/some_component.rb`\n\n```ruby\nclass Components::SomeComponent \u003c Matestack::Ui::Component\n\n  def response\n    matestack_form my_form_config do\n      #...\n    end\n    #...\n    cable prepend_on: \"new_element_created\", id: \"some-cable-driven-list\" do\n      MyActiveRecordModel.last(5).each do |model|\n        Components::SomeListItemComponent.call(content: model.some_content)\n      end\n    end\n  end\n\nend\n```\n\n`app/controllers/some_controller.rb`\n\n```ruby\n# within your controller action handling the form input\nActionCable.server.broadcast(\"matestack_ui_core\", {\n  event: \"new_element_created\",\n  data: Components::SomeListItemComponent.call(content: model.some_content) # or plain HTML\n})\n```\n\n### **2. Easily extend with Vue.js**\n\nMatestack's dynamic parts are built on Vue.js. If you want to implement custom dynamic behaviour, you can simply create your own Vue components and use them along Matestack's components. It's even possible to interact with Matestack's components using the built-in event bus.\n\n`app/matestack/components/some_component.rb`\n\n```ruby\nclass Components::SomeComponent \u003c Matestack::Ui::Component\n\n  def response\n    Components::MyVueJsComponent.call()\n    toggle show_on: \"some_event\", hide_after: \"3000\" do\n      span class: \"message success\" do\n        plain \"event triggered from custom vuejs component\"\n      end\n    end\n  end\n\nend\n```\n\n`app/matestack/components/my_vue_js_component.rb`\n\n```ruby\nclass Components::MyVueJsComponent \u003c Matestack::Ui::VueJsComponent\n\n  vue_name \"my-vue-js-component\"\n\n  def response\n    div class: \"my-vue-js-component\" do\n      button \"@click\": \"vc.increaseValue\"\n      br\n      plain \"{{ vc.dynamicValue }}!\"\n    end\n  end\n\nend\n```\n\n`app/matestack/components/my_vue_js_component.js`\n\n```javascript\nimport MatestackUiVueJs from 'matestack-ui-vuejs'\n\nconst myComponent = {\n  mixins: [MatestackUiVueJs.componentMixin],\n  template: MatestackUiVueJs.componentHelpers.inlineTemplate,\n  data: () =\u003e {\n    return {\n      dynamicValue: 0\n    };\n  },\n  methods: {\n    increaseValue(){\n      this.dynamicValue++\n      MatestackUiVueJs.eventHub.$emit(\"some_event\")\n    }\n  }\n}\n\nexport default myComponent\n\n// and then in your application pack file you register the component like:\n\nappInstance.component('my-vue-js-component', myComponent) /\n```\n\n### 3. Create whole SPA-like apps in pure Ruby\n\nThe last step in order to leverage the full Matestack power: Create a Matestack layout (\\~Rails layout) and Matestack page (Rails \\~view) classes (as seen on `matestack-ui-core`) and implement dynamic page transitions with components coming from `matestack-ui-vuejs` without any custom JavaScript implementation required.\n\n**Create your layouts and views in pure Ruby**\n\nThe layout class is used to define a layout, usually containing some kind of header, footer and navigation. The page class is used to define a view. Following the same principles as seen on components, you can use components (core or your own) in order to create the UI. The `matestack_vue_js_app` `page_switch` and `transition` components enable dynamic page transition, replacing the yielded content with new serverside rendered content rendered by the requested page.\n\n`app/matestack/some_app/some_layout.rb`\n\n```ruby\nclass SomeApp::SomeLayout \u003c Matestack::Ui::Layout\n\n  def response\n    h1 \"My App\"\n    matestack_vue_js_app do\n      nav do\n        transition path: page1_path do\n          button \"Page 1\"\n        end\n        transition path: page2_path do\n          button \"Page 2\"\n        end\n      end\n      main do\n        div class: \"container\" do\n          page_switch do\n            yield\n          end\n        end\n      end\n    end\n  end\n\nend\n```\n\n`app/matestack/some_app/pages/page1.rb`\n\n```ruby\nclass SomeApp::Pages::Page1 \u003c Matestack::Ui::Page\n\n  def response\n    div class: \"row\" do\n      div class: \"col\" do\n        plain \"Page 1\"\n      end\n    end\n  end\n\nend\n```\n\n`app/matestack/some_app/pages/page2.rb`\n\n```ruby\nclass SomeApp::Pages::Page2 \u003c Matestack::Ui::Page\n\n  def response\n    div class: \"row\" do\n      div class: \"col\" do\n        plain \"Page 2\"\n      end\n    end\n  end\n\nend\n```\n\n**Layouts and pages are referenced in your Rails controllers and actions**\n\nInstead of referencing Rails layouts and views on your controllers, you just use apps and pages as substitutes. Work with controllers, actions and routing as you're used to! Controller hooks (e.g. devise's authenticate\\_user) would still work!\n\n`app/controllers/some_controller.rb`\n\n```ruby\nclass SomeController \u003c ApplicationController\n\n  include Matestack::Ui::Core::Helper\n\n  matestack_layout SomeApp::SomeLayout\n\n  def page1\n    render SomeApp::Page1\n  end\n\n  def page2\n    render SomeApp::Page2\n  end\n\nend\n```\n\n`app/config/routes.rb`\n\n```ruby\nRails.application.routes.draw do\n\n  root to: 'some#page1'\n\n  get :page1, to: 'some#page1'\n  get :page2, to: 'some#page2'\n\nend\n```\n\n**Use CSS animations for fancy page transition animations**\n\nUse Matestack's css classes applied to the wrapping DOM structure of a page in order to add CSS animiations, whenever a page transition is performed. You can even inject a loading state element, enriching your page transition effect.\n\n`app/matestack/some_app/some_layout.rb`\n\n```ruby\nclass SomeApp::SomeLayout \u003c Matestack::Ui::Layout\n\n  def response\n    h1 \"My App\"\n    matestack_vue_js_app do\n      nav do\n        transition path: page1_path do\n          button \"Page 1\"\n        end\n        transition path: page2_path do\n          button \"Page 2\"\n        end\n      end\n      main do\n        div class: \"container\" do\n          page_switch do\n            yield\n          end\n        end\n      end\n    end\n  end\n\n  def loading_state_element\n    div class: 'some-loading-element-styles'\n  end\n\nend\n```\n\n`app/assets/stylesheets/application.scss`\n\n```scss\n.matestack-page-container{\n\n  .matestack-page-wrapper {\n    opacity: 1;\n    transition: opacity 0.2s ease-in-out;\n\n    \u0026.loading {\n      opacity: 0;\n    }\n  }\n\n  .loading-state-element-wrapper{\n    opacity: 0;\n    transition: opacity 0.3s ease-in-out;\n\n    \u0026.loading {\n      opacity: 1;\n    }\n  }\n\n}\n```\n\n## License\n\n`matestack-ui-vuejs` is an Open Source project licensed under the terms of the [MIT license](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatestack%2Fmatestack-ui-vuejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatestack%2Fmatestack-ui-vuejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatestack%2Fmatestack-ui-vuejs/lists"}