Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
image: a11y-attributes + content + examples
- Loading branch information
Showing
7 changed files
with
73 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
block('image')( | ||
tag()('img'), | ||
attrs()(function() { | ||
var ctx = this.ctx; | ||
return { | ||
src : ctx.url, | ||
width : ctx.width, | ||
height : ctx.height, | ||
alt : ctx.alt, | ||
title : ctx.title | ||
}; | ||
}) | ||
attrs()({ role : 'img' }), | ||
|
||
tag()('span'), | ||
|
||
match(function() { return typeof this.ctx.content === 'undefined'; })( | ||
tag()('img'), | ||
attrs()(function() { | ||
var ctx = this.ctx; | ||
return this.extend(applyNext(), | ||
{ | ||
src : ctx.url, | ||
width : ctx.width, | ||
height : ctx.height, | ||
alt : ctx.alt, | ||
title : ctx.title | ||
}); | ||
}) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
module.exports = function(bh) { | ||
bh.match('image', function(ctx, json) { | ||
ctx | ||
.tag('img') | ||
.attrs({ | ||
src : json.url, | ||
width : json.width, | ||
height : json.height, | ||
alt : json.alt, | ||
title : json.title | ||
}); | ||
ctx.attr('role', 'img'); | ||
|
||
if(typeof json.content !== 'undefined') { | ||
ctx.tag('span'); | ||
} else { | ||
ctx | ||
.tag('img') | ||
.attrs({ | ||
src : json.url, | ||
width : json.width, | ||
height : json.height, | ||
alt : json.alt, | ||
title : json.title | ||
}); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<img class="image" src="#" width="16" height="16" alt="Download" title="Download image"/> | ||
<img class="image" role="img" src="#" width="16" height="16" alt="Download" title="Download image"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
({ | ||
block : 'image', | ||
width : '16', | ||
height : '16', | ||
content : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"></svg>' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class="image" role="img"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"></svg></div> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.