Skip to content

Instantly share code, notes, and snippets.

@C-Rodg
Created May 26, 2016 19:38
Show Gist options
  • Save C-Rodg/b05716612b2cb9bd1700a86d4b5eb3d5 to your computer and use it in GitHub Desktop.
Save C-Rodg/b05716612b2cb9bd1700a86d4b5eb3d5 to your computer and use it in GitHub Desktop.
Panels
<h1 class="title">Panels</h1>
<div class="content">
<div class="panels">
<div class="panel">
<div class="panel__actions clearfix">
<button class="btn btn--hide"><i class="fa fa-ban"></i></button>
<button class="btn btn--heart"><i class="fa fa-heart-o"></i></button>
</div>
<div class="panel__content clearfix">
<button class="btn btn--more">
<i class="fa fa-ellipsis-h btn-front-more"></i>
<i class="fa fa-times hidden btn-front-close"></i>
<i class="fa fa-heart-o hidden btn-front-heart"></i>
</button>
<div class="img img--profile"></div>
<span class="panel__content__title">Curtis Rodgers</span>
<p class="panel__content__body">Web Developer. <br />Seattle, WA.</p>
</div>
</div>
<div class="panel">
<div class="panel__actions clearfix">
<button class="btn btn--hide"><i class="fa fa-ban"></i></button>
<button class="btn btn--heart"><i class="fa fa-heart-o"></i></button>
</div>
<div class="panel__content clearfix">
<button class="btn btn--more">
<i class="fa fa-ellipsis-h btn-front-more"></i>
<i class="fa fa-times hidden btn-front-close"></i>
<i class="fa fa-heart-o hidden btn-front-heart"></i>
</button>
<div class="img img--walter"></div>
<span class="panel__content__title">Walter White</span>
<p class="panel__content__body">Chemist. <br />Albuquerque, NM.</p>
</div>
</div>
<div class="panel">
<div class="panel__actions clearfix">
<button class="btn btn--hide"><i class="fa fa-ban"></i></button>
<button class="btn btn--heart"><i class="fa fa-heart-o"></i></button>
</div>
<div class="panel__content clearfix">
<button class="btn btn--more">
<i class="fa fa-ellipsis-h btn-front-more"></i>
<i class="fa fa-times hidden btn-front-close"></i>
<i class="fa fa-heart-o hidden btn-front-heart"></i>
</button>
<div class="img img--batman"></div>
<span class="panel__content__title">Bruce Wayne</span>
<p class="panel__content__body">The Dark Knight. <br />Gotham City, NJ.</p>
</div>
</div>
<div class="panel">
<div class="panel__actions clearfix">
<button class="btn btn--hide"><i class="fa fa-ban"></i></button>
<button class="btn btn--heart"><i class="fa fa-heart-o"></i></button>
</div>
<div class="panel__content clearfix">
<button class="btn btn--more">
<i class="fa fa-ellipsis-h btn-front-more"></i>
<i class="fa fa-times hidden btn-front-close"></i>
<i class="fa fa-heart-o hidden btn-front-heart"></i>
</button>
<div class="img img--mickey"></div>
<span class="panel__content__title">Mickey Mouse</span>
<p class="panel__content__body">Mascot of The Walt Disney Company. <br />Orlando, FL.</p>
</div>
</div>
</div><!--End of Panels-->
</div><!--End of Content-->
function togglePanel($ele, status){
if(status){
if(status === 'close'){
$ele.removeClass('panel--open');
} else if(status === 'open'){
$ele.addClass('panel--open');
$ele.siblings('.panel').removeClass('panel--open');
}
} else {
if($ele.hasClass('panel--open')){
togglePanel($ele, 'close');
} else {
togglePanel($ele, 'open');
}
}
return;
}
(function(){
$('.btn').on('click', function(){
$parent = $(this).parents('.panel');
if($(this).hasClass('btn--heart')){
if($parent.hasClass('panel--hearted')){
$parent.removeClass('panel--hearted');
togglePanel($parent, 'close');
} else {
$parent.addClass('panel--hearted');
togglePanel($parent, 'close');
}
} else if ($(this).hasClass('btn--more')){
togglePanel($parent);
} else if ($(this).hasClass('btn--hide')){
togglePanel($parent, 'close');
return $parent.delay(200).fadeOut(400);
}
});
})();
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
body {
font-family: 'Open Sans', sans-serif;
color: #333;
box-sizing: border-box;
}
button {
background: none;
border: 0;
outline: 0;
}
.hidden {
display: none;
}
.clearfix:after {
content: '';
display: table;
clear: both;
}
.img {
background-color: #c5c5c5;
border-radius: 50%;
border: 4px solid #333;
float: left;
width: 70px;
height: 70px;
background-size: cover;
background-position: 50% 50%;
}
.img--walter {
background-image: url('http://img4.wikia.nocookie.net/__cb20130928055404/breakingbad/images/e/e7/BB-S5B-Walt-590.jpg');
}
.img--profile {
background-image: url('http://curtisrodgers.com/img/profile.png')
}
.img--batman {
background-position: 50% 10%;
background-image: url('https://upload.wikimedia.org/wikipedia/en/9/90/Bale_as_Batman.jpg');
}
.img--mickey {
background-position: 50% 10%;
background-image: url('http://images.clipartpanda.com/mickey-mouse-birthday-clipart-Mickie-Mouse-Clip-Art-126.jpg');
}
.title {
margin: 0;
padding:25px;
width: 100%;
text-align: center;
background: #ecf0f1;
}
.content {
height: 100%;
width: 100%;
margin: 0;
background: #3498db;
}
.panels {
max-width: 440px;
margin: 0 auto;
padding: 15px;
}
.panel:not(:first-child){
margin-top: 20px;
}
.panel {
position: relative;
}
.panel__actions {
position: absolute;
height: 45px;
width: 100px;
top: 50%;
right: 20px;
}
.panel__content {
background-color: #fff;
padding: 13px 10px;
border-bottom: 1px solid #c7c7c7;
position: relative;
right: 0;
z-index: 3;
transition: all 0.3s;
}
.btn--more {
width: 30px;
height: 30px;
line-height: 30px;
position: absolute;
border-radius:50%;
top: 0;
right: 0;
opacity: 0;
transition: all 0.3s;
}
.btn--more i {
vertical-align: middle;
}
.btn--more:hover {
background-color: #e5e5e5;
}
.panel__content img {
background-color: #3498db;
border: 4px solid #333;
width: 18%;
height: auto;
border-radius: 50%;
float: left;
}
span.panel__content__title,
.panel__content__body {
float: left;
display: block;
margin: 0 0 5px 10px;
width: 75%;
}
span.panel__content__title {
font-size: 1.3em;
}
.panel__content:hover .btn--more {
opacity: 1;
}
.panel__actions {
width: 100px;
height: 45px;
position: absolute;
top: 50%;
right: 20px;
z-index: 2;
transform: translateY(-50%);
}
.panel__actions button {
display: inline-block;
width: 45px;
height: 45px;
border: 2px solid;
border-radius: 50%;
transition: all 0.3s;
}
.panel__actions .btn--hide {
border-color: #2c3e50;
color: #2c3e50;
}
.panel__actions .btn--hide:hover {
background-color: #2c3e50;
color: white;
}
.panel__actions .btn--heart {
border-color: #e74c3c;
color: #e74c3c;
}
.panel--hearted .btn--heart,
.panel__actions .btn--heart:hover {
background-color: #e74c3c;
color: white;
}
.panel--open .panel__content {
right: 140px;
}
.panel--open .btn--more {
opacity: 1;
}
.panel--hearted .btn-front-heart {
display: inline-block;
}
.panel--hearted .btn--more {
opacity: 1;
color: #e74c3c;
}
.panel--hearted .btn-front-more {
display:none;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,600" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment