summaryrefslogtreecommitdiff
path: root/templates/assets/bootstrap-material-design/scss/_buttons.scss
blob: ee3defcf00596b3b68924c8249c4b4e5b6168f6c (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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
// specification: https://www.google.com/design/spec/components/buttons.html

// bmd default buttons are flat by default
.btn {
  position: relative;
  margin-bottom: $bmd-btn-margin-bottom; // just enough room so that focus shadows aren't covered up
  font-size: $bmd-btn-font-size;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: pointer;
  background-color: transparent;
  border: 0;
  outline: 0;
  transition: box-shadow 0.2s $bmd-animation-curve-fast-out-linear-in, background-color 0.2s $bmd-animation-curve-default, color 0.2s $bmd-animation-curve-default;
  will-change: box-shadow, transform;

  @include undo-bs-tab-focus();

  //--
  // Colors

  // flat removes bg, add color variations to text
  @include bmd-flat-button-color();

  // fab and raised
  //  - colored, add their text and bg
  //  - hover color contrasted
  //  - shared shadow state on hover/active/focus
  &.bmd-btn-fab,
  &.btn-raised,
  .btn-group-raised & {
    @include bmd-raised-button-color();

    // enlarged shadow on hover, focus
    @include hover-focus() {
      //border: 1px solid $blue;
      z-index: 1; // add to the z-index so that the expanded shadow is above anything below it i.e. another button
      @include box-shadow($bmd-shadow-4dp);
    }

    // :active - momentary press: big shadow, release and it is gone
    // .active - persistent big shadow
    &.active,
    &:active {
      z-index: 1; // add to the z-index so that the expanded shadow is above anything below it i.e. another button
      @include box-shadow($bmd-shadow-focus);
      //border: 1px solid $green;
    }
  }

  //---
  // btn-raised
  &.btn-raised,
  .btn-group-raised & {

    // baseline shadow
    @include box-shadow($bmd-shadow-2dp);

    // reverse any of the above for links
    &.btn-link {
      box-shadow: none;
      @include bmd-hover-focus-active() {
        box-shadow: none;
      }
    }

    @include bmd-disabled() {
      box-shadow: none;
    }
  }

  //---
  // btn-outline
  @include bmd-outline-button-color();

  // https://www.google.com/design/spec/components/buttons-floating-action-button.html
  &.bmd-btn-fab,
  &.bmd-btn-icon {
    overflow: hidden;
    font-size: $bmd-btn-fab-font-size;
    line-height: normal;

    .btn-group-lg &,
    .btn-group-sm &,
    & {
      padding: 0; // need specificity
      border-radius: 50%;
    }

    .material-icons {
      position: absolute;
      top: 50%;
      left: 50%;
      width: $bmd-btn-fab-font-size;
      line-height: $bmd-btn-fab-font-size;
      transform: translate(-($bmd-btn-fab-font-size / 2), -($bmd-btn-fab-font-size / 2));
    }
  }

  &.bmd-btn-fab {
    // see above for color variations
    width: $bmd-btn-fab-size;
    min-width: $bmd-btn-fab-size;
    height: $bmd-btn-fab-size;
    //margin: auto;
    //margin: 2px; // use z-index focus/hover/active instead. This is not called for in the spec, but it ensures room for the box-shadow, which is nice to have.
    box-shadow: 0 1px 1.5px 0 $gray-lighter, 0 1px 1px 0 $gray-light;

    .ripple-container {
      border-radius: 50%;
    }

    &.bmd-btn-fab-sm,
    .btn-group-sm & {
      width: $bmd-btn-fab-size-sm;
      min-width: $bmd-btn-fab-size-sm;
      height: $bmd-btn-fab-size-sm;
      //margin: 1px; // use z-index focus/hover/active instead. This is not called for in the spec, but it ensures room for the box-shadow, which is nice to have.

      //.material-icons {
      //  top: ($bmd-btn-icon-size-sm - $bmd-btn-fab-font-size) / 2;
      //  left: ($bmd-btn-icon-size-sm - $bmd-btn-fab-font-size) / 2;
      //}
    }
  }

  // Icon buttons
  &.bmd-btn-icon {
    width: $bmd-btn-icon-size;
    min-width: $bmd-btn-icon-size;
    height: $bmd-btn-icon-size;
    margin: 0;
    color: inherit;

    &.bmd-btn-icon-sm,
    .btn-group-sm & {
      width: $bmd-btn-icon-size-sm;
      min-width: $bmd-btn-icon-size-sm;
      height: $bmd-btn-icon-size-sm;
      font-size: $bmd-btn-icon-font-size-sm;

      .material-icons {
        //$position: ($bmd-btn-icon-size-sm - $bmd-btn-icon-font-size-sm) / 2;
        //top: $position;
        //left: $position;
        width: $bmd-btn-icon-font-size-sm;
        font-size: $bmd-btn-icon-font-size-sm;
        line-height: 1;
        transform: translate(-($bmd-btn-icon-font-size-sm / 2), -($bmd-btn-icon-font-size-sm / 2));
      }
    }
  }

  // Align icons inside buttons with text
  .material-icons {
    position: relative;
    top: .25em;
    margin-top: -1em;
    margin-bottom: -1em;
    font-size: 1.5em;
  }

  // Size variations
  &.btn-lg,
  .btn-group-lg & {
    @include button-size($btn-padding-y-lg, $btn-padding-x-lg, $bmd-btn-font-size-lg, $btn-border-radius-lg);
  }
  &.btn-sm,
  .btn-group-sm & {
    @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $bmd-btn-font-size-sm, $btn-border-radius-sm);
    font-size: $bmd-btn-font-size-sm;
  }
}

// Disabled buttons and button groups
.btn,
.input-group-btn .btn,
.btn-group,
.btn-group-vertical {
  // have to ratchet up the specificity to kill drop shadows on disabled raised buttons
  @include bmd-disabled() {
    color: $bmd-btn-disabled;
    .bg-inverse & {
      color: $bmd-inverse-btn-disabled;
    }

    // flat buttons shouldn't lose transparency on disabled hover/focus
    &,
    &:hover,
    &:focus {
      background: transparent;
    }
  }
}

// btn-group variations
.btn-group,
.btn-group-vertical {

  position: relative;
  margin: 10px 1px;

  // spec: https://www.google.com/design/spec/components/buttons.html#buttons-toggle-buttons
  //&.open {
  //  .dropdown-toggle {
  //  }
  //
  //  > .dropdown-toggle.btn {
  //    @include bmd-raised-button-color-bg();
  //  }
  //}

  .dropdown-menu {
    border-radius: 0 0 $border-radius $border-radius;
  }

  &.btn-group-raised {
    @include box-shadow($bmd-shadow-2dp);
  }

  .btn + .btn,
  .btn,
  .btn:active,
  .btn-group {
    margin: 0;
  }

  // remove margin from nested btn-group(s) to properly align them with the outer buttons
  > .btn-group {
    margin: 0;
  }
}