Skip to content

Commit 5adafed

Browse files
author
Nils Henning
committed
Merge branch '20200914_improve-and-extend-documentation'
2 parents 50bc0de + f2eb488 commit 5adafed

File tree

144 files changed

+1643
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+1643
-341
lines changed

CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ app/matestack/
121121
and your corresponding controllers could look like this:
122122

123123
`app/controllers/admin_controller.rb`
124+
124125
```ruby
125126
class AdminController < ApplicationController
126127
include Matestack::Ui::Core::ApplicationHelper
@@ -137,6 +138,7 @@ end
137138
```
138139

139140
`app/controllers/website_controller.rb`
141+
140142
```ruby
141143
class WebsiteController < ApplicationController
142144
include Matestack::Ui::Core::ApplicationHelper
@@ -181,6 +183,7 @@ This auto resolving is being completely removed in the `1.0.0` release. All comp
181183
*Core components*
182184

183185
`CORE_ROOT/lib/matestack/ui/core/components.rb`
186+
184187
```ruby
185188
module Matestack::Ui::Core::Components
186189
#...
@@ -202,6 +205,7 @@ The registered DSL method `some_new_component` does not have to match the compon
202205
Create a registry module like:
203206

204207
`APP_ROOT/app/matestack/components/registry.rb`
208+
205209
```ruby
206210
module Components::Registry
207211

@@ -573,7 +577,7 @@ We reworked the form components quite a bit:
573577
- options passed as hashes in to `form_select`, `form_radio` and `form_checkbox` are now expected to be { label_value: input_value } and thus the other way around. Until 0.7.6 it was { input_value: label_value }
574578
- and added a lot of new features, such as customizing the error rendering.
575579

576-
We invested a lot of time to improve the `form` API docs found [here](/docs/api/components/form.md).
580+
We invested a lot of time to improve the `form` API docs found [here](/docs/api/100-components/form.md).
577581

578582
- [ ] Please make sure to read through the docs and migrate your forms accordingly!
579583

@@ -708,6 +712,7 @@ To render existing rails views inside your components or pages, use the new `rai
708712
You can render existing partials and views with this helper anywhere in your app. For further information read the `rails_view` documentation.
709713

710714
Let's say you have an old view file in `app/views/example/partial.html.erb`
715+
711716
```html
712717
<p>An example text in a Rails view</p>
713718
```
@@ -1075,13 +1080,15 @@ none
10751080
***OLD:***
10761081

10771082
`app/matestack/app/example_app.rb`
1083+
10781084
```ruby
10791085
class Apps::ExampleApp < App::Cell::App end
10801086
```
10811087

10821088
***NEW:***
10831089

10841090
`app/matestack/app/example_app.rb`
1091+
10851092
```ruby
10861093
class Apps::ExampleApp < Matestack::Ui::App end
10871094
```
@@ -1091,13 +1098,15 @@ class Apps::ExampleApp < Matestack::Ui::App end
10911098
***OLD:***
10921099

10931100
`app/matestack/pages/example_app/example_page.rb`
1101+
10941102
```ruby
10951103
class Pages::ExampleApp::ExamplePage < Page::Cell::Page end
10961104
```
10971105

10981106
***NEW:***
10991107

11001108
`app/matestack/pages/example_app/example_page.rb`
1109+
11011110
```ruby
11021111
class Pages::ExampleApp::ExamplePage < Matestack::Ui::Page end
11031112
```
@@ -1107,13 +1116,15 @@ class Pages::ExampleApp::ExamplePage < Matestack::Ui::Page end
11071116
***OLD:***
11081117

11091118
`app/matestack/components/card/cell/card.rb`
1119+
11101120
```ruby
11111121
class Components::Card::Cell::Card < Component::Cell::Static end
11121122
```
11131123

11141124
***NEW:***
11151125

11161126
`app/matestack/components/card.rb`
1127+
11171128
```ruby
11181129
class Components::Card < Matestack::Ui::StaticComponent end
11191130
```
@@ -1123,23 +1134,27 @@ class Components::Card < Matestack::Ui::StaticComponent end
11231134
***OLD:***
11241135

11251136
`app/matestack/components/card/cell/card.rb`
1137+
11261138
```ruby
11271139
class Components::Card::Cell::Card < Component::Cell::Dynamic end
11281140
```
11291141

11301142
`app/matestack/components/card/cell/card.js`
1143+
11311144
```javascript
11321145
MatestackUiCore.Vue.component('custom-card-cell', { ... });
11331146
```
11341147

11351148
***NEW:***
11361149

11371150
`app/matestack/components/card.rb`
1151+
11381152
```ruby
11391153
class Components::Card < Matestack::Ui::DynamicComponent end
11401154
```
11411155

11421156
`app/matestack/components/card.js`
1157+
11431158
```javascript
11441159
MatestackUiCore.Vue.component('custom-card', { ... }); //no -cell postfix
11451160
```
@@ -1149,6 +1164,7 @@ MatestackUiCore.Vue.component('custom-card', { ... }); //no -cell postfix
11491164
***OLD:***
11501165

11511166
`app/matestack/pages/example_app/example_page.rb`
1167+
11521168
```ruby
11531169
class Pages::ExampleApp::ExamplePage < Matestack::Ui::Page
11541170

@@ -1166,6 +1182,7 @@ end
11661182
***NEW:***
11671183

11681184
`app/matestack/pages/example_app/example_page.rb`
1185+
11691186
```ruby
11701187
class Pages::ExampleApp::ExamplePage < Matestack::Ui::Page
11711188

@@ -1197,6 +1214,7 @@ app/concepts/matestack/ui/core
11971214
```
11981215

11991216
`app/concepts/matestack/ui/core/div/div.rb`
1217+
12001218
```ruby
12011219
module Matestack::Ui::Core::Div
12021220
class Div < Matestack::Ui::Core::Component::Static
@@ -1213,6 +1231,7 @@ We also removed the `Cell` module (`cell` folder) and the separate `js` and `vie
12131231
Last module name and class name of CORE components have to be the same. That doesn't apply for CUSTOM components:
12141232

12151233
`app/matestack/pages/example_app/example_page.rb`
1234+
12161235
```ruby
12171236
class Pages::ExampleApp::ExamplePage < Matestack::Ui::Page
12181237

@@ -1254,6 +1273,7 @@ Scoping all core components within `Matestack::Ui::Core` is reflected in differe
12541273
Example: `async` core component
12551274

12561275
`app/concepts/matestack/ui/core/async`
1276+
12571277
```javascript
12581278
//old
12591279
Vue.component('async-cell', componentDef)
@@ -1278,6 +1298,7 @@ ADDON_ENGINE_ROOT/app/concepts/matestack/ui/materialize
12781298
```
12791299

12801300
`ADDON_ENGINE_ROOT/app/concepts/matestack/ui/materialize/row/row.rb`
1301+
12811302
```ruby
12821303
module Matestack::Ui::Materialize::Row
12831304
class Row < Matestack::Ui::Core::Component::Static
@@ -1296,6 +1317,7 @@ end
12961317
Usage:
12971318

12981319
`app/matestack/pages/example_app/example_page.rb`
1320+
12991321
```ruby
13001322
class Pages::ExampleApp::ExamplePage < Matestack::Ui::Page
13011323

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
matestack-ui-core (1.0.0.rc.1)
4+
matestack-ui-core (1.0.0)
55
cells-haml
66
cells-rails
77
haml
@@ -233,7 +233,7 @@ GEM
233233
activesupport (>= 4.2)
234234
rack-proxy (>= 0.6.1)
235235
railties (>= 4.2)
236-
websocket-driver (0.7.2)
236+
websocket-driver (0.7.3)
237237
websocket-extensions (>= 0.1.0)
238238
websocket-extensions (0.1.5)
239239
xpath (3.2.0)

docs/api/1-base/app.md renamed to docs/api/000-base/00-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,4 @@ and during async page request triggered via transition:
155155

156156
You can use the `loading` class and your loading state element to implement CSS based loading state effects.
157157

158-
For more informations on transitions, visit [transitions](/docs/api/2-components/transition.md)
158+
For more informations on transitions, visit [transitions](/docs/api/100-components/transition.md)
File renamed without changes.

docs/api/1-base/component.md renamed to docs/api/000-base/20-component.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ components and custom components are registered slightly different:
1515
Create a registry module like:
1616

1717
`APP_ROOT/app/matestack/components/registry.rb`
18+
1819
```ruby
1920
module Components::Registry
2021

@@ -52,6 +53,7 @@ will be available without having to restart the server.
5253
### Core component registry
5354

5455
`CORE_ROOT/lib/matestack/ui/core/components.rb`
56+
5557
```ruby
5658
module Matestack::Ui::Core::Components
5759
#...

docs/api/1-base/vue_js_component.md renamed to docs/api/000-base/30-vue_js_component.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ A VueJs component is defined by two files. A Ruby file and a JavaScript file:
1717
Within the Ruby file, the Ruby class inherits from `Matestack::Ui::VueJsComponent`:
1818

1919
`app/matestack/components/some_component.rb`
20+
2021
```ruby
2122
class SomeComponent < Matestack::Ui::VueJsComponent
2223

@@ -37,6 +38,7 @@ one root element! Disregarding this rule will lead to Vue.js errors in the brows
3738
This Ruby class has to be registered like all other components:
3839

3940
`app/matestack/components/registry.rb`
41+
4042
```ruby
4143
module Components::Registry
4244
Matestack::Ui::Core::Component::Registry.register_components(
@@ -51,6 +53,7 @@ end
5153
The VueJs JavaScript component is defined in a separate JavaScript file:
5254

5355
`app/matestack/components/some_component.js`
56+
5457
```javascript
5558
MatestackUiCore.Vue.component('some-component', {
5659
mixins: [MatestackUiCore.componentMixin],
@@ -126,7 +129,7 @@ markup. See below, how you can pass in data to the VueJs JavaScript component.
126129
### Same as component
127130

128131
The basic VueJs Ruby component API is the same as described within the
129-
[component API documenation](/docs/api/1-base/component.md). The options below extend
132+
[component API documenation](/docs/api/000-base/20-component.md). The options below extend
130133
this API.
131134

132135
### Referencing the VueJs JavaScript component
@@ -135,6 +138,7 @@ As seen above, the VueJs JavaScript component name has to be referenced in the V
135138
Ruby component using the `vue_js_component_name` class method
136139

137140
`app/matestack/components/some_component.rb`
141+
138142
```ruby
139143
class SomeComponent < Matestack::Ui::VueJsComponent
140144

@@ -151,6 +155,7 @@ the component tag. In order to fill in some date there, you should use the `setu
151155
method like this:
152156

153157
`app/matestack/components/some_component.rb`
158+
154159
```ruby
155160
class SomeComponent < Matestack::Ui::VueJsComponent
156161

@@ -176,6 +181,7 @@ within the VueJs JavaScript component.
176181
### Component mixin
177182

178183
`app/matestack/components/some_component.js`
184+
179185
```javascript
180186
MatestackUiCore.Vue.component('some-component', {
181187
mixins: [MatestackUiCore.componentMixin],
@@ -197,6 +203,7 @@ this.componentConfig["some_serverside_data"]
197203
if implemented like
198204

199205
`app/matestack/components/some_component.rb`
206+
200207
```ruby
201208
class SomeComponent < Matestack::Ui::VueJsComponent
202209

@@ -209,13 +216,14 @@ class SomeComponent < Matestack::Ui::VueJsComponent
209216
end
210217
```
211218

212-
### Eventhub
219+
### Event Hub
213220

214-
Matestack offers an eventhub, which can be used to communicate between components.
221+
Matestack offers an event hub, which can be used to communicate between components.
215222

216223
#### Emitting events
217224

218225
`app/matestack/components/some_component.js`
226+
219227
```javascript
220228
MatestackUiCore.Vue.component('some-component', {
221229
mixins: [MatestackUiCore.componentMixin],
@@ -233,6 +241,7 @@ Use `MatestackUiCore.matestackEventHub.$emit(EVENT_NAME, OPTIONAL PAYLOAD)`
233241
#### Receiving events
234242

235243
`app/matestack/components/some_component.js`
244+
236245
```javascript
237246
MatestackUiCore.Vue.component('some-component', {
238247
mixins: [MatestackUiCore.componentMixin],

docs/api/1-base/isolated_component.md renamed to docs/api/000-base/40-isolated_component.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Furthermore isolated components have to be authorized independently. See below.
6161

6262
## Differences to the `async` component
6363

64-
The [`async` component](docs/api/2-components/core/async.md) offers pretty similar
64+
The [`async` component](docs/api/100-components/core/async.md) offers pretty similar
6565
functionalities enabling you to define asynchronous rendering. The important difference
6666
is that rerendering an `async` component requires resolving the whole page on the serverside,
6767
which can be performance critical on complex pages. An isolated component bypasses
@@ -112,13 +112,13 @@ rendered within a secured context.
112112
That's why we enforce the usage of the `authorized?` method to make sure, all isolated
113113
components take care of their authorization themselves.
114114

115-
If `authorized?` return `true`, the component will be rendered. If it returns `false`,
115+
If `authorized?` returns `true`, the component will be rendered. If it returns `false`,
116116
the component will not be rendered.
117117

118118
A public isolated component therefore needs an `authorized?` method simply returning `true`.
119119

120120
You can create your own isolated base components with their `authorized` methods
121-
for your use cases and thus keep your code DRY
121+
for your use cases and thus keep your code DRY.
122122

123123
### Options
124124

docs/api/000-base/50-event_hub.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
### Event Hub
2+
3+
Matestack offers an event hub, which can be used to communicate between components.
4+
5+
#### Emitting events
6+
7+
`app/matestack/components/some_component.js`
8+
9+
```javascript
10+
MatestackUiCore.Vue.component('some-component', {
11+
mixins: [MatestackUiCore.componentMixin],
12+
data() {
13+
return {}
14+
},
15+
mounted(){
16+
MatestackUiCore.matestackEventHub.$emit("some-event", { some: "optional data" })
17+
}
18+
})
19+
```
20+
21+
Use `MatestackUiCore.matestackEventHub.$emit(EVENT_NAME, OPTIONAL PAYLOAD)`
22+
23+
#### Receiving events
24+
25+
`app/matestack/components/some_component.js`
26+
27+
```javascript
28+
MatestackUiCore.Vue.component('some-component', {
29+
mixins: [MatestackUiCore.componentMixin],
30+
data() {
31+
return {}
32+
},
33+
methods: {
34+
reactToEvent(payload){
35+
console.log(payload)
36+
}
37+
},
38+
mounted(){
39+
MatestackUiCore.matestackEventHub.$on("some-event", this.reactToEvent)
40+
},
41+
beforeDestroy: function() {
42+
matestackEventHub.$off("some-event", this.reactToEvent)
43+
}
44+
})
45+
```
46+
47+
Make sure to cancel the event listener within the `beforeDestroy` hook!

0 commit comments

Comments
 (0)