_mixins.scss 11.2 KB
Newer Older
1 2
////////////////////////////////////////
// Widget Common Mixins
3 4
@use "sass:math";

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
@mixin boxShadow($arguments) {
  box-shadow: #{$arguments};
}

@mixin defaultBoxShadow() {
  @include boxShadow("0 1px 2px rgba(0, 0, 0, 0.3)");
}

@mixin borderBoxShadow($color: $border-color) {
  box-shadow: 0 0 0 1px $color;
}

@mixin cardBoxShadow($color: $border-color) {
  box-shadow: 0 1px 0 $color;
}

@mixin pointerStyle($width, $height) {
  position: absolute;
  width: $width + px;
  height: $height + px;
杨思琦's avatar
杨思琦 committed
25
  content: "";
26 27 28
}

@mixin outlineStyle() {
杨思琦's avatar
杨思琦 committed
29
  z-index: 1;
30 31 32 33 34 35
  outline: 2px solid $interactive-font-color;
  outline-offset: 2px;
}

@mixin popupHeight_BasedOnViewSize($height) {
  $pageMenuHeight: $height - 50;
杨思琦's avatar
杨思琦 committed
36

37 38 39
  .esri-popup__main-container {
    max-height: $height;
  }
杨思琦's avatar
杨思琦 committed
40

41 42 43 44 45 46 47 48 49 50
  &.esri-popup--feature-menu-open {
    .esri-popup__feature-menu-viewport {
      max-height: $pageMenuHeight;
    }
  }
}

@mixin wordbreak() {
  /* For Firefox */
  white-space: pre-wrap;
杨思琦's avatar
杨思琦 committed
51 52
  word-break: break-word;

53 54 55 56 57 58 59 60 61 62 63
  /**
  * IE should ignore these.
  * Modern browsers should override break-all.
  */
  word-wrap: break-word;
}

