Skip to content

Commit 49f89bd

Browse files
Merge branch 'develop' into add_object_component
2 parents cfc2b9d + dbb41ef commit 49f89bd

File tree

19 files changed

+1876
-881
lines changed

19 files changed

+1876
-881
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
%area{@tag_attributes}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Matestack::Ui::Core::Area
2+
class Area < Matestack::Ui::Core::Component::Static
3+
def setup
4+
@tag_attributes.merge!({
5+
alt: options[:alt],
6+
coords: options[:coords].join(','),
7+
download: options[:download],
8+
href: options[:href],
9+
hreflang: options[:hreflang],
10+
media: options[:media],
11+
rel: options[:rel],
12+
shape: options[:shape],
13+
target: options[:target],
14+
type: options[:type]
15+
})
16+
end
17+
end
18+
end

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def setup
66
src: ActionController::Base.helpers.asset_path(options[:path]),
77
height: options[:height],
88
width: options[:width],
9+
usemap: options[:usemap],
910
alt: options[:alt]
1011
})
1112
end

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%map{@tag_attributes}
2+
- if block_given?
3+
= yield
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Matestack::Ui::Core::Map
2+
class Map < Matestack::Ui::Core::Component::Static
3+
REQUIRED_KEYS = [:name]
4+
5+
def setup
6+
@tag_attributes.merge!({
7+
name: options[:name]
8+
})
9+
end
10+
end
11+
end

builder/yarn.lock

Lines changed: 1566 additions & 853 deletions
Large diffs are not rendered by default.

docs/components/area.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# matestack core component: Area
2+
3+
Tested within the [map specs](/spec/usage/components/map_spec.rb).
4+
5+
The HTML `<area>` tag implemented in Ruby.
6+
7+
## Parameters
8+
This component takes up to 10 optional configuration params. It is meant to be used within the `<map>` component.
9+
10+
#### # alt (optional)
11+
Expects a string that specifies an alternate text for the `<area>`. Required if the href attribute is present.
12+
13+
#### # coords (optional)
14+
Expects an array of integers that define the `<area>`'s coordinates. For more details, see the [official documentation](https://www.w3schools.com/tags/att_area_coords.asp).
15+
16+
#### # download (optional)
17+
Expects a string to specify the target that will be downloaded when a user clicks on the hyperlink.
18+
19+
#### # href (optional)
20+
Expects a string to specify the hyperlink target for the area.
21+
22+
#### # hreflang (optional)
23+
Expects a string to specify the language of the target URL.
24+
25+
#### # media (optional)
26+
Expects a string to specify what media/device the target URL is optimized for.
27+
28+
#### # rel (optional)
29+
Expects a string to specify the relationship between the current document and the target URL.
30+
31+
#### # shape (optional)
32+
Expects a string to specify the shape of the area: Default, rect, circle, poly.
33+
34+
#### # target (optional)
35+
Expects a string to specify where to open the target URL.
36+
37+
#### # type (optional)
38+
Expects a string to specify the media type of the target URL.
39+
40+
## Example:
41+
42+
```ruby
43+
img path: 'matestack-logo.png', width: 500, height: 300, alt: "otherlogo", usemap: "#newmap"
44+
45+
map name: 'newmap' do
46+
area shape: 'rect', coords: [0,0,100,100], href: 'first.htm', alt: 'First'
47+
area shape: 'rect', coords: [0,0,100,100], href: 'second.htm', alt: 'Second'
48+
area shape: 'rect', coords: [0,0,100,100], href: 'third.htm', alt: 'Third'
49+
end
50+
```
51+
52+
returns
53+
54+
```html
55+
<img src="matestack-logo.png" alt="otherlogo" width="500" height="300" usemap="#newmap">
56+
57+
<map name="newmap">
58+
<area shape="rect" coords="0,0,100,100" href="first.htm" alt="First">
59+
<area shape="rect" coords="100,100,200,200" href="second.htm" alt="Second">
60+
<area shape="rect" coords="200,200,300,300" href="third.htm" alt="Third">
61+
</map>
62+
```

docs/components/img.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ The HTML img tag implemented in ruby.
66

77
## Parameters
88

9-
The image takes a mandatory path argument and can take 3 optional configuration params.
9+
The image takes a mandatory path argument and can take 4 optional configuration params.
1010

11-
#### # path
12-
Expects a string with the source to the image. It looks for the image in the assets/images folder and uses the standard Rails asset pipeline.
11+
#### # alt (optional)
12+
Expects a string with the alt text the image should have.
1313

1414
#### # height (optional)
1515
Expects an integer with the height of the image in px.
1616

17+
#### # path
18+
Expects a string with the source to the image. It looks for the image in the assets/images folder and uses the standard Rails asset pipeline.
19+
20+
#### # usemap (optional)
21+
Expects a string to specify the image as a client-side image-map.
22+
1723
#### # width (optional)
1824
Expects an integer with the width of the image in px.
19-
20-
#### # alt (optional)
21-
Expects a string with the alt text the image should have.

docs/components/link.md

Lines changed: 39 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
```
@@ -107,3 +110,37 @@ returns
107110
</a>
108111
</div>
109112
```
113+
114+
## Example 5 - path from symbol
115+
This example renders a link with a get request to any within your Rails application. In case you want to switch between pages within one specific matestack app, using the `transition` component probably is a better idea though!
116+
117+
```ruby
118+
div id: "foo", class: "bar" do
119+
link path: :inline_edit_path, text: 'Click to edit'
120+
end
121+
```
122+
123+
returns
124+
125+
```html
126+
<div id="foo" class="bar">
127+
<a href="/inline_edit">Click to edit</a>
128+
</div>
129+
```
130+
131+
## Example 6 - path from symbol with params
132+
You can also dynamically create `paths` from symbols and params, as displayed below:
133+
134+
```ruby
135+
div id: "foo", class: "bar" do
136+
link path: :single_endpoint_path, params: {number: 1}, text: 'Call API endpoint 1'
137+
end
138+
```
139+
140+
returns
141+
142+
```html
143+
<div id="foo" class="bar">
144+
<a href="/api/single_endpoint/1">Call API endpoint 1</a>
145+
</div>
146+
```

0 commit comments

Comments
 (0)