Skip to content

Added Sass Support #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,62 @@ module.exports = function(grunt){
less_main: {
files: './css/**/*.less',
tasks: ['less']
},
sass: {
files: './css/**/*.scss',
tasks: ['sass', 'postcss:autoprefixer', 'postcss:minify']
}
},

less: {
main: {
files: {
'./css/style.css': './css/style.less'
'./css/style.css': './css/less/style.less'
}
}
}
},

sass: {
options: {
sourceMap: true
},
dist: {
files: {
'./css/style.css': './css/sass/style.scss'
}
}
},

postcss: {
autoprefixer: {
options: {
map: true,
processors: [
require('autoprefixer-core')
]
},
files: {
'./css/style.css': './css/style.css'
}
},
minify: {
options: {
map: true,
processors: [
require('csswring')
]
},
files: {
'./css/style.min.css': './css/style.css'
}
}
}
});

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-postcss');

grunt.registerTask('default', ['sass', 'postcss:autoprefixer', 'postcss:minify', 'watch']);
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
166 changes: 166 additions & 0 deletions css/sass/css-flip-counter.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// Some defaults

$digitWidth: 60px;
$digitHeight: 90px;
$digitFontSize: 90px;

$digitMargin: 10px;
$digitBackground: black;
$digitColor: white;

$digitFontFamily: 'Ubuntu', sans-serif;
$digitFontWeight: 700;

$digitFlipDuration: 0.3s ease-in;
$digitFlipPerspective: 300px;

$delimiterFontSize: 52px;

// Base styles

.counter-wrapper {
float : right;
position : relative;
left : -50%;
margin-top : 20px;
}

.flip-counter {
position : relative;
left : 50%;
list-style-type : none;

li {
float : right;
}
}

@mixin build-counter($className,
$digitWidth: $digitWidth,
$digitHeight: $digitHeight,
$digitFontSize: $digitFontSize,
$digitMargin: $digitMargin,
$digitBackground: $digitBackground,
$digitColor: $digitColor,
$delimiterFontSize: $delimiterFontSize,
$digitFlipPerspective: $digitFlipPerspective
) {
$shadowColor: rgba($digitBackground, .5);

.flip-counter.#{$className} .digit {
position : relative;
z-index : 0;
width : $digitWidth;
height : $digitHeight;
margin-left : $digitMargin;
background-color : $digitBackground;
text-align : center;
line-height : 0;
// Fix for slight Chrome-Win font jumping
// https://code.google.com/p/chromium/issues/detail?id=137692
// 1px not enough, unfortunately
//-webkit-text-stroke : 2px #fff;
box-shadow : 1px 1px 5px 0 $shadowColor;
border-radius : 5px;

&:last-child {
margin-left : 0;
}

span {
position : absolute;
left : 0;
height : $digitHeight / 2;
width : $digitWidth;
overflow : hidden;
border-radius : 5px;
font-size : $digitFontSize;
font-family : $digitFontFamily;
font-weight : $digitFontWeight;
text-indent : 2px;
background-color : $digitBackground;
color : $digitColor;

// Prevents some jumping around in FF
transform : translate3d(0, 0, 0);

&.front {
top : 0;
padding-top : $digitHeight / 2;
}

&.back {
bottom : 0;
}
}

.line {
position : absolute;
z-index : 10;
height : $digitHeight / 2;
width : $digitWidth;
$lineHeight: ceil($digitFontSize/100);
border-bottom : $lineHeight solid rgba($digitBackground, .3);
box-shadow: 0 $lineHeight+4 7px -4px rgba($digitBackground, .3);

// Another method of creating the dividing line as a box shadow. I thought this might
// fix Safari's problem of not respecting z-index with transforms:
// http://stackoverflow.com/questions/5472802/css-z-index-lost-after-webkit-transform-translate3d
// I've spent enough time messing with it, can't get it to work right in Safari.
// Applying a .translate3d(0, 0, 0); to it also does nothing.
//
//@shadows: 0px @lineHeight+4 7px -4px fadeout($digitBackground, 20%), 0px @lineHeight 0px 0px fadeout($digitBackground, 20%);
//.box-shadow(@shadows);
}

.hinge-wrap {
z-index : 5;
position : relative;
overflow : visible;
perspective : $digitFlipPerspective;
}

.hinge {
position : absolute;
height : $digitHeight / 2;
width : $digitWidth;
transform-style: preserve-3d;
transition: transform $digitFlipDuration;
transform-origin: 50% 100%;

span {
height : 0;
z-index : 5;
backface-visibility: hidden;

&.front {
padding-top : $digitHeight / 2;
}

&.back {
height : $digitHeight / 2;
transform: rotateX(180deg);
}
}
}

&.animate .hinge {
transform: rotateX(-180deg);
}
}

.flip-counter.#{$className} .digit-delimiter {
padding-top : $digitHeight - $delimiterFontSize;
margin-right : -($digitMargin / 2);
font-family : $digitFontFamily;
font-weight : $digitFontWeight;
font-size : $delimiterFontSize;
color : $digitBackground;
text-indent : ($digitMargin) / 3;
text-shadow : 1px 1px 5px $shadowColor;
}
};

.no-csstransforms3d span.back {
display : none;
}
86 changes: 86 additions & 0 deletions css/sass/demo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
body {
font: 14px 'Ubuntu', sans-serif;
}

h1 {
text-align: center;
margin: 10px;
line-height: 60px;
font-weight: 700;
font-size: 60px;
/* Web fonts look bad in Chrome even with -webkit-font-smoothing, so this is a cheap way to soften the jaggies */
//text-shadow: 0 0 1px #000;
}

.clearfix {
*zoom: 1;
&:before,
&:after {
display: table;
content: ""; // Fixes Opera/contenteditable bug:
// http://nicolasgallagher.com/micro-clearfix-hack/#comment-36952
line-height: 0;
}
&:after {
clear: both;
}
}

#style-switcher {
list-style-type: none;
width: 600px;
margin: 20px auto 10px;

li {
padding: 0;
width: 150px;
float: left;
text-align: center;

a {
display: block;
padding: 5px 10px;
text-transform: uppercase;
text-decoration: none;
font-size: 20px;
font-weight: 400;
color: #000;

&:hover {
font-size: 24px;
}

&.active {
font-size: 24px;
font-weight: 700;
background: #eee;
}
}
}
}

#demo_controls {
position: relative;
width: 700px;
margin: 0 auto;
padding: 20px 0;
list-style-type: none;

li {
width: 320px;
float: left;
text-align: center;
margin: 0 15px;
font-weight: bold;
font-size: 15px;

p {
margin-bottom: 10px;
}
}
}

p.info {
text-align: center;
margin-top: 20px;
}
19 changes: 19 additions & 0 deletions css/sass/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Demo page styles
// -------------------------
@import 'demo';

// Base counter styles and builder
// -------------------------
@import 'css-flip-counter';

// Lets make some counters!
// -------------------------

// Simple default
@include build-counter(default);
// Light
@include build-counter(light, 60px, 90px, 90px, 10px, #E8F1FF, white, 52px, 300px);
// Small
@include build-counter(small, 30px, 40px, 34px, 5px, black, white, 25px, 300px);
// Huge mofo
@include build-counter(huge, 140px, 200px, 190px, 20px, black, white, 70px, 800px);
Loading