Created
November 10, 2018 18:54
-
-
Save hardmantoplz/a32341cb16c8235d96ace22b04db5227 to your computer and use it in GitHub Desktop.
Digital Clock with Vue.js_edited
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
<div id="clock"> | |
<p class="date">{{ date }}</p> | |
<p class="time">{{ time }}</p> | |
<p class="text">Calvary Chapel Redmond</p> | |
</div> |
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
var clock = new Vue({ | |
el: '#clock', | |
data: { | |
time: '', | |
date: '' | |
} | |
}); | |
var week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']; | |
var timerID = setInterval(updateTime, 1000); | |
updateTime(); | |
function updateTime() { | |
var cd = new Date(); | |
clock.time = zeroPadding(cd.getHours(), 2) + ':' + zeroPadding(cd.getMinutes(), 2) + ':' + zeroPadding(cd.getSeconds(), 2); | |
clock.date = zeroPadding(cd.getFullYear(), 4) + '-' + zeroPadding(cd.getMonth()+1, 2) + '-' + zeroPadding(cd.getDate(), 2) + ' ' + week[cd.getDay()]; | |
}; | |
function zeroPadding(num, digit) { | |
var zero = ''; | |
for(var i = 0; i < digit; i++) { | |
zero += '0'; | |
} | |
return (zero + num).slice(-digit); | |
} |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js"></script> |
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
html,body { | |
height: 100%; | |
} | |
body { | |
background: #0f3854; | |
background: radial-gradient(ellipse at center, #0a2e38 0%, #000000 70%); | |
background-size: 100%; | |
} | |
p { | |
margin: 0; | |
padding: 0; | |
} | |
#clock { | |
font-family: 'Share Tech Mono', monospace; | |
color: #ffffff; | |
text-align: center; | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
transform: translate(-50%, -50%); | |
color: #daf6ff; | |
text-shadow: 0 0 20px rgba(10, 175, 230, 1), 0 0 20px rgba(10, 175, 230, 0); | |
.time { | |
letter-spacing: 0.05em; | |
font-size: 80px; | |
padding: 5px 0; | |
} | |
.date { | |
letter-spacing: 0.1em; | |
font-size: 24px; | |
} | |
.text { | |
letter-spacing: 0.1em; | |
font-size: 18px; | |
padding: 20px 0 0; | |
color: red; | |
} | |
} |
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
<link href="https://fonts.googleapis.com/css?family=Share+Tech+Mono" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment