Skip to content

Commit 257f7a3

Browse files
committed
title case, converted code
1 parent ff20b65 commit 257f7a3

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

docs/getting-started/quick-start.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,8 @@ end
13181318

13191319
`app/matestack/twitter_clone/posts/index.rb`
13201320

1321+
# todo: matestack_component
1322+
13211323
```ruby
13221324
# ...
13231325

@@ -1579,7 +1581,7 @@ end
15791581
* [x] Click on the transition components
15801582
* [x] Enjoy the fade effects once again :\)
15811583

1582-
And now we do something, what's not possible in Twitter: Editing. Tweets. Inline. In pure Ruby! \(Just because it's nice to showcase that\)
1584+
And now, let's do something that isn't possible in Twitter: Editing. Tweets. Inline. In pure Ruby! \(Just because it's nice to showcase that\)
15831585

15841586
## Inline Editing
15851587

@@ -1597,21 +1599,21 @@ class Components::Post < Matestack::Ui::Component
15971599
requires :post
15981600

15991601
def response
1600-
div class: "mb-3 p-3 rounded shadow-sm", id: "post-#{post.id}" do
1602+
div class: "mb-3 p-3 rounded shadow-sm", id: "post-#{context.post.id}" do
16011603
heading size: 5 do
1602-
plain post.username
1603-
small text: post.created_at.strftime("%d.%m.%Y %H:%M")
1604+
plain context.post.username
1605+
small text: context.post.created_at.strftime("%d.%m.%Y %H:%M")
16041606
end
1605-
toggle hide_on: "edit-post-#{post.id}", show_on: "updated", init_show: true do
1607+
toggle hide_on: "edit-post-#{context.post.id}", show_on: "updated", init_show: true do
16061608
show_partial
16071609
end
1608-
toggle show_on: "edit-post-#{post.id}", hide_on: "updated" do
1610+
toggle show_on: "edit-post-#{context.post.id}", hide_on: "updated" do
16091611
edit_partial
16101612
end
1611-
# paragraph text: post.body, class: "mb-5"
1612-
# action path: like_post_path(post), method: :put do
1613+
# paragraph text: context.post.body, class: "mb-5"
1614+
# action path: like_post_path(context.post), method: :put do
16131615
# button class: "btn btn-light" do
1614-
# plain "Like (#{post.likes_count})"
1616+
# plain "Like (#{context.post.likes_count})"
16151617
# end
16161618
# end
16171619
end
@@ -1620,38 +1622,36 @@ class Components::Post < Matestack::Ui::Component
16201622
private
16211623

16221624
def show_partial
1623-
paragraph text: post.body, class: "mb-5"
1624-
action path: like_post_path(post), method: :put do
1625+
paragraph text: context.post.body, class: "mb-5"
1626+
action path: like_post_path(context.post), method: :put do
16251627
button class: "btn btn-light" do
1626-
plain "Like (#{post.likes_count})"
1628+
plain "Like (#{context.post.likes_count})"
16271629
end
16281630
end
16291631
# onclick emits an event triggering the toggle components to show/hide
16301632
# we use Bootstraps "d-inline" utility class here because onclick renders
16311633
# a block element (will be changed to an inline element in a future release)
1632-
onclick emit: "edit-post-#{post.id}", class: "d-inline" do
1634+
onclick emit: "edit-post-#{context.post.id}", class: "d-inline" do
16331635
button class: "btn btn-link" do
16341636
plain "Edit"
16351637
end
16361638
end
16371639
end
16381640

16391641
def edit_partial
1640-
form form_config_helper do
1642+
matestack_form form_config_helper do
16411643
div class: "mb-3" do
16421644
form_input key: :body, type: :text, placeholder: "What's up?", class: "form-control"
16431645
end
16441646
div class: "mb-3" do
1645-
form_submit do
1646-
button type: :submit, class: "btn btn-primary", text: "Update!"
1647-
end
1647+
button 'submit', type: :submit, class: "btn btn-primary", text: "Update!"
16481648
end
16491649
end
16501650
end
16511651

16521652
def form_config_helper
16531653
{
1654-
for: post, path: post_path(id: post.id), method: :put,
1654+
for: context.post, path: post_path(id: context.post.id), method: :put,
16551655
success: { emit: "updated" },
16561656
failure: { emit: "form_failed" },
16571657
errors: { wrapper: { tag: :div, class: 'invalid-feedback' }, input: { class: 'is-invalid' } }
@@ -1677,7 +1677,7 @@ def update
16771677
if @post.update(post_params)
16781678
ActionCable.server.broadcast('matestack_ui_core', {
16791679
event: "cable__updated_post",
1680-
data: matestack_component(:post_component, post: @post)
1680+
data: post_component(post: @post)
16811681
})
16821682
render json: {
16831683
message: 'Post was successfully updated.'

0 commit comments

Comments
 (0)