Skip to content

Commit 345e167

Browse files
Merge pull request #214 from Manukam/add-s-tag
Add <s> tag to core components - good work, thanks a million!
2 parents 565e6ca + a808cbc commit 345e167

File tree

9 files changed

+407
-12
lines changed

9 files changed

+407
-12
lines changed

.github/pull_request_template.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
**Please make sure to target feature and bugfix requests to develop branch**
2+
13
## Issue https://github.com/basemate/matestack-ui-core/issues/XXX: Short description here
24

35
### Changes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dynamic Web-App.
2121

2222
### Installation:
2323

24-
Click here to see how you can add Matestack UI to your existing Rails application: [Installation Guide](./docs/install)
24+
Click here to see how you can add Matestack UI to your existing Rails application: [Installation Guide](https://www.matestack.org/docs/install)
2525

2626
### Features:
2727

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%s{@tag_attributes}
2+
- if options[:text].nil? && block_given?
3+
= yield
4+
- else
5+
= options[:text]

app/concepts/matestack/ui/core/s/s.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Matestack::Ui::Core::S
2+
class S < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end
6+

docs/components/s.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# matestack core component: s
2+
3+
Show [specs](/spec/usage/components/s_spec.rb)
4+
5+
The HTML `<s>` tag implemented in ruby.
6+
7+
## Parameters
8+
9+
This component can take 3 optional configuration params and optional content.
10+
11+
#### # id (optional)
12+
Expects a string with all ids the s tag should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the s tag should have.
16+
17+
#### # text (optional)
18+
Expects a string with the text that s go into the `<s>` tag.
19+
20+
## Example 1
21+
Specifying the text directly
22+
23+
```ruby
24+
s id: "foo", class: "bar" text: "Hello World"
25+
```
26+
27+
returns
28+
29+
```html
30+
<s id="foo" class="bar">Hello World</s>
31+
```
32+
33+
## Example 2
34+
Rendering a content block between the `<s>` tags
35+
36+
```ruby
37+
s id: "foo", class: "bar" do
38+
plain "Hello World"
39+
end
40+
```
41+
42+
returns
43+
44+
```html
45+
<s id="foo" class="bar">Hello World</s>
46+
```

guides/hello_world.md renamed to guides/10_hello_world.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# Hello World Guide
2-
31
## Getting from zero to one, quickly
42

53
*Prerequisite:* We assume you have read and followed the [installation guide](/docs/install), either in a new or existing Rails application.
64

75
### Creating your first Matestack app
86

7+
*A matestack `app` is something like a classic Rails `layout`. It will wrap `pages`.*
8+
99
Within your `app/matestack/` folder, create a folder called `apps` and there,
1010
we will start by adding a file called `my_app.rb`!
1111
Put the following code inside it:
1212

13+
`app/matestack/apps/my_app.rb`
14+
1315
```ruby
1416
class Apps::MyApp < Matestack::Ui::App
1517

@@ -27,15 +29,19 @@ class Apps::MyApp < Matestack::Ui::App
2729
end
2830
```
2931

30-
Great! Now we have our first Matestack app inside our Rails application. It can have many pages, and adding a first one is our next step!
32+
Great! Now we have our first matestack app inside our Rails application. It can wrap many pages, and adding a first one is our next step!
3133

32-
### Creating your first Matestack page
34+
### Creating your first matestack page
35+
36+
*A matestack `page` is something like a classic Rails `view`. It will be wrapped by an `app`.*
3337

3438
Now, within `app/matestack/`, create another folder called `pages/`, and put a folder for our app in it (`my_app`).
3539
In `app/matestack/pages/my_app/`, create a file called `my_example_page.rb` for our first view.
3640

3741
Notice how we describe our User Interface with elements that resemble `HTML tags` - but we can also write Ruby just the way we want to!
3842

43+
`app/matestack/pages/my_app/my_example_page.rb`
44+
3945
```ruby
4046
class Pages::MyApp::MyExamplePage < Matestack::Ui::Page
4147

@@ -54,7 +60,7 @@ class Pages::MyApp::MyExamplePage < Matestack::Ui::Page
5460
end
5561
```
5662

57-
After creating this example page for our example Matestack app, we're nearly finished. But as you may have guessed, we've yet to prepare the routes and the controller!
63+
After creating this example page for our example matestack app, we're nearly finished. But as you may have guessed, we've yet to prepare the routes and the controller!
5864

5965
### Setting up router and controller
6066

@@ -63,7 +69,7 @@ This is straightforward and just works *the Rails way*.
6369
Inside `config/routes.rb`, add a route for the example page:
6470

6571
```ruby
66-
scope :my_app do
72+
Rails.application.routes.draw do
6773
get 'my_example_page', to: 'my_app#my_example_page'
6874
end
6975
```
@@ -74,19 +80,18 @@ In `app/controllers/`, create a file called `my_app_controller.rb` and define ou
7480
class MyAppController < ApplicationController
7581

7682
# if it is not already included in the ApplicationController
77-
# add the Matestack ApplicationHelper here by
78-
# uncommenting the line below
79-
# include Matestack::Ui::Core::ApplicationHelper
83+
include Matestack::Ui::Core::ApplicationHelper
8084

8185
def my_example_page
8286
responder_for(Pages::MyApp::MyExamplePage)
8387
end
88+
8489
end
8590
```
8691

8792
### Test it
8893

89-
All we got left to do is to start Rails by entering `rails server` in the console and then head to [localhost:3000/my_app/my_example_page](http://localhost:3000/my_app/my_example_page) in our favorite browser!
94+
All we got left to do is to start Rails by entering `rails server` in the console and then head to [localhost:3000/my_example_page](http://localhost:3000/my_example_page) in our favorite browser!
9095

9196
### Summary
9297

0 commit comments

Comments
 (0)