Skip to content

Commit 2e1cdc6

Browse files
author
Nils Henning
committed
[TASK] extend basic building blocks guide
1 parent a9dc582 commit 2e1cdc6

File tree

9 files changed

+268
-28
lines changed

9 files changed

+268
-28
lines changed

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)
File renamed without changes.
File renamed without changes.
File renamed without changes.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ markup. See below, how you can pass in data to the VueJs JavaScript component.
129129
### Same as component
130130

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

135135
### Referencing the VueJs JavaScript component
@@ -216,9 +216,9 @@ class SomeComponent < Matestack::Ui::VueJsComponent
216216
end
217217
```
218218

219-
### Eventhub
219+
### Event Hub
220220

221-
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.
222222

223223
#### Emitting events
224224

File renamed without changes.

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!

docs/api/000-base/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ meant to be used for simple rendering of content and other components. Matestack
4747
will simply render the UI defined within the `response` method without any
4848
wrapping elements by default.
4949

50-
[Read more](/docs/api/000-base/component.md)
50+
[Read more](/docs/api/000-base/20-component.md)
5151

5252
#### VueJsComponent
5353

@@ -59,7 +59,7 @@ Ruby component. The VueJs JavaScript component (defined in a separate JavaScript
5959
managed via Sprockets or Webpacker) will treat the response of the Ruby
6060
component as its template.
6161

62-
[Read more](/docs/api/000-base/vue_js_component.md)
62+
[Read more](/docs/api/000-base/30-vue_js_component.md)
6363

6464
#### IsolatedComponent
6565

@@ -70,7 +70,7 @@ response defined in the Ruby component. Additionally, Matestack wraps the
7070
component's `response` with some DOM elements enabling asynchronous loading
7171
state animations.
7272

73-
[Read more](/docs/api/000-base/isolated_component.md)
73+
[Read more](/docs/api/000-base/40-isolated_component.md)
7474

7575
### Core Components
7676

@@ -101,7 +101,7 @@ A page is a special kind of `Matestack::Ui::VueJsComponent`. Matestack will
101101
therefore wrap the UI defined in the `response` method with some markup enabling
102102
dynamic UI behavior and CSS styling.
103103

104-
Learn more about [pages](/docs/api/000-base/page.md)
104+
Learn more about [pages](/docs/api/000-base/10-page.md)
105105

106106
## Apps
107107

@@ -116,4 +116,4 @@ The app ships a `Vuex store` and `Vue.js event hub`, which are used by core vuej
116116
components and can optionally be used by custom vuejs components in order to
117117
trigger events, manage client side date and communicate between components.
118118

119-
Learn more about [apps](/docs/api/000-base/app.md)
119+
Learn more about [apps](/docs/api/000-base/10-app.md)

0 commit comments

Comments
 (0)