A Pen by Bitcollage on CodePen.
Created
June 2, 2014 19:08
-
-
Save SerkanSipahi/64b249b10410dac2cd60 to your computer and use it in GitHub Desktop.
A Pen by Bitcollage.
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
<body data-fb-color> | |
<div class="fb-buttons center"> | |
<div data-fb-color="green" class="fb-button"></div> | |
<div data-fb-color="blue" class="fb-button fb-active"></div> | |
<div data-fb-color="red" class="fb-button"></div> | |
</div> | |
<div class="fb-circle center"> | |
</div> | |
<div class="fb-circle-static center"> | |
</div> | |
</body> |
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
window.onload = function(){ | |
var $ = document.querySelectorAll.bind(document), | |
buttons = $('.fb-button'), | |
$lastActive = {}, color ='', | |
handleCircleGlow = function($lastActive){ | |
$('body[data-fb-color]')[0].setAttribute( | |
'data-fb-color', | |
$lastActive.getAttribute('data-fb-color') | |
); | |
}; | |
for(var i =0, length=buttons.length;i<length;i++){ | |
if(buttons[i].classList.contains('fb-active')){ | |
$lastActive = buttons[i]; | |
handleCircleGlow($lastActive); | |
} | |
buttons[i].addEventListener('click', function(e){ | |
$lastActive.classList.remove('fb-active'); | |
$lastActive = this; | |
$lastActive.classList.add('fb-active'); | |
handleCircleGlow($lastActive); | |
}); | |
} | |
}; |
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
prefix = { | |
'0' : -moz-, | |
'1' : -webkit-, | |
'2' : -o-, | |
'3' : '' | |
} | |
border-radius($n, prefix){ | |
for $key, $value in prefix{ | |
{$value}border-radius: $n; | |
} | |
} | |
box-shadow($n, prefix){ | |
for $key, $value in prefix{ | |
{$value}box-shadow: $n; | |
} | |
} | |
square(n){ | |
width: n; | |
height: n; | |
} | |
transition($rule){ | |
-moz-transition: $rule; | |
-o-transition: $rule; | |
-webkit-transition: $rule; | |
transition: $rule; | |
} | |
transform(prefix, $rule){ | |
for $key, $value in prefix{ | |
{$value}transform: $rule; | |
} | |
} | |
animation($rule, prefix){ | |
for $key, $value in prefix{ | |
{$value}animation: $rule; | |
} | |
} | |
@keyframes fbspin { | |
for $num in (0..100){ | |
{1% * $num} { | |
transform( | |
prefix, | |
rotateZ( (360/100 * $num) deg ) translate3d(5px, 0, 0) | |
) | |
} | |
} | |
} | |
.center { | |
margin: 0 auto 0; | |
} | |
body{ | |
background-color: black; | |
} | |
body, | |
.fb-circle, | |
.fb-circle-static { | |
transition(all 1000ms ease-in); | |
} | |
// >>> ------------ Start Theme -------- | |
body { | |
&[data-fb-color="green"]{ | |
background-color: #000c02; | |
.fb-circle { | |
background-color: #247a2f; | |
box-shadow(0 0 28px 0 #247a2f, prefix); | |
} | |
.fb-circle-static { | |
box-shadow(inset 0 0 4px 2px #14541c, prefix); | |
background-color: #0a2700; | |
} | |
} | |
&[data-fb-color="blue"] { | |
background-color: #000921; | |
.fb-circle { | |
background-color: #005cd8; | |
box-shadow(0 0 28px 0 #005cd8, prefix); | |
} | |
.fb-circle-static { | |
box-shadow(inset 0 0 4px 2px #2d43cb, prefix); | |
background-color: #001c37; | |
} | |
} | |
&[data-fb-color="red"] { | |
background-color: #140000; | |
.fb-circle { | |
background-color: #952626; | |
box-shadow(0 0 35px 0 #952626, prefix); | |
} | |
.fb-circle-static { | |
box-shadow(inset 0 0 4px 2px #5f1212, prefix); | |
background-color: #2f0000; | |
} | |
} | |
} | |
// >>> ------------ End Theme -------- | |
.fb-circle { | |
position:relative; | |
animation(fbspin 1500ms linear infinite, prefix); | |
margin-top: 240px; | |
square(200px); | |
border-radius(50%, prefix); | |
background-color: #001c37; | |
} | |
.fb-circle-static { | |
top: -205px; | |
position:relative; | |
square(200px); | |
border-radius(50%, prefix); | |
} | |
.fb-buttons { | |
position :relative; | |
top: -160px; | |
width: 174px; | |
left: 10px; | |
.fb-button { | |
cursor: pointer; | |
margin-right: 20px; | |
border-radius(50%, prefix); | |
square(28px); float:left; | |
border-width : 5px; border-style: solid; | |
} | |
.fb-button[data-fb-color="green"] { | |
border-color: #14541c; | |
background-color: #021b0a; | |
} | |
.fb-button[data-fb-color="blue"] { | |
border-color: #0a4392; | |
background-color: #061a37; | |
} | |
.fb-button[data-fb-color="red"] { | |
border-color: #5f1212; | |
background-color: #120000; | |
} | |
// >> fb-button active | |
.fb-button[data-fb-color="green"].fb-active { | |
box-shadow(0 0 28px 0 #14541c, prefix); | |
background-color:#14541c; | |
} | |
.fb-button[data-fb-color="blue"].fb-active { | |
box-shadow(0 0 28px 0 #0a4392, prefix); | |
background-color:#0a4392; | |
} | |
.fb-button[data-fb-color="red"].fb-active { | |
box-shadow(0 0 28px 0 #5f1212, prefix); | |
background-color:#5f1212; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment