Skip to content
This repository has been archived by the owner on Jun 26, 2018. It is now read-only.

Commit

Permalink
Merge pull request #852 from massgov/feature/dp-7363-image-srcset
Browse files Browse the repository at this point in the history
DP-7363: Image srcset
  • Loading branch information
clair0917 authored May 30, 2018
2 parents b8ec45e + 6d8caea commit 4e7ff34
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 10 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions changelogs/DP-7363.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
___DESCRIPTION___
Added
Minor
- DP-7363: Enable srcset on the image pattern and demonstrate usage on Press Release with Image Page
8 changes: 6 additions & 2 deletions styleguide/source/_patterns/01-atoms/09-media/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ image {
type: string / required
src:
type: string (url) / required
srcset:
type: string / optional
sizes:
type: string / optional
height:
type: string / required
type: string / optional
width:
type: string / required
type: string / optional
shape:
type: string / optional
}
Expand Down
30 changes: 24 additions & 6 deletions styleguide/source/_patterns/01-atoms/09-media/image.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
<img
class="ma__image{% if image.shape %} {{ image.shape }}{% endif %}"
alt="{{ image.alt }}"
src="{{ image.src }}"
height="{{ image.height }}"
width="{{ image.width }}" />
<img
class="ma__image{% if image.shape %} {{ image.shape }}{% endif %}"
alt="{{ image.alt }}"
src="{{ image.src }}"
{% if image.versions %}
srcset="
{% for version in image.versions %}
{% if version.url and version.width %}
{{ version.url }} {{ version.width }}{% if not loop.last %},{% endif %}
{% endif %}
{% endfor %}
"
{% if image.sizes %}
{# Only use sizes if certain breakpoints limit the width of the image to less than approximately full width #}
sizes="{{ image.sizes }}"
{% endif %}
{% endif %}
{% if image.height %}
height="{{ image.height }}"
{% endif %}
{% if image.width %}
width="{{ image.width }}"
{% endif %}
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"image": {
"alt": "alt text",
"src": "../../assets/images/placeholder/800x400.png",
"versions": [
{
"url": "../../assets/images/placeholder/400x200.png",
"width": "620w"
},
{
"url": "../../assets/images/placeholder/700x350.png",
"width": "780w"
},
{
"url": "../../assets/images/placeholder/800x400.png",
"width": "910w"
}
]
}
}
21 changes: 19 additions & 2 deletions styleguide/source/_patterns/05-pages/press-release~with-image.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,25 @@
"image": {
"alt": "alt text",
"src": "../../assets/images/placeholder/820x460.png",
"height": "",
"width": ""
"versions": [
{
"url": "../../assets/images/placeholder/565x282.png",
"width": "565w"
},
{
"url": "../../assets/images/placeholder/820x460.png",
"width": "820w"
},
{
"url": "../../assets/images/placeholder/835x467.png",
"width": "835w"
},
{
"url": "../../assets/images/placeholder/1670x835.png",
"width": "1670w"
}
],
"sizes": "(min-width: 910px) 820px, 100vw"
},
"caption": "This is an optional caption that can wrap to multiple lines."
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4e7ff34

Please sign in to comment.