Set a minimum height when using a 100% width embed #1401
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to the embed code are working well on various size screens and with various height and width settings. However, the embedded map preview hasn't been updated to match and should be kept consistent.
Note this should be added to the
|
Nice catch @TaiWilkin. I think we can get away with a more relaxed minimum, so we're not usurping too much of their customers' webpages. Even still, one wrinkle with our solution is that we run the risk of mooting the customer-specified relative height at desktop widths. Eg, if someone sets We could address this through a media query, where we force a static height only for viewports below a certain width ( <div>
<style>
#oar-embed-GUID { /* append some RANDOM GUID? */
position: relative;
padding-top: 50%; /* customer-specified relative height */
}
@media (max-width: 600px) { /* mobile breakpoint */
#oar-embed-GUID {
padding-top: 500px; /* our mobile minumum */
}
}
</style>
<div id="oar-embed-GUID"> <!-- id for CSS -->
<iframe
src="http://localhost:6543/?contributors=6&embed=1"
frameborder="0"
allowfullscreen
style="position:absolute;top:0;left:0;width:100%;height:100%;"
title="embedded-map">
</iframe>
</div>
</div> |
I implemented Scott's suggested media query-based solution, reduced the min height to 500px, and fixed the preview. Thanks for the help. This is ready for another review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working very well. Nice incorporation of changes, and the additional code comments will be helpful. I was able to simulate a number of height and width settings successfully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
When setting the embed height as a proportion of the page width, the narrow screen widths of mobile devices lead to an embed that is too sort to be functional.
The critical search button at the bottom of the sidebar search tab was being obscured by the footer.
When the contributor uses the 100% width embed option we were enforcing a minimum allowable height to avoid creating an iframe that is too short to be functional. Replacing the `max` function with a media query allows us to conditionally enforce this minimum only at mobile widths. We append GUID to the DOM ID we use to attach styles so that there is no chance of the ID conflicting with another element on the host page.
We update the content of the preview React component to be the same as the generated iframe text and add comments explaining that future changes to the markup should be applied in both places.
64c4068
to
fec8eed
Compare
Thanks, again, for helping me revise this. |
Thanks for jumping in and fixing this! |
Overview
When setting the embed height as a proportion of the page width, the narrow screen widths of mobile devices lead to an embed that is too sort to be functional.
To work around this we introduce additional styling of the embed that uses media query to override the percentage with a fixed, minimum height.
Connects #1400
Demo
Testing Instructions
I used this index.html page served wtih https://www.npmjs.com/package/http-server to test the embed codes generated by this PR
Checklist
fixup!
commits have been squashed