-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstyle.scss
111 lines (94 loc) · 2.3 KB
/
style.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
110
111
// Animate the size, inside
.fill:hover,
.fill:focus {
box-shadow: inset 0 0 0 2.3em var(--hover);
}
// Animate the size, outside
.pulse:hover,
.pulse:focus {
animation: pulse 1s;
box-shadow: 0 0 0 2.5em rgba(#fff,0);
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 var(--hover); }
}
// Size can also be negative; see how it's smaller than the element
.raise:hover,
.raise:focus {
box-shadow: 0 0.5em 0.5em -0.4em var(--hover);
transform: translateY(-0.25em);
}
// Animating from the bottom
.up:hover,
.up:focus {
box-shadow: inset 0 -3.25em 0 0 var(--hover);
}
// And from the left
.slide:hover,
.slide:focus {
box-shadow: inset 9.5em 0 0 0 var(--hover);
}
// Multiple shadows, one on the outside, another on the inside
.offset {
box-shadow:
0.3em 0.3em 0 0 var(--color),
inset 0.3em 0.3em 0 0 var(--color);
&:hover,
&:focus {
box-shadow:
0 0 0 0 var(--hover),
inset 6em 3.5em 0 0 var(--hover);
}
}
//=== Set button colors
// If you wonder why use Sass vars or CSS custom properties...
// Make a map with the class names and matching colors
$colors: (
fill: #ca96eb,
pulse: #ef6eae,
raise: #ffa260,
up: #e4cb58,
slide: #8fc866,
offset: #19bc8b
);
// Sass variables compile to a static string; CSS variables are dynamic and inherited
// Loop through the map and set CSS custom properties using Sass variables
@each $button, $color in $colors {
.#{$button} {
--color: #{$color};
--hover: #{adjust-hue($color, 45deg)};
}
}
// Now every button will have different colors as set above. We get to use the same structure, only changing the custom properties.
button {
color: var(--color);
transition: 0.25s;
&:hover,
&:focus {
border-color: var(--hover);
color: #fff;
}
}
//=== Pen styling, ignore
body {
color: #fff;
background: hsl(227, 10%, 10%);
font: 300 1em 'Fira Sans', sans-serif;
// Center everything ever
justify-content: center;
align-content: center;
align-items: center;
text-align: center;
min-height: 100vh;
display:flex;
}
// Basic button styles
button {
display: block;
background: none;
border: 2px solid;
font: inherit;
line-height: 1;
margin: 3em;
padding: 1em 3em;
}