// Smart Mapping Sliders
@mixin smartMappingSlider($class) {
  .#{$class} {
    min-width: $smartmapping-slider__width;
杨思琦's avatar
杨思琦 committed
64
    direction: ltr;
65 66

    .esri-slider {
杨思琦's avatar
杨思琦 committed
67 68
      position: relative;
      z-index: 1;
69 70 71 72 73
      font-size: $font-size--small;

      .esri-slider__content {
        flex-direction: row;
        margin: 0 auto 0 40%;
杨思琦's avatar
杨思琦 committed
74
        height: $smartmapping-slider__base-height;
75 76 77 78 79
      }

      .esri-slider__track {
        display: flex;
        flex: 0 0 auto;
杨思琦's avatar
杨思琦 committed
80
        background-color: transparent;
81 82 83 84
      }

      .esri-slider__anchor {
        border-top: 1px solid $background-color;
杨思琦's avatar
杨思琦 committed
85
        border-bottom: 1px solid $interactive-font-color;
86 87 88 89 90 91 92 93 94 95
        width: $smartmapping-slider__ramp-width;

        &:hover,
        &:focus {
          .esri-slider__label {
            text-decoration: underline;
          }

          .esri-slider__thumb {
            transform: none;
杨思琦's avatar
杨思琦 committed
96 97
            border: none;
            background-color: $interactive-font-color--hover;
98

杨思琦's avatar
杨思琦 committed
99
            &::after {
100 101
              border-left-color: $interactive-font-color--hover;
            }
杨思琦's avatar
杨思琦 committed
102 103

            &::before {
104
              transform: translate3d(-$smartmapping-slider__thumb-size--offset * 0.25, 0, 0);
杨思琦's avatar
杨思琦 committed
105
              background-color: $button-color--bright;
106 107 108 109 110 111 112
            }
          }
        }
      }

      .esri-slider__thumb {
        top: -$smartmapping-slider__thumb-size--offset;
杨思琦's avatar
杨思琦 committed
113 114 115 116
        left: -$smartmapping-slider__thumb-size;
        border: none;
        border-radius: 0;
        background-color: $smartmapping-slider__thumb-background-color;
117
        width: $smartmapping-slider__thumb-size--offset;
杨思琦's avatar
杨思琦 committed
118
        height: $smartmapping-slider__thumb-size;
119

杨思琦's avatar
杨思琦 committed
120
        &::before {
121 122
          position: absolute;
          top: 0;
123
          left: -$smartmapping-slider__thumb-size--offset * 0.25;
杨思琦's avatar
杨思琦 committed
124 125 126 127
          transition:
            transform 125ms ease-in-out,
            background-color 125ms ease-in-out;
          background-color: $interactive-font-color;
128
          width: $smartmapping-slider__thumb-size--offset * 0.5;
129
          height: $smartmapping-slider__thumb-size;
杨思琦's avatar
杨思琦 committed
130
          content: "";
131
        }
杨思琦's avatar
杨思琦 committed
132 133

        &::after {
134 135 136
          position: absolute;
          top: 0;
          left: $smartmapping-slider__thumb-size--offset;
杨思琦's avatar
杨思琦 committed
137
          border-top: $smartmapping-slider__thumb-pointer-size solid #0000;
138 139 140
          border-bottom: $smartmapping-slider__thumb-pointer-size solid #0000;
          border-left: $smartmapping-slider__thumb-pointer-size solid $interactive-font-color;
          width: 0;
杨思琦's avatar
杨思琦 committed
141 142
          height: 0;
          content: "";
143 144 145 146
        }
      }

      .esri-slider__label {
杨思琦's avatar
杨思琦 committed
147
        right: 50px;
148 149 150
        left: auto;
        min-width: 50px;
        text-align: right;
杨思琦's avatar
杨思琦 committed
151
        line-height: 20px;
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166

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

      .esri-slider__segment {
        &:hover {
          cursor: default;
        }
      }

      .esri-slider__range-input {
        margin: auto;
        width: 50%;
杨思琦's avatar
杨思琦 committed
167
        text-align: center;
168 169 170 171
      }

      .esri-slider__label-input {
        width: 70px;
杨思琦's avatar
杨思琦 committed
172
        text-align: right;
173 174 175 176
      }

      .esri-slider__max,
      .esri-slider__min {
杨思琦's avatar
杨思琦 committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
        position: relative;
        flex: none;
        z-index: 0;
        margin: $cap-spacing--three-quarters auto;
        padding: $cap-spacing--three-quarters $cap-spacing;
        width: auto;

        &::before {
          position: absolute;
          top: 0;
          left: 0;
          z-index: -1;
          width: 100%;
          height: 100%;
          content: "";
        }

        &.esri-slider__range--active {
          background-color: $background-color;
        }

        .esri-slider__range-input {
          margin: 0 auto;
        }
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
      }

      .esri-slider__extra-content {
        display: flex;
        height: 100%;
      }

      .esri-histogram__svg {
        overflow: visible;
      }

      .esri-histogram__label {
        fill: $font-color;
        stroke-width: 2;
      }

      .esri-histogram__average-line,
      .esri-histogram__label {
        paint-order: stroke;
        stroke: $background-color;
      }

      .zoom-cap--max {
        position: absolute;
        top: 0;
      }

      .zoom-cap--min {
        position: absolute;
        bottom: 0;
      }

      .zoom-cap {
        width: $smartmapping-slider__ramp-width;
杨思琦's avatar
杨思琦 committed
235
        height: 11px;
236 237 238 239 240 241 242 243
        stroke-width: 0;

        &:hover {
          cursor: pointer;

          .zoom-cap--mask {
            fill: #fff;
          }
杨思琦's avatar
杨思琦 committed
244

245 246 247
          .zoom-cap--line {
            fill: #0079c1;
          }
杨思琦's avatar
杨思琦 committed
248

249 250 251 252
          .zoom-cap--underline {
            fill: #fff;
          }
        }
杨思琦's avatar
杨思琦 committed
253 254 255 256 257 258 259 260 261 262 263 264

        .zoom-cap--mask {
          fill: #fff;
        }

        .zoom-cap--line {
          fill: #fff;
        }

        .zoom-cap--underline {
          fill: #323232;
        }
265 266 267 268 269 270 271
      }
    }
  }

  .#{$class}__ramp {
    display: flex;
    position: relative;
杨思琦's avatar
杨思琦 committed
272 273
    width: $smartmapping-slider__ramp-width;
    height: 100%;
274 275 276

    svg {
      position: absolute;
杨思琦's avatar
杨思琦 committed
277 278 279
      left: 0;
      width: 100%;
      height: 100%;
280 281 282 283 284
      stroke: $smartmapping-slider__ramp-stroke-color;
      stroke-width: $smartmapping-slider__ramp-stroke-width;

      rect {
        width: 100%;
杨思琦's avatar
杨思琦 committed
285
        height: 100%;
286 287 288 289 290 291 292 293 294 295 296 297
      }

      path {
        stroke-width: $smartmapping-slider__ramp-path-stroke-width;
      }
    }
  }

  .#{$class}__histogram-container {
    display: flex;
    flex: 1 1 0;
    width: $smartmapping-slider__histogram-width;
