forked from middleman/middleman
/
_fancy_buttons.sass
executable file
·172 lines (155 loc) · 5.96 KB
/
_fancy_buttons.sass
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@import compass/css3.sass
@import fancy_gradient.sass
!fb_gradient_style ||= "glossy"
!fb_invert_on_click ||= 1
!fb_font_size ||= 18px
!fb_color ||= #444
!fb_font_weight ||= "bold"
!fb_border_width ||= 1px
!fb_radius ||= 6px
!fb_light_text ||= #fff
!fb_dark_text ||= #222
!fb_gradient ||= 1
// Make a fancy button.
=fancy-button(!color= !fb_color, !font_size= !fb_font_size, !radius= !fb_radius, !border_width= !fb_border_width)
+fancy-button-structure(!font_size, !radius, !border_width)
+fancy-button-colors(!color)
// Style the button's colors, picking the most appropriate color set for the base color.
=fancy-button-colors(!color = !fb_color, !hover = 0, !active = 0)
+fb-color(!color, "default")
&.disabled:active, &.disabled:hover, &[disabled]:active, &[disabled]:hover
+fb-color(!color, "default")
&:hover, &:focus
@if !hover == 0
+fb-color(darken(!color, 3), "hover", !color)
@else
+fb-color(!hover, "hover")
&:active
@if !active == 0
+fb-color(darken(!color, 6), "active", !color)
@else
+fb-color(!active, "active")
=fancy-button-matte(!color= !fb_color, !font_size= !fb_font_size, !radius= !fb_radius, !border_width= !fb_border_width)
+fancy-button-structure(!font_size, !radius, !border_width)
+fancy-button-colors-matte(!color)
=fancy-button-custom(!color= !fb_color, !font_size= !fb_font_size, !radius= !fb_radius, !border_width= !fb_border_width)
+fancy-button-structure(!font_size, !radius, !border_width)
+fancy-button-colors-custom(!color, !font_size, !radius, !border_width)
=fancy-button-colors-matte(!color = !fb_color, !hover = 0, !active = 0)
!fb_current_style = !fb_gradient_style
!fb_gradient_style = "matte"
+fancy-button-colors(!color, !hover, !active)
!fb_gradient_style = !fb_current_style
=fancy-button-colors-custom(!color = !fb_color, !hover = 0, !active = 0)
!fb_current_style = !fb_gradient_style
!fb_gradient_style = "custom"
+fancy-button-colors(!color, !hover, !active)
!fb_gradient_style = !fb_current_style
// Default state color settings
=fb-color(!color, !state, !lumins = !color)
!gradient_top = lighten(!color, 15)
!gradient_bottom = darken(!color, 06)
!border_color = darken(!color, 08)
@if !fb_invert_on_click != 0
!border_color = darken(!color, 15)
@if saturation(!color) > 0
!color = saturate(!color, 40)
@else if luminosity(!lumins) >= luminosity(#aaa)
!color = lighten(!color, 20)
+fb-state-colors(!color, !gradient_top, !gradient_bottom, !border_color, !state, !lumins)
// Apply the button colors specified for the button state into which it is mixed.
=fb-state-colors(!color, !gradient_top, !gradient_bottom, !border, !state, !lumins = !color)
background-color= !color
@if !fb_gradient != 0
@if !fb_gradient_style == "glossy"
@if !fb_invert_on_click != 0 and !state == "active"
+invert-fancy-gradient(!gradient_top, !gradient_bottom)
@else
+fancy-gradient(!gradient_top, !gradient_bottom)
@else if !fb_gradient_style == "matte"
@if !fb_invert_on_click and !state == "active"
+invert-fancy-matte-gradient(!gradient_top, !gradient_bottom)
@else
+fancy-matte-gradient(!gradient_top, !gradient_bottom)
@else if !fb_gradient_style == "custom"
@if !fb_invert_on_click and !state == "active"
+invert-custom-fancy-gradient(!gradient_top, !gradient_bottom)
@else
+custom-fancy-gradient(!gradient_top, !gradient_bottom)
border:
color= !border
!text_shadow_settings = "0px 1px 1px"
@if !fb_invert_on_click != 0 and !state == "active"
!text_shadow_settings = "0px -1px -1px"
@if luminosity(!lumins) < luminosity(#aaa)
text-shadow= darken(!color, 25) !text_shadow_settings
color= !fb_light_text
@else
text-shadow= lighten(!color, 15) !text_shadow_settings
color= !fb_dark_text
=fancy-button-text-colors(!color, !hover, !active)
color= !color
&:hover, &:focus
color= !hover
&:active
color= !active
&.disabled:active, &.disabled:hover, &[disabled]:active, &[disabled]:hover
color= !color
// Apply this mixin to a nested element to style an arrow
=fancy-arrow(!font_size)
font-size= !font_size + 4px
line-height= !font_size - 4px
margin-left= 4px
// Layout the button's box
=fancy-button-structure(!font_size = !fb_font_size, !radius = !fb_radius, !border_width = !fb_border_width, !line_height = !font_size * 1.2)
+fb-reset
+fancy-button-size(!font_size, !radius, !border_width, !line_height)
=fancy-button-size(!font_size = !fb_font_size, !radius = !fb_radius, !border_width = !fb_border_width, !line_height = !font_size * 1.2)
// better padding for smaller buttons
!v_padding = 0
!h_padding = 0
@if !font_size > 15
!v_padding = floor(!font_size/3.5)
!h_padding = !font_size
@else
!v_padding = floor(!font_size/5)
!h_padding = floor(!font_size/1.2)
@if !radius > 0
+border-radius(!radius)
font-size= !font_size
line-height= !line_height
+fancy-button-padding(!v_padding, !h_padding, !border_width)
=fancy-button-padding(!v_padding, !h_padding, !border_width = !fb_border_width)
!v_padding_active = !v_padding - 1px
!h_padding_active = !h_padding - 1px
padding= !v_padding !h_padding
border-width= !border_width
&:active
padding= !v_padding_active !h_padding_active
border-width= !border_width + 1px
&.disabled:active, &[disabled]
padding= !v_padding !h_padding
border-width= !border_width
// Reset the button's important properties to make sure they behave correctly
=fb-reset(!font_weight = !fb_font_weight)
font-family: "Lucida Grande", Lucida, Arial, sans_serif
background: #{image_url("button_bg.png")} repeat-x bottom left
margin: 0
width: auto
overflow: visible
display: inline-block
cursor: pointer
text-decoration: none
border-style: solid
font-weight= !font_weight
&::-moz-focus-inner
border: none
padding: 0
&:focus
outline: none
&.disabled, &[disabled]
+disable-button
=disable-button(!opacity = .7)
+opacity(!opacity)
&:hover, &:focus
cursor: default