Skip to content

Commit b711543

Browse files
Add usemap attribute to image component
1 parent 4e005a0 commit b711543

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

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

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.

spec/usage/components/img_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
class ExamplePage < Matestack::Ui::Page
99
def response
1010
components {
11+
# simple image
1112
img path: 'matestack-logo.png', width: 500, height: 300, alt: "logo"
13+
# using usemap
14+
img path: 'matestack-logo.png', width: 500, height: 300, alt: "otherlogo", usemap: "#newmap"
1215
}
1316
end
1417
end
1518

1619
visit '/example'
1720

1821
expect(page).to have_xpath("//img[contains(@src,'matestack-logo') and @alt='logo' and @width='500' and @height='300']")
22+
expect(page).to have_xpath("//img[contains(@src,'matestack-logo') and @alt='otherlogo' and @width='500' and @height='300'] and @usemap='\#newmap'")
1923
end
2024
end

0 commit comments

Comments
 (0)