Skip to content

Commit dfe8b09

Browse files
Add title option to link component
1 parent ff7f417 commit dfe8b09

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def setup
99
"id": component_id,
1010
"method": options[:method],
1111
"target": options[:target] ||= nil,
12-
"href": link_path
12+
"href": link_path,
13+
"title": options[:title]
1314
})
1415
end
1516

docs/components/link.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ The HTTP request method the link should implement.
2828
#### # target (optional, default is nil)
2929
Specify where to open the linked document.
3030

31+
#### # title (optional)
32+
Specify a title for the link (shown on mouseover).
33+
3134
## Example 1
3235
This example renders a simple link within a `<div`-tag
3336

@@ -50,7 +53,7 @@ This example renders a link without a specific link-text, so it wraps the rest o
5053

5154
```ruby
5255
div id: "foo", class: "bar" do
53-
link path: "https://matestack.org" do
56+
link path: "https://matestack.org", title: "The matestack website" do
5457
plain "Here"
5558
end
5659
end
@@ -59,7 +62,7 @@ end
5962
returns
6063

6164
```html
62-
<div id="foo" class="bar">
65+
<div id="foo" class="bar" title="The matestack website">
6366
<a href="https://matestack.org">Here</a>
6467
</div>
6568
```

spec/usage/components/link_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ExamplePage < Matestack::Ui::Page
3737
def response
3838
components {
3939
div id: "foo", class: "bar" do
40-
link path: "https://matestack.org" do
40+
link path: "https://matestack.org", title: "The matestack website" do
4141
plain 'here'
4242
end
4343
end
@@ -52,7 +52,7 @@ def response
5252
static_output = page.html
5353

5454
expected_static_output = <<~HTML
55-
<div id="foo" class="bar">
55+
<div id="foo" class="bar" title="The matestack website">
5656
<a href="https://matestack.org">here</a>
5757
</div>
5858
HTML

0 commit comments

Comments
 (0)