杨思琦's avatar
杨思琦 committed
298
    height: 100%;
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
  }

  .#{$class}.#{$class}--interactive-track {
    .esri-slider {
      .esri-slider__content {
        margin: 0 auto 0 35%;
      }

      .esri-slider__track {
        background-color: transparent;
        width: 12px;
      }
    }

    .esri-slider__anchor--active {
      .esri-slider__label {
        text-decoration: underline;
      }
杨思琦's avatar
杨思琦 committed
317

318 319
      .esri-slider__thumb {
        transform: none;
杨思琦's avatar
杨思琦 committed
320 321 322 323
        border: none;
        background-color: $interactive-font-color--hover;

        &::after {
324 325
          border-left-color: $interactive-font-color--hover;
        }
杨思琦's avatar
杨思琦 committed
326 327

        &::before {
328
          transform: translate3d(-$smartmapping-slider__thumb-size--offset * 0.25, 0, 0);
杨思琦's avatar
杨思琦 committed
329
          background-color: $button-color--bright;
330 331 332 333 334
        }
      }
    }

    .esri-slider__segment--interactive {
杨思琦's avatar
杨思琦 committed
335
      background-image: url("../base/images/SM-Slider_TrackBackground_idle.svg");
336
      background-position: 50% 50%;
杨思琦's avatar
杨思琦 committed
337 338
      background-repeat: no-repeat;
      background-size: 12px 100%;
339 340 341

      &:hover,
      &:focus {
杨思琦's avatar
杨思琦 committed
342 343
        background-color: #eee;
        background-image: url("../base/images/SM-Slider_TrackBackground_hover.svg");
344
        cursor: pointer;
杨思琦's avatar
杨思琦 committed
345 346 347
      }

      &.esri-slider__segment--active {
348
        background-color: #eee;
杨思琦's avatar
杨思琦 committed
349
        background-image: url("../base/images/SM-Slider_TrackBackground_hover.svg");
350 351 352 353 354 355 356 357 358 359 360
      }
    }
  }
}

@mixin loopingProgressBar($selector) {
  #{$selector}:before,
  #{$selector}:after {
    position: absolute;
    top: 0;
    transition: opacity 500ms ease-in-out;
杨思琦's avatar
杨思琦 committed
361 362 363
    opacity: 1;
    height: 1px;
    content: "";
364 365
  }
  #{$selector}:before {
杨思琦's avatar
杨思琦 committed
366
    z-index: 0;
367 368 369 370
    background-color: $border-color;
    width: 100%;
  }
  #{$selector}:after {
杨思琦's avatar
杨思琦 committed
371
    z-index: 0;
