Skip to content

Commit 65ffae0

Browse files
Add area component
1 parent bb10eaa commit 65ffae0

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
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

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+
```

0 commit comments

Comments
 (0)