summaryrefslogtreecommitdiff
path: root/app/assets/stylesheets/vendor/fancy-buttons/_fancy-buttons.scss
blob: 2e85caf3ab2b837bba9bf083001c98efdb7f4b27 (plain)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
@import "compass/css3/gradient";
@import "compass/css3/border-radius";
@import "compass/css3/opacity";
@import "compass/css3/text-shadow";
@import "compass/css3/box-shadow";
@import "compass/css3/background-clip";
@import "fancy-gradient";

$fb-gradient-style: glossy !default;
$fb-invert-on-click: 1 !default;
$fb-font-size: 18px !default;
$fb-color: #444444 !default;
$fb-font-weight: bold !default;
$fb-border-width: 1px !default;
$fb-radius: 6px !default;
$fb-light-text: white !default;
$fb-dark-text: #222222 !default;
$fb-gradient: 1 !default;
$fb-image-path: image-url("vendor/fancy-buttons/button_bg.png") !default;
$fb-allow-disabled: false !default;
$fb-line-height: 1.2em !default;

// Make a fancy button.
@mixin fancy-button($color: $fb-color, $font-size: $fb-font-size, $radius: $fb-radius, $border-width: $fb-border-width) {
  @include fancy-button-structure($font-size, $radius, $border-width);
  @include fancy-button-colors($color);
}

// Style the button's colors, picking the most appropriate color set for the base color.
@mixin fancy-button-colors($color: $fb-color, $hover: 0, $active: 0, $fb-allow-disabled: $fb-allow-disabled) {
  @include fb-color($color, "default");
  &:hover, &:focus {
    @if $hover == 0 {
      @include fb-color(darken($color, 3), "hover", $color); }
    @else {
      @include fb-color($hover, "hover"); } }
  &:active {
    @if $active == 0 {
      @include fb-color(darken($color, 6), "active", $color);
      @include box-shadow(darken($color, 15) 0 0.08em 0.2em 1px inset); }
    @else {
      @include fb-color($active, "active");
      @include box-shadow(darken($active, 9) 0 0.08em 0.1em 1px inset); } }
  @include box-shadow(rgba(white, lightness($color) / 100) 0 0 0.1em 1px inset);
  @include background-clip(padding-box);
  @if $fb-allow-disabled {
    &.disabled, &[disabled] {
      @include disable-fancy-button($color);
    }
  }
}

@mixin fancy-button-allow-disable($color: $fb-color, $font-size: $fb-font-size, $radius: $fb-radius, $border-width: $fb-border-width) {
  $fb-disable-allowed: $fb-allow-disabled;
  $fb-allow-disabled: true;
  @include fancy-button-structure($font-size, $radius, $border-width);
  @include fancy-button-colors-matte($color);
  $fb-allow-disabled: $fb-disable-allowed;
}

@mixin fancy-button-matte($color: $fb-color, $font-size: $fb-font-size, $radius: $fb-radius, $border-width: $fb-border-width) {
  @include fancy-button-structure($font-size, $radius, $border-width);
  @include fancy-button-colors-matte($color); 
}

@mixin fancy-button-custom($color: $fb-color, $font-size: $fb-font-size, $radius: $fb-radius, $border-width: $fb-border-width) {
  @include fancy-button-structure($font-size, $radius, $border-width);
  @include fancy-button-colors-custom($color, $font-size, $radius, $border-width); 
}

@mixin fancy-button-colors-matte($color: $fb-color, $hover: 0, $active: 0) {
  $fb-current-style: $fb-gradient-style;
  $fb-gradient-style: matte;
  @include fancy-button-colors($color, $hover, $active);
  $fb-gradient-style: $fb-current-style; 
}

@mixin fancy-button-colors-custom($color: $fb-color, $hover: 0, $active: 0) {
  $fb-current-style: $fb-gradient-style;
  $fb-gradient-style: custom;
  @include fancy-button-colors($color, $hover, $active);
  $fb-gradient-style: $fb-current-style;
}

// Default state color settings
@mixin fb-color($color, $state, $lumins: $color) {
  $gradient-top: lighten($color, 15);
  $gradient-bottom: darken($color, 6);
  $border-color: darken($color, 8);
  @if $fb-invert-on-click != 0 {
    $border-color: darken($color, 15); }
  @if saturation($color) > 0 {
    $color: saturate($color, 40); }
  @else if lightness($lumins) >= lightness(#aaaaaa) {
    $color: lighten($color, 20); }
  @include 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.
@mixin 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 $state == "active" {
        @include fancy-gradient-active($gradient-top, $gradient-bottom); }
      @else {
        @include fancy-gradient($gradient-top, $gradient-bottom); } }
    @else if $fb-gradient-style == "matte" {
      @if $state == "active" {
        @include fancy-matte-gradient-active($gradient-top, $gradient-bottom); }
      @else {
        @include fancy-matte-gradient($gradient-top, $gradient-bottom); } }
    @else if $fb-gradient-style == "custom" {
      @if $state == "active" {
        @include custom-fancy-gradient-active($gradient-top, $gradient-bottom); }
      @else {
        @include custom-fancy-gradient($gradient-top, $gradient-bottom); } } }
  border: {
    color: $border; };
  $text-shadow-settings: unquote("0px 1px 1px");
  @if $fb-invert-on-click != 0 and $state == "active" {
    $text-shadow-settings: unquote("0px -1px -1px"); }
  @if lightness($lumins) < lightness(#aaaaaa) {
    text-shadow: darken($color, 25) $text-shadow-settings;
    &, &:visited {
      color: $fb-light-text; } }
  @else {
    text-shadow: lighten($color, 15) $text-shadow-settings;
    &, &:visited {
      color: $fb-dark-text; } }
}

@mixin fancy-button-text-colors($color, $hover: $color, $active: $color, $fb-allow-disabled: $fb-allow-disabled) {
  &, &:visited {
    color: $color; }
  &:hover, &:focus {
    color: $hover; }
  &:active {
    color: $active; }
  @if $fb-allow-disabled {
    &.disabled, &[disabled] {
      color: $color; } }
}

// Layout the button's box
@mixin fancy-button-structure($font-size: $fb-font-size, $radius: $fb-radius, $border-width: $fb-border-width, $line-height: $fb-line-height) {
  @extend .fancy-button-reset-base-class;
  @include fancy-button-size($font-size, $radius, $border-width, $line-height);
}

@mixin fancy-button-size($font-size: $fb-font-size, $radius: $fb-radius, $border-width: $fb-border-width, $line-height: $fb-line-height) {
  // better padding for smaller buttons
  $v-padding: 0.3em;
  $h-padding: 1em;
  @if $radius > 0 {
    @include border-radius($radius); }
  font-size: $font-size;
  line-height: $line-height;
  @include fancy-button-padding($v-padding, $h-padding, $border-width);
}

@mixin fancy-button-padding($v-padding, $h-padding, $border-width: $fb-border-width) {
  padding: $v-padding $h-padding;
  border-width: $border-width;
}

// Reset the button's important properties to make sure they behave correctly
@mixin fb-reset($font-weight: $fb-font-weight) {
  font-family: "Lucida Grande", Lucida, Arial, sans-serif;
  background: #{$fb-image-path} 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; }
}

@mixin disable-fancy-button($color: $fb-color, $opacity: 0.7) {
  @include fb-color($color, "default");
  @include opacity($opacity);
  @include box-shadow(none);
  cursor: default !important;
}

.fancy-button-reset-base-class {
  @include fb-reset;
}