summaryrefslogtreecommitdiffstats
path: root/afb-client/bower_components/foundation-apps/scss/components/_action-sheet.scss
blob: 28b945c2ffa8cc7ad9e283713f89063e61d5a7c7 (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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/*
  ACTION SHEET
  ------------

  A dropdown menu that sticks to the bottom of the screen on small devices, and becomes a dropdown menu on larger devices.
*/

/// @Foundation.settings
// Action Sheet
$actionsheet-background: white !default;
$actionsheet-border-color: #ccc !default;
$actionsheet-animate: transform opacity !default;
$actionsheet-animation-speed: 0.25s !default;
$actionsheet-width: 300px !default;
$actionsheet-radius: 4px !default;
$actionsheet-shadow: 0 -3px 10px rgba(black, 0.25) !default;
$actionsheet-padding: $global-padding !default;
$actionsheet-tail-size: 10px !default;

$actionsheet-popup-shadow: 0 0 10px rgba(black, 0.25) !default;

$actionsheet-link-color: #000 !default;
$actionsheet-link-background-hover: smartscale($actionsheet-background) !default;
///

/*
  Styles for the list inside an action sheet.
  Don't include this mixin if you want to build custom controls inside the sheet.
*/
@mixin action-sheet-menu(
  $padding: $actionsheet-padding,
  $color: $actionsheet-link-color,
  $border-color: $actionsheet-border-color,
  $background-hover: $actionsheet-link-background-hover
) {
  // Menu container
  ul {
    margin: -($padding);
    margin-top: 0;
    list-style-type: none;
    user-select: none;

    // If the menu has no content above it
    &:first-child {
      margin-top: -$padding;

      li:first-child {
        border-top: 0;
      }
    }

    // Menu links
    a {
      display: block;
      padding: $padding * 0.8;
      line-height: 1;
      color: $color;
      border-top: 1px solid $border-color;

      &:hover {
        color: $color;
        background: $background-hover;
      }
    }

    .alert > a {
      color: $alert-color;
    }
    .disabled > a {
      pointer-events: none;
      color: #999;
    }
  }
}

/*
  Styles for the action sheet container. Action sheets pin to the top or bottom of the screen.
*/
@mixin action-sheet(
  $position: bottom,
  $shadow: $actionsheet-shadow,
  $animate: $actionsheet-animate,
  $animation-speed: $actionsheet-animation-speed,
  $padding: $actionsheet-padding,
  $background: $actionsheet-background
) {
  position: fixed;
  left: 0;
  z-index: 1000;
  width: 100%;
  padding: $padding;
  background: $background;
  text-align: center;
  transition-property: $animate;
  transition-duration: $animation-speed;
  transition-timing-function: ease-out;

  @if hasvalue($shadow) {
    box-shadow: $shadow;
  }

  // Positions
  @if $position == bottom {
    bottom: 0;
    transform: translateY(100%);

    &.is-active {
      transform: translateY(0%);
    }
  }
  // These two don't quite work as planned yet
  @else if $position == top {
    top: 0;
    transform: translateY(-100%);

    &.is-active {
      transform: translateY(0%);
    }
  }
}

@mixin popup-menu(
  $position: bottom,
  $background: $actionsheet-background,
  $width: $actionsheet-width,
  $radius: $actionsheet-radius,
  $shadow: $actionsheet-popup-shadow,
  $tail-size: $actionsheet-tail-size
) {
  /*
    Core styles
  */
  position: absolute;
  left: 50%;
  width: $width;
  border-radius: $radius;
  opacity: 0;
  pointer-events: none;

  /*
    Menu shadow
  */
  @if hasvalue($shadow) {
    box-shadow: $shadow;
  }

  /*
    Active state
  */
  &.is-active {
    opacity: 1;
    pointer-events: auto;
  }

  /*
    Menu tail
  */
  &::before, &::after {
    content: '';
    position: absolute;
    left: 50%;
    display: block;
    width: 0px;
    height: 0px;
    border-left: $tail-size solid transparent;
    border-right: $tail-size solid transparent;
    margin-left: -($tail-size);
  }

  /*
    Positioning
  */
  @if $position == bottom {
    top: auto;
    bottom: 0;
    transform: translateX(-50%) translateY(110%);
    &.is-active {
      transform: translateX(-50%) translateY(100%);
    }

    &::before, &::after {
      top: -($tail-size);
      bottom: auto;
      border-top: 0;
      border-bottom: $tail-size solid $background;
    }
    &::before {
      top: -($tail-size + 2);
      border-bottom-color: rgba(black, 0.15);
    }

  }
  @else if $position == top {
    top: 0;
    bottom: auto;
    transform: translateX(-50%) translateY(-120%);
    &.is-active {
      transform: translateX(-50%) translateY(-110%);
    }

    &::before, &::after {
      top: auto;
      bottom: -($tail-size);
      border-top: $tail-size solid $background;
      border-bottom: 0;
    }
    &::before {
      bottom: -($tail-size + 2);
      border-top-color: rgba(black, 0.15);
    }
  }
}

@include exports(action-sheet) {
  .action-sheet-container {
    position: relative;
    display: inline-block;

    .button {
      margin-left: 0;
      margin-right: 0;
    }
  }
  .action-sheet {
    @include action-sheet;
    @include action-sheet-menu;

    @include breakpoint(medium) {
      @include popup-menu;

      &.top {
        @include popup-menu(top);
      }
    }

    &.primary {
      background: $primary-color;
      color: isitlight($primary-color);
      border: 0;
      &::before { display: none; }
      &::before, &::after { border-top-color: $primary-color; }
      &.top::before, &.top::after { border-bottom-color: $primary-color; }

      @include action-sheet-menu(
        $color: isitlight($primary-color),
        $border-color: smartscale($primary-color, 10%),
        $background-hover: smartscale($primary-color)
      );
    }
    &.dark {
      background: $dark-color;
      color: isitlight($dark-color);
      border: 0;
      &::before { display: none; }
      &::before, &::after { border-top-color: $dark-color; }
      &.top::before, &.top::after { border-bottom-color: $dark-color; }

      @include action-sheet-menu(
        $color: isitlight($dark-color),
        $border-color: smartscale($dark-color, 10%),
        $background-hover: smartscale($dark-color)
      );
    }
  }
}