-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpie.scss
108 lines (98 loc) · 2.18 KB
/
pie.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// GENERIC MIXINS
@mixin border-radius($px) {
-moz-border-radius: $px;
-webkit-border-radius: $px;
-o-border-radius: $px;
border-radius: $px;
}
@mixin transform-rotate($deg) {
-webkit-transform:rotate($deg);
-moz-transform:rotate($deg);
-o-transform:rotate($deg);
-ms-transform:rotate($deg);
transform:rotate($deg);
}
// PIE MIXIN STARTS HERE
@mixin pie($radius) {
$clip: $radius/2;
height: $radius;
width: $radius;
position: relative;
.pie {
position: absolute;
width: $radius;
height: $radius;
@include border-radius($clip);
clip: rect(0px, $clip, $radius, 0px);
&.color1 {
background-color: #d64231;
}
&.color2 {
background-color: #4284fc;
}
&.color3 {
background-color: #f5c827;
}
&.color4 {
background-color: #2ba553;
}
}
.pie-number {
height: $radius;
width: $radius;
position: absolute;
text-align: center;
top: 50%;
margin-top: -$clip/2;
color: #ffffff;
font-size: $clip;
font-family: 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
text-shadow: 0px 1px 0px rgba(0,0,0,0.75);
}
.hold {
position: absolute;
width: $radius;
height: $radius;
@include border-radius($clip);
clip: rect(0px, $radius, $radius, $clip);
}
}
@for $slices from 1 through 10 {
.pie-container[data-slices="#{$slices}"] {
// set some var defaults
$sliceNumber: 1;
$totalDeg: 0;
$sliceTotal: 0;
$baseDegree: 360;
@if $slices == 1 { // check to see if just one slice
$sliceTotal: 2; // run loop twice to draw both halves
$baseDegree: 180; // base degree for 2 iterations
}
@else {
$sliceTotal: $slices; // for non-1, set loop to # of slices
}
@while $sliceNumber <= $sliceTotal {
$deg: $baseDegree/$slices;
.pie-slice-#{$sliceNumber} {
@include transform-rotate(#{$totalDeg}deg);
.pie {
@include transform-rotate(#{$deg}deg);
}
}
$sliceNumber: $sliceNumber+1;
$totalDeg: ($totalDeg+$deg);
}
}
}
#pie1 {
@include pie(100px);
margin: 20px;
}
#pie2 {
@include pie(50px);
margin: 20px;
}
#pie3 {
@include pie(300px);
margin: 20px;
}