Skip to content

Commit 1c4f9b5

Browse files
author
Nils Henning
committed
[WIP][TASK][REFACTOR] update setup documentation
1 parent 8d30ad0 commit 1c4f9b5

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

docs/guides/essential/00_introduction.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
## Guide Assumptions
44

5-
* Required knowledge etc
65
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.
76

87
## What is Matestack?
@@ -33,9 +32,9 @@ To enable you to write your apps, pages and components in Ruby, matestack provid
3332

3433
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.
3534

36-
#### `Matestack::Ui::VueComponent`'s
35+
#### `Matestack::Ui::VueJsComponent`'s
3736

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.
3938

4039
## Recap & outlook
4140

docs/guides/essential/01_setup.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,68 @@ We successfully rendered our first page displaying "Hello World" without writing
167167

168168
## Create our first app
169169

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+
class Demo::App < Matestack::Ui::App
190+
191+
def response
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+
class DemoController < ApplicationController
210+
matestack_app Demo::App
211+
212+
def first_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+
171232

172233
Within your `app` directory, create a directory called `matestack` - this is where `matestack` **apps**, **pages** and, later on, **components**, will live.
173234

0 commit comments

Comments
 (0)