summaryrefslogtreecommitdiff
path: root/templates/assets/bootstrap-material-design/scss/mixins/_buttons.scss
blob: 9d849f19a76aeca6002852b40558fa9e778b1247 (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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// from bs mixins/buttons button-variant
@mixin bmd-button-variant($color, $background, $focus-background, $active-background, $border, $focus-border, $active-border) {
  color: $color;
  background-color: $background;
  border-color: $border;

  @include hover {
    color: $color;
    background-color: $focus-background;
    border-color: $focus-border;
  }

  &:focus,
  &.focus {
    color: $color;
    background-color: $focus-background;
    border-color: $focus-border;
  }

  &:active,
  &.active,
  .open > &.dropdown-toggle {
    color: $color;
    background-color: $focus-background;
    border-color: $focus-border;

    &:hover,
    &:focus,
    &.focus {
      color: $color;
      background-color: $active-background;
      border-color: $active-border;
    }
  }

  // when it is an icon, kill the active bg on open dropdown, but stabilize on hover
  .open > &.dropdown-toggle.bmd-btn-icon {
    color: inherit;
    background-color: $background;

    // leave hover on with the lighter focus color
    &:hover {
      background-color: $focus-background;
    }
  }

  &.disabled,
  &:disabled {
    &:focus,
    &.focus {
      background-color: $background;
      border-color: $border;
    }
    @include hover {
      background-color: $background;
      border-color: $border;
    }
  }
}

@mixin bmd-flat-button-variant(
  $color,
  $border: $bmd-btn-border,
  $focus-border: $bmd-btn-focus-bg,
  $active-border: $bmd-btn-active-bg
) {

  $background: $bmd-btn-bg;
  $focus-background: $bmd-btn-focus-bg;
  $active-background: $bmd-btn-active-bg;

  @include bmd-button-variant($color,
    $background,
    $focus-background,
    $active-background,
    $border,
    $focus-border,
    $active-border);

  // inverse color scheme
  .bg-inverse & {
    $focus-background: $bmd-inverse-btn-focus-bg;
    $focus-border: $bmd-inverse-btn-focus-bg;

    $active-background: $bmd-inverse-btn-active-bg;
    $active-border: $bmd-inverse-btn-active-bg;

    @include bmd-button-variant($color,
      $background,
      $focus-background,
      $active-background,
      $border,
      $focus-border,
      $active-border);
  }

  // reverse the above for links
  &.btn-link {
    background-color: transparent;
  }
}

@mixin bmd-flat-button-color() {

  @include bmd-flat-button-variant($bmd-btn-color);

  // flat bg with text color variations
  &.btn-primary {
    @include bmd-flat-button-variant($btn-primary-bg);
  }
  &.btn-secondary {
    @include bmd-flat-button-variant($btn-secondary-color);
  }
  &.btn-info {
    @include bmd-flat-button-variant($btn-info-bg);
  }
  &.btn-success {
    @include bmd-flat-button-variant($btn-success-bg);
  }
  &.btn-warning {
    @include bmd-flat-button-variant($btn-warning-bg);
  }
  &.btn-danger {
    @include bmd-flat-button-variant($btn-danger-bg);
  }
}

@mixin bmd-outline-button-color() {
  &.btn-outline,
  &.btn-outline-primary,
  &.btn-outline-secondary,
  &.btn-outline-info,
  &.btn-outline-success,
  &.btn-outline-warning,
  &.btn-outline-danger {
    border-color: currentColor;
    border-style: solid;
    border-width: 1px;
  }

  // flat bg with text and border color variations
  &.btn-outline {
    @include bmd-flat-button-variant($bmd-btn-color, $bmd-btn-color, $bmd-btn-color, $bmd-btn-color);
  }
  &.btn-outline-primary {
    @include bmd-flat-button-variant($btn-primary-bg, $btn-primary-bg, $btn-primary-bg, $btn-primary-bg);
  }
  &.btn-outline-secondary {
    @include bmd-flat-button-variant($btn-secondary-color, $btn-secondary-color, $btn-secondary-color, $btn-secondary-color);
  }
  &.btn-outline-info {
    @include bmd-flat-button-variant($btn-info-bg, $btn-info-bg, $btn-info-bg, $btn-info-bg);
  }
  &.btn-outline-success {
    @include bmd-flat-button-variant($btn-success-bg, $btn-success-bg, $btn-success-bg, $btn-success-bg);
  }
  &.btn-outline-warning {
    @include bmd-flat-button-variant($btn-warning-bg, $btn-warning-bg, $btn-warning-bg, $btn-warning-bg);
  }
  &.btn-outline-danger {
    @include bmd-flat-button-variant($btn-danger-bg, $btn-danger-bg, $btn-danger-bg, $btn-danger-bg);
  }
}

@mixin bmd-raised-button-variant($color, $background, $border) {

  // FIXME: SPEC - this should be the 600 color, how can we get that programmatically if at all? Or are we limited to the color palette only?
  $focus-background: contrast-color($background, darken($background, 4%), lighten($background, 4%));
  //$focus-background: darken($background, 10%);  // default bootstrap
  $focus-border: darken($border, 12%);

  $active-background: $focus-background;
  //$active-background: darken($background, 17%);
  $active-border: darken($border, 25%);

  @include bmd-button-variant($color,
    $background,
    $focus-background,
    $active-background,
    $border,
    $focus-border,
    $active-border);
}

@mixin bmd-raised-button-color() {

  &.btn-primary {
    @include bmd-raised-button-variant($btn-primary-color, $btn-primary-bg, $btn-primary-border);
  }
  &.btn-secondary {
    @include bmd-raised-button-variant($btn-secondary-color, $btn-secondary-bg, $btn-secondary-border);
  }
  &.btn-info {
    @include bmd-raised-button-variant($btn-info-color, $btn-info-bg, $btn-info-border);
  }
  &.btn-success {
    @include bmd-raised-button-variant($btn-success-color, $btn-success-bg, $btn-success-border);
  }
  &.btn-warning {
    @include bmd-raised-button-variant($btn-warning-color, $btn-warning-bg, $btn-warning-border);
  }
  &.btn-danger {
    @include bmd-raised-button-variant($btn-danger-color, $btn-danger-bg, $btn-danger-border);
  }
}

@mixin undo-bs-tab-focus() {
  // clear out the tab-focus() from BS
  &,
  &:active,
  &.active {
    &:focus,
    &.focus {
      //@include tab-focus();
      outline: 0;
    }
  }
}