372 373 374 375 376 377 378 379 380 381 382 383
    background-color: $interactive-font-color;
    width: $looping-progress-bar-width;
    animation: looping-progresss-bar-ani $looping-progress-bar-params;
  }
}

/**
 * Adds the base styles for an arrow facing down.
 */
@mixin arrowButton() {
  $size: 18px;
  $icon-size: 10px;
384
  $padding: ($size - $icon-size) * 0.5;
385

杨思琦's avatar
杨思琦 committed
386
  @extend .esri-icon-left;
387

杨思琦's avatar
杨思琦 committed
388
  appearance: none;
389 390 391
  transition: all 0.1s ease-in-out;
  border: none;
  background: none;
杨思琦's avatar
杨思琦 committed
392 393 394 395 396 397 398
  cursor: pointer;
  padding: $padding;
  width: $size;
  height: $size;
  text-align: center;
  line-height: $icon-size;
  font-size: $icon-size;
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423

  &:hover:not(:disabled) {
    background: $background-color--hover;
  }

  &:disabled {
    opacity: 0.4;
    cursor: default;
  }

  &.esri-arrow-down {
    transform: rotate(-90deg);
  }

  &.esri-arrow-up {
    transform: rotate(90deg);
  }

  &.esri-arrow-left {
    transform: rotate(0deg);
  }

  &.esri-arrow-right {
    transform: rotate(180deg);
  }
杨思琦's avatar
杨思琦 committed
424 425 426 427

  @each $icomoon-selector in $icomoon-selectors {
    @extend #{$icomoon-selector};
  }
428 429 430 431 432 433 434 435 436
}

/**
* Styles for Sortable
*/
@mixin sortableChosen($selector) {
  transition: background-color 125ms ease-in-out;
  &.#{$selector} {
    opacity: $opacity--sortable;
杨思琦's avatar
杨思琦 committed
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
    background-color: $background-color--active;
  }
}

@mixin timeSlider() {
  $tick-width: 1px;
  $focus-ring-width: 2px;
  $thumb-size: 16px;
  $tick-padding: 3px;
  $tick-height: 3px;
  $tick-height-primary: 6px;

  .esri-slider.esri-slider--horizontal {
    flex-grow: 1;
    padding: 30px 13px 28px 13px;
    width: inherit;

    .esri-widget__anchor,
    .esri-slider__anchor {
      outline: none !important;
      color: inherit;
    }

    .esri-slider__anchor:focus .esri-slider__thumb {
      outline: solid $focus-ring-width $border-color--active;
      outline-offset: $focus-ring-width;
      overflow: visible;
    }

    .esri-slider__segment.esri-slider__segment-0 {
      background-color: unset; // Reset blue first segment
    }

    .esri-slider__thumb {
      top: -$thumb-size * 0.5;
      left: -$thumb-size * 0.5;
      width: $thumb-size;
      height: $thumb-size;
    }

    .esri-slider__tick {
      margin: -$tick-padding;
      background: none;
      padding: $tick-padding; // Make ticks slightly easier to click on
      width: $tick-width + ($tick-padding * 2);
      height: 20px;

      &::after {
        display: block;
        background: #6e6e6e66;
        width: $tick-width;
        content: "";
      }

      &.secondary-tick::after {
        height: $tick-height;
      }

      &.primary-tick {
        &::after {
          height: $tick-height-primary;
        }

        .primary-tick__ampm {
          font-size: $font-size--tiny;
        }
      }
    }

    .esri-slider__ticks {
      margin: 0;
      margin-top: $cap-spacing--half;
      width: calc(100% - #{$tick-width});
    }

    .esri-slider__tick-label {
      margin-top: $cap-spacing;
      text-align: center;
      line-height: normal;
      font-size: $font-size--tiny-time-slider;
    }

    .esri-slider__label {
      font-size: $font-size--small;
    }

    .esri-slider__label-input {
      font-size: $font-size--tiny-time-slider;
    }
  }
}