You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/essential/00_introduction.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,6 @@
2
2
3
3
## Guide Assumptions
4
4
5
-
* Required knowledge etc
6
5
This guide is designed for Ruby on Rails beginners, advanced and experienced developers. We assume that you have basic knowledge about how Ruby on Rails routing and action controllers work. In this series of guides we will cover the basic principles and usage of matestack and further down the road introduce more complex principles and example use cases.
7
6
8
7
## What is Matestack?
@@ -33,9 +32,9 @@ To enable you to write your apps, pages and components in Ruby, matestack provid
33
32
34
33
For nearly all existing HTML5 Tags there is a component in order to create a ui element with this tag. Visit the [components API documentation](docs/components/) for more information about `Matestack::Ui::Component`'s.
35
34
36
-
#### `Matestack::Ui::VueComponent`'s
35
+
#### `Matestack::Ui::VueJsComponent`'s
37
36
38
-
VueComponents are more complex components. These always have a Vue.js counterpart and enable easy development of dynamic ui elements which would usually require you to write javascript code. VueComponents provide an abstraction so you don't have to write javascript code and instead create rich interfaces in Ruby. Visit the [components API documentation](docs/components/) for more information about `Matestack::Ui::VueComponent`'s.
37
+
VueJsComponents are more complex components. These always have a Vue.js counterpart and enable easy development of dynamic ui elements which would usually require you to write javascript code. VueJsComponents provide an abstraction so you don't have to write javascript code and instead create rich interfaces in Ruby. Visit the [components API documentation](docs/components/) for more information about `Matestack::Ui::VueJsComponent`'s.
Copy file name to clipboardExpand all lines: docs/guides/essential/01_setup.md
+62-1Lines changed: 62 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,7 +167,68 @@ We successfully rendered our first page displaying "Hello World" without writing
167
167
168
168
## Create our first app
169
169
170
-
TODO write create app chapter
170
+
Lets say we want to add a header with navigation links to our first page and upcoming pages. In Rails we would implement this navigation inside our layout, so we don't repeat ourselfs by adding the navigation in every single view. With Matestack we have so called apps which replace the concept of Rails layouts. In order to add a navigation around our page similiar to a rails layout we will create an app called `Demo::App`.
171
+
But where to put this app. We recommend you structure your apps and pages as follows:
172
+
173
+
In our example we want to have a demo app and pages rendered inside this app. That means that `Demo` is our namespace for those. Therefore we put our app and pages inside a folder called `demo`. We move our first page inside this demo folder because it should belong to the demo app. Since we can have many different pages we put all pages in a subfolder called `pages`.
174
+
175
+
```
176
+
app/matestack/
177
+
|
178
+
└───demo/
179
+
│ │ app.rb (`Demo::App`)
180
+
│ └───pages/
181
+
│ │ │ first_page.rb (`Demo::Pages::FirstPage`)
182
+
```
183
+
184
+
Because we moved our first page inside `demo/pages` we need to update the class name accordingly, matching the Rails naming conventions. Update the class name of your first page to `Demo::Pages::FirstPage`.
185
+
186
+
Now we create the demo app by creating a file called `app.rb` inside `app/matestack/demo` and add the following content. We will take a closer look at what is happening down below.
187
+
188
+
```ruby
189
+
classDemo::App < Matestack::Ui::App
190
+
191
+
defresponse
192
+
header do
193
+
heading size:1, text:'Demo App'
194
+
end
195
+
main do
196
+
yield_page
197
+
end
198
+
end
199
+
200
+
end
201
+
```
202
+
203
+
What is happening here. An app needs to inherit from `Matestack::Ui::App` and define a response method like a page. `header, heading, main` are all matestack component helper like `div` which we used in our first page. The `yield_page` call tells the app where the page content should be rendered. In this case inside a `main` tag beneath the `header` tag.
204
+
205
+
The last thing we need to do in order to render our app around our page is to tell the controller to use the app as a layout. We do this by adding `matestack_app Demo::App` inside our controller, which should now look like this:
206
+
207
+
208
+
```ruby
209
+
classDemoController < ApplicationController
210
+
matestack_app Demo::App
211
+
212
+
deffirst_page
213
+
render FirstPage
214
+
end
215
+
216
+
end
217
+
```
218
+
219
+
If we visit [localhost:3000](http://localhost:3000/) now, we can see that our app is rendered around our first page and the "Hello world!" is shown below the heading "Demo App".
220
+
221
+
222
+
----
223
+
Refactor the below part and remove doubled stuff!
224
+
225
+
Next steps:
226
+
- add a second page
227
+
- introduce a navigation with transition
228
+
- describe the benefits of transitions inside an app ;)
229
+
----
230
+
231
+
171
232
172
233
Within your `app` directory, create a directory called `matestack` - this is where `matestack`**apps**, **pages** and, later on, **components**, will live.
0 commit comments