-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TCI-1129: fixes & real-time orientation handling (#868)
- Loading branch information
1 parent
e6c5d8c
commit a68b35f
Showing
10 changed files
with
80 additions
and
46 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
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,25 +1,49 @@ | ||
/* | ||
* Consistent image height for mixed card widths. | ||
*/ | ||
const cards = Array.from(document.querySelectorAll('.jcc-cards--2-60-40-cols, .jcc-cards--2-75-25-cols')); | ||
|
||
cards.forEach(function (cardset) { | ||
// If media containers exist. | ||
let medias = Array.from(cardset.getElementsByClassName('usa-card__media')); | ||
|
||
* Consistent image height for mixed card widths. | ||
*/ | ||
function adjustMixedWidthMediaHeight(medias) { | ||
if (medias.length > 0) { | ||
// Determine max height from smallest image. | ||
// Reset media height to default. | ||
medias.forEach(function (media) { | ||
let image = media.getElementsByTagName("img"); | ||
media.removeAttribute("style"); | ||
image[0].removeAttribute("style"); | ||
}); | ||
|
||
// Determine max height from smallest media found. | ||
let maxHeight = medias[0].offsetHeight; | ||
medias.forEach(function(media) { | ||
medias.forEach(function (media) { | ||
maxHeight = Math.min(maxHeight, media.offsetHeight); | ||
}) | ||
}); | ||
|
||
// Adjust all container and image heights to max allowed. | ||
medias.forEach(function (media) { | ||
let image = media.getElementsByTagName('img'); | ||
let imageHeight = maxHeight/16 + 'rem'; | ||
image[0].setAttribute('style', 'height: ' + imageHeight + ';'); | ||
media.style.height = imageHeight; | ||
let mediaHeight = maxHeight / 16 + "rem"; | ||
let image = media.getElementsByTagName("img"); | ||
media.style.height = mediaHeight; | ||
image[0].setAttribute("style", "height: " + mediaHeight + ";"); | ||
}); | ||
} | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
// Detect any mixed card widths. | ||
const cards = Array.from( | ||
document.querySelectorAll(".jcc-cards--2-60-40-cols, .jcc-cards--2-75-25-cols") | ||
); | ||
|
||
if (cards) { | ||
cards.forEach(function (cardset) { | ||
// If media exist. | ||
let medias = Array.from(cardset.getElementsByClassName("usa-card__media")); | ||
|
||
if (medias) { | ||
adjustMixedWidthMediaHeight(medias); | ||
|
||
window.onresize = function () { | ||
adjustMixedWidthMediaHeight(medias); | ||
}; | ||
} | ||
}); | ||
} | ||
}); |
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
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
source/_patterns/02-molecules/card/card~media-left-icon-example.yml
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,8 @@ | ||
card: | ||
style: "media-left" | ||
title: "SVG Icon Media Source" | ||
body: "<p>Earlier use of icons from complete SVG HTML source rather than as an icon subcomponent.</p>" | ||
media: "<svg class='icon icon-laptop margin-4 margin-right-0' width='35' height='35' role='img' aria-label='Laptop'><use xlink:href='#icon-fa-laptop'></use></svg>" | ||
link: | ||
url: "#" | ||
text: "Luctus nunc quam" |
File renamed without changes.
File renamed without changes.
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