Skip to content

Instantly share code, notes, and snippets.

@atodev
Forked from anonymous/index.html
Last active June 1, 2021 23:10
Show Gist options
  • Save atodev/bf638b358c5fc77a995dd750b6749d1f to your computer and use it in GitHub Desktop.
Save atodev/bf638b358c5fc77a995dd750b6749d1f to your computer and use it in GitHub Desktop.
[Widget Phone] # Widget Phone
<div class="phonewrap landscape">
<div class="bananaphone">
<div class="iframe-wrapper">
<iframe id="mobile-preview-content" class="preview-frame" src='https://trustsphere.mitrustview.com/widget/widget?key=0ea79ty6hzfnjqh4&options={"header":true,"border":true,"widget":"linksWithin"}&query={"remote":"[email protected]"}'>
</iframe>
</div>
</div>
</div>
<a href="#" class="btn rotate">Rotate Me</a>
<a href="#" class="btn stretch">Stretch Me</a>
$('.rotate').click(function() {
if ($('.phonewrap').hasClass('landscape')) {
$('.phonewrap').removeClass('landscape');
$(this).text('Rotate to Landscape');
} else {
$('.phonewrap').addClass('landscape');
$(this).text('Rotate to Portrait');
}
});
$('.stretch').click(function() {
if ($('.bananaphone').hasClass('tablet')) {
$('.bananaphone').removeClass('tablet');
$(this).text('Stretch to Tablet');
} else {
$('.bananaphone').addClass('tablet');
$(this).text('Squish to Phone');
}
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
.phonewrap {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
}
.bananaphone {
.transition(all .5s ease-in-out);
margin: 15px auto;
width: 350px;
height: 620px;
padding-top: 55px;
padding-left: 11px;
position: relative;
border: 2px solid #bcbcbc;
border-radius: 35px;
background: #fff;
.iframe-wrapper {
.transition(all .5s ease-in-out);
border: 2px solid #bcbcbc;
width: 324px;
height: 484px;
border-radius: 3px;
}
iframe {
width: 320px;
height: 480px;
border: none;
}
&:after,
&:before {
.transition(left .5s ease-in-out);
content: "";
position: absolute;
left: 140px;
width: 70px;
border-radius: 5px;
}
&:after {
border: 3px solid #bcbcbc;
top: 25px;
height: 6px;
}
&:before {
border: 2px solid #bcbcbc;
bottom: 20px;
height: 35px;
}
.landscape & {
margin: -80px auto 0 auto;
.transform(rotate(-90deg));
iframe {
position: absolute;
top: 137px;
left: -67px;
width: 480px;
height: 320px;
.transform(rotate(90deg));
}
}
&.tablet {
width: 670px;
height: 1100px;
.iframe-wrapper {
width: 646px;
height: 964px;
}
iframe {
width: 640px;
height: 960px;
border: none;
}
&:after,
&:before {
left: 300px;
}
.landscape & {
margin: -100px auto 0 auto;
iframe {
top: 217px;
left: -146px;
width: 960px;
height: 640px;
}
}
}
}
.btn {
font-family: "Helvetica Neue", Arial, Helvetica, Verdana, sans-serif;
background: #e0e0e0;
border-radius: 3px;
color: #737373;
text-decoration: none;
font-weight: 700;
font-size: 13px;
position: relative;
display: inline-block;
padding: 0 18px;
margin: 10px;
line-height: 36px;
&:hover {
background: #d3d3d3;
}
}
* {
box-sizing: border-box;
}
// Basic Mixins
.transition (@value1, @value2: X, ...) {
@value: ~`"@{arguments}".replace(/[\[\]]|\, \sX/g, '')`;
-webkit-transition: @value;
-moz-transition: @value;
-ms-transition: @value;
-o-transition: @value;
transition: @value;
}
.transform(@string) {
-webkit-transform: @string;
-ms-transform: @string;
transform: @string;
}

Widget Phone

In the MailChimp app, we created a preview of what your campaign might look like on a mobile device. It's really just an iframe with some device chrome around it but if the campaign has media queries, it gives a pretty good approximation of how it'll look.

I thought it'd be fun to pull the markup out to experiment with new ideas for it.

A Pen by Tom on CodePen.

License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment