-
Notifications
You must be signed in to change notification settings - Fork 0
/
_star-rating.scss
executable file
·109 lines (78 loc) · 2.46 KB
/
_star-rating.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
109
// Rating Scale component
// ===
// Configurable variables
// ---
//
// 1. Scales size of entire component (<1 decrease, >1 increase).
// 2. Sets a standard size for the entire component.
// 3. Swaps out the standard star(s) colour. Default is grey.
// 4. Swaps out the emphasized star(s) colour. Default is yellow.
$rating-item--multiplier: 1 !default;
$rating-item--base: 16px !default;
$rating-item--color: #ccc !default;
$rating-item--color-filled: #f4d214 !default;
// Rating Scale Root (whole thing)
// ---
.c-star-ratings {
display: flex;
align-items: center;
}
// Rating Scale Item (individual star)
// ---
//
// Note: These rating stars are built entirely with CSS; the :before and :after
// pseudo elements are similar to how we build CSS triangles. Each of the
// pseudos correspond to certain points of the star, and are molded using
// border-width and rotation to be placed accordingly.
.c-star-ratings__item,
.c-star-ratings__item:before,
.c-star-ratings__item:after {
content: "";
display: block;
width: 0;
height: 0;
border-style: solid;
border-color: transparent;
}
// Rating Scale Item: top left, bottom right star points
// ---
.c-star-ratings__item {
position: relative;
margin-right: $rating-item--multiplier*($rating-item--base/4);
border-width: 0 $rating-item--multiplier*10px $rating-item--multiplier*7px;
border-bottom-color: currentColor;
color: $rating-item--color;
transform: rotate(35deg);
&.c--filled {
color: $rating-item--color-filled;
}
}
// Rating Scale Item: top middle star point
// ---
.c-star-ratings__item:before {
position: absolute;
top: -$rating-item--multiplier*5px;
left: -$rating-item--multiplier*6px;
border-width: 0 $rating-item--multiplier*3px $rating-item--multiplier*8px;
border-bottom-color: currentColor;
transform: rotate(-35deg);
}
// Rating Scale Item: top right, bottom left star points
// ---
.c-star-ratings__item:after {
position: absolute;
top: 0;
left: -$rating-item--multiplier*10px;
border-width: 0 $rating-item--multiplier*10px $rating-item--multiplier*7px;
border-bottom-color: currentColor;
transform: rotate(-70deg);
}
// Rating Scale Value (number value)
// ---
.c-star-ratings__value {
flex: 1 1 auto;
padding-left: $rating-item--multiplier*($rating-item--base/4);
font-weight: bold;
font-size: $rating-item--multiplier*$rating-item--base;
line-height: 1;
}