|
| 1 | +# Base API |
| 2 | + |
| 3 | +matestack's UI concept consists of three major building blocks: `component`, `page` and `app`. |
| 4 | +A component is a reusable UI-Element. A `page` contains multiple `components` |
| 5 | +and represents the main content on a specific view. Multiple |
| 6 | +`pages` can be wrapped in an `app`, sharing a layout for example. |
| 7 | + |
| 8 | +If you think of an UI, a small `component` may be a simple button. A bigger `component` may |
| 9 | +use three other components, including an image-component, a text-component and this |
| 10 | +button-component to display a product-image, -description and a "more details" button. |
| 11 | + |
| 12 | +A `component` is the smallest UI-Element and can consist of other components. matestack |
| 13 | +provides a wide set of core components, which enables you to easily build your UI. |
| 14 | +You can build your own components as well! |
| 15 | + |
| 16 | +20 of these product-components should be displayed on a specific `page` of your Web-App. |
| 17 | +A `page` therefore defines, that 20 product-components should be used and how they should |
| 18 | +be aligned to each other. |
| 19 | + |
| 20 | +A `page` composes multiple components in order to display the main content. |
| 21 | + |
| 22 | +Usually a `page` should be wrapped in a layout. A layout may define a navigation-menu, |
| 23 | +header and footer for example. In matestack, a layout is defined in an `app`. Multiple |
| 24 | +`pages` belong to one matestack `app`, which can perform dynamic transitions |
| 25 | +between its `pages`. A Rails application may host multiple matestack `apps`: One could |
| 26 | +be the Online-Shop-App, displaying products on multiple `pages`. The other could be |
| 27 | +an Backoffice-App managing all kind of data and processes. |
| 28 | + |
| 29 | +A matestack `app` manages multiple `pages` in order to fullfill one specific purpose of your organization. |
| 30 | + |
| 31 | +## Components |
| 32 | + |
| 33 | +### Types of components |
| 34 | + |
| 35 | +Matestack uses three different types of components: |
| 36 | + |
| 37 | +* Component |
| 38 | +* VueJsComponent |
| 39 | +* IsolatedComponent |
| 40 | + |
| 41 | +All components define their UI within a `response` method, written in Ruby. |
| 42 | + |
| 43 | +#### Component |
| 44 | + |
| 45 | +The simplest type of a component inherits from `Matestack::Ui::Component` and is |
| 46 | +meant to be used for simple rendering of content and other components. Matestack |
| 47 | +will simply render the UI defined within the `response` method without any |
| 48 | +wrapping elements by default. |
| 49 | + |
| 50 | +[Read more](/docs/api/base/component.md) |
| 51 | + |
| 52 | +#### VueJsComponent |
| 53 | + |
| 54 | +In order to equip a Ruby component with some JavaScript, we associate |
| 55 | +the Ruby component with a VueJs JavaScript component. The Ruby component therefore needs to inherit |
| 56 | +from `Matestack::Ui::VueJsComponent`. Matestack will then render a HTML component |
| 57 | +tag with some special attributes and props around the response defined in the |
| 58 | +Ruby component. The VueJs JavaScript component (defined in a separate JavaScript file and |
| 59 | +managed via Sprockets or Webpacker) will treat the response of the Ruby |
| 60 | +component as its template. |
| 61 | + |
| 62 | +[Read more](/docs/api/base/vue_js_component.md) |
| 63 | + |
| 64 | +#### IsolatedComponent |
| 65 | + |
| 66 | +Components inheriting from `Matestack::Ui::IsolatedComponent` are designed for |
| 67 | +isolated, asynchronous rendering. Like seen at VueJsComponents, Matestack will |
| 68 | +render a HTML component tag with some special attributes and props around the |
| 69 | +response defined in the Ruby component. Additionally, Matestack wraps the |
| 70 | +component's `response` with some DOM elements enabling asynchronous loading |
| 71 | +state animations. |
| 72 | + |
| 73 | +[Read more](/docs/api/base/isolated_component.md) |
| 74 | + |
| 75 | +### Core Components |
| 76 | + |
| 77 | +Matestack ships a lot of core components. A lot of them are simple `Matestack::Ui::Component`s |
| 78 | +and representing HTML tags in order to enable the developer to create html markup |
| 79 | +with pure Ruby. Some other core components are `Matestack::Ui::VueJsComponent`s shipping |
| 80 | +predefined dynamic UI behavior. |
| 81 | + |
| 82 | +See [here](/docs/api/components/core/README.md) for a list of available `core components`. |
| 83 | + |
| 84 | +### Custom Components |
| 85 | + |
| 86 | +By definition, custom components only live within your application. |
| 87 | +To use them on your `apps` and `pages`, you need to register them in a component |
| 88 | +registry file. Custom components can inherit from `Matestack::Ui::Component`, |
| 89 | +`Matestack::Ui::VueJsComponent` or `Matestack::Ui::IsolatedComponent` depending on |
| 90 | +the specific usecase. |
| 91 | + |
| 92 | +[Read more](/docs/api/components/custom/README.md) |
| 93 | + |
| 94 | +## Pages |
| 95 | + |
| 96 | +A page orchestrates components within its response method. A Rails controller |
| 97 | +action references a page (and its corresponding app) in its render call. Thus a |
| 98 | +matestack page substitutes a typical Rails view. |
| 99 | + |
| 100 | +A page is a special kind of `Matestack::Ui::VueJsComponent`. Matestack will |
| 101 | +therefore wrap the UI defined in the `response` method with some markup enabling |
| 102 | +dynamic UI behavior and CSS styling. |
| 103 | + |
| 104 | +Learn more about [pages](/docs/api/base/page.md) |
| 105 | + |
| 106 | +## Apps |
| 107 | + |
| 108 | +An app defines a layout within its `response` method and uses the `yield_page` |
| 109 | +method to yield the content of a page in its layout. |
| 110 | + |
| 111 | +An app is a special kind of `Matestack::Ui::VueJsComponent`. Matestack will |
| 112 | +therefore wrap the UI defined in the `response` method with some markup enabling |
| 113 | +dynamic UI behavior and CSS styling. |
| 114 | + |
| 115 | +The app ships a `Vuex store` and `Vue.js event hub`, which are used by core vuejs |
| 116 | +components and can optionally be used by custom vuejs components in order to |
| 117 | +trigger events, manage client side date and communicate between components. |
| 118 | + |
| 119 | +Learn more about [apps](/docs/api/base/app.md) |
0 commit comments