Skip to content

Commit 3f1f004

Browse files
committed
add click-down(), click-inset(), click-shadow(), & click-shrink() per #199
1 parent 5791217 commit 3f1f004

File tree

11 files changed

+100
-3
lines changed

11 files changed

+100
-3
lines changed

axis/interaction.styl

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,19 @@ hover-color(color, forceUseColor = false)
115115

116116
// Mixin: Hover Glow
117117
//
118-
// Creates a glow when hovering an element. Takes a color and a radius (size). Recommended to be used with transition.
118+
// Creates a glow when hovering an element. Takes a color and a radius (size).
119+
// Recommended to be used with transition.
119120
//
120121
// ex: hover-glow()
121122

122123
hover-glow($color = rgba(blue, .8), $radius = 20px )
123124
&:hover
124125
box-shadow: 0px 0px $radius 2px $color
125126

126-
127127
// Mixin: Hover Float
128128
//
129-
// Gives an element the effect of rising up vertically with a small shadow underneath. Recommended to be use with transition.
129+
// Gives an element the effect of rising up vertically with a small shadow
130+
// underneath. Recommended to be use with transition.
130131
//
131132
// Ex: hover-float()
132133

@@ -150,3 +151,47 @@ hover-float()
150151
&:before
151152
opacity: 1
152153
transform: scale(1)
154+
155+
// Mixin: Click down
156+
//
157+
// Move an element down while clicked/tapped. Takes distance.
158+
//
159+
// ex: click-down()
160+
161+
click-down($distance = 1px)
162+
&:active
163+
transform: translateY($distance)
164+
165+
// Mixin: Click shadow
166+
//
167+
// Creates a shadow under element while clicked/tapped. Takes distance and
168+
// radius (size). Recommended to be use with transition.
169+
//
170+
// ex: click-shadow()
171+
172+
click-shadow($distance = 2px, $radius = 10px )
173+
&:active
174+
box-shadow: 0px $distance $radius 2px rgba(0, 0, 0, 0.25)
175+
176+
// Mixin: Click inset
177+
//
178+
// Creates an inset shadow on an elment while clicked/tapped. Takes radius
179+
// (inset shadow size). Recommended to be use with transition.
180+
//
181+
// ex: click-inset()
182+
183+
click-inset($radius = 20px)
184+
$distance = $radius / 2
185+
&:active
186+
box-shadow: inset 0px $distance $radius rgba(0, 0, 0, 0.35);
187+
188+
// Mixin: Click-shrink
189+
//
190+
// Scale down an element when clicked/tapped. Gives the effect of "sinking"
191+
// or lowering on the z-axis.
192+
//
193+
// ex: click-shrink()
194+
195+
click-shrink($distance = .92)
196+
&:active
197+
transform: scale($distance)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.click-down:active {
2+
-webkit-transform: translateY(1px);
3+
-moz-transform: translateY(1px);
4+
-o-transform: translateY(1px);
5+
-ms-transform: translateY(1px);
6+
transform: translateY(1px);
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.click-down
2+
click-down()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.click-inset:active {
2+
box-shadow: inset 0px 10px 20px rgba(0,0,0,0.35);
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.click-inset
2+
click-inset()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.click-shadow:active {
2+
box-shadow: 0px 2px 10px 2px rgba(0,0,0,0.25);
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.click-shadow
2+
click-shadow()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.click-shrink:active {
2+
-webkit-transform: scale(0.92);
3+
-moz-transform: scale(0.92);
4+
-o-transform: scale(0.92);
5+
-ms-transform: scale(0.92);
6+
transform: scale(0.92);
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.click-shrink
2+
click-shrink()

test/test.coffee

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ describe 'interaction', ->
151151
it 'hover-float', (done) ->
152152
compile_and_match(path.join(@path, 'hover-float.styl'), done)
153153

154+
it 'click-down', (done) ->
155+
compile_and_match(path.join(@path, 'click-down.styl'), done)
156+
157+
it 'click-shadow', (done) ->
158+
compile_and_match(path.join(@path, 'click-shadow.styl'), done)
159+
160+
it 'click-inset', (done) ->
161+
compile_and_match(path.join(@path, 'click-inset.styl'), done)
162+
163+
it 'click-shrink', (done) ->
164+
compile_and_match(path.join(@path, 'click-shrink.styl'), done)
165+
154166
describe 'layout', ->
155167

156168
before -> @path = path.join(test_path, 'layout')

0 commit comments

Comments
 (0)