/***************************************************************************** * Open MCT, Copyright (c) 2014-2018, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * * Open MCT is licensed under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * * Open MCT includes source code licensed under additional open source * licenses. See the Open Source Licenses file (LICENSES.md) included with * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ /************************** GLYPHS */ @mixin glyphBefore($unicode, $family: 'symbolsfont') { &:before { content: $unicode; font-family: $family; } } @mixin glyphAfter($unicode, $family: 'symbolsfont') { &:after { content: $unicode; font-family: $family; } } @mixin glyphBg($glyphUrl) { background-image: $glyphUrl; background-position: center; background-size: contain; background-repeat: no-repeat; } [class*="icon-"] { &:before, &:after { -webkit-font-smoothing: antialiased; } } /************************** VISUALS */ @mixin ancillaryIcon($d, $c) { // Used for small icons used in combination with larger icons, // like the link and alert icons in tree items. color: $c; font-size: $d; line-height: $d; height: $d; width: $d; } @mixin isAlias() { &:after { color:$colorIconAlias; content: $glyph-icon-link; display: block; font-family: symbolsfont; position: absolute; text-shadow: rgba(black, 0.5) 0 1px 4px; top: auto; left: 0; bottom: 10%; right: auto; transform-origin: left bottom; transform: scale(0.5); } } @mixin bgDiagonalStripes($c: yellow, $a: 0.1, $d: 40px) { background-image: linear-gradient(-45deg, rgba($c, $a) 25%, transparent 25%, transparent 50%, rgba($c, $a) 50%, rgba($c, $a) 75%, transparent 75%, transparent 100% ); background-repeat: repeat; background-size: $d $d; } @mixin bgStripes($c: yellow, $a: 0.1, $bgsize: 5px, $angle: 90deg) { background-image: linear-gradient($angle, rgba($c, $a) 25%, transparent 25%, transparent 50%, rgba($c, $a) 50%, rgba($c, $a) 75%, transparent 75%, transparent 100% ); background-repeat: repeat; background-size: $bgsize $bgsize; } @mixin noColor() { // A "no fill/stroke" selection option. Used in palettes. $c: red; $s: 48%; $e: 52%; background-image: linear-gradient(-45deg, transparent $s - 5%, $c $s, $c $e, transparent $e + 5% ); background-repeat: no-repeat; background-size: contain; } @mixin bgTicks($c: $colorBodyFg, $repeatDir: 'x') { $deg: 90deg; @if ($repeatDir != 'x') { $deg: 0deg; $repeatDir: repeat-y; } @else { $repeatDir: repeat-x; } background-image: linear-gradient($deg, $c 1px, transparent 1px, transparent 100% ); background-repeat: $repeatDir; } @mixin bgVertStripes($c: yellow, $a: 0.1, $d: 40px) { @include background-image(linear-gradient(-90deg, rgba($c, $a) 0%, rgba($c, $a) 50%, transparent 50%, transparent 100% )); background-repeat: repeat; background-size: $d $d; } /************************** LAYOUT */ @mixin abs($m: 0) { position: absolute; top: $m; right: $m; bottom: $m; left: $m; } @mixin propertiesHeader() { border-radius: $smallCr; background-color: $colorInspectorSectionHeaderBg; color: $colorInspectorSectionHeaderFg; font-weight: normal; margin: 0 0 $interiorMarginSm 0; padding: $interiorMarginSm $interiorMargin; text-transform: uppercase; } @mixin modalFullScreen() { // Optional modifier that makes a c-menu more mobile-friendly position: fixed; border-radius: 0; top: 0; right: 0; bottom: 0; left: 0; } /************************** TEXT */ @mixin ellipsize() { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } @mixin reverseEllipsis() { @include ellipsize(); direction: rtl; unicode-bidi:bidi-override; } /************************** CONTROLS, BUTTONS */ @mixin hover { body.desktop & { &:hover { @content } } } @mixin htmlInputReset() { appearance: none; background: transparent; border: none; border-radius: 0; outline: none; text-align: inherit; &:focus { outline: 0; } } @mixin input-base() { @include htmlInputReset(); border-radius: $controlCr; &.error { background: $colorFormFieldErrorBg; color: $colorFormFieldErrorFg; } } @mixin nice-input($bg: $colorInputBg, $fg: $colorInputFg, $shdw: rgba(black, 0.5) 0 0 2px) { @include input-base(); background: $bg; color: $fg; box-shadow: inset $shdw; } @mixin reactive-input($bg: $colorInputBg, $fg: $colorInputFg) { @include input-base(); background: $bg; box-shadow: $shdwInput; color: $fg; &:focus { box-shadow: $shdwInputFoc; } @include hover() { &:not(:focus) { box-shadow: $shdwInputHov; } } } @mixin button($bg: $colorBtnBg, $fg: $colorBtnFg, $radius: $controlCr, $shdw: none) { // Is this being used? Remove if not. background: $bg; color: $fg; border-radius: $radius; box-shadow: $shdw; } @mixin cControl() { $fs: 1em; @include userSelectNone(); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; &:before, &:after { font-family: symbolsfont; display: block; flex: 0 0 auto; } &:after { font-size: 0.8em; } [class*="__label"] { @include ellipsize(); display: block; line-height: $fs; // Remove effect on top and bottom padding font-size: $fs; } } @mixin cButton() { @include cControl(); @include themedButton(); border-radius: $controlCr; color: $colorBtnFg; cursor: pointer; padding: $interiorMargin floor($interiorMargin * 1.25); @include hover() { background: $colorBtnBgHov; color: $colorBtnFgHov; } &[class*="--major"] { background: $colorBtnMajorBg; color: $colorBtnMajorFg; @include hover() { background: $colorBtnMajorBgHov; color: $colorBtnMajorFgHov; } } &[class*='--caution'] { background: $colorBtnCautionBg; color: $colorBtnCautionFg; &:hover { background: $colorBtnCautionBgHov; } } } @mixin cClickIcon() { // A clickable element that just includes the icon, no background // Padding is included to facilitate a bigger hit area // Make the icon bigger relative to its container @include cControl(); $pLR: 4px; $pTB: 3px; background: none; box-shadow: none; border-radius: $controlCr; color: $colorKey; cursor: pointer; padding: $pTB $pLR ; @include hover() { background: $colorClickIconBgHov; color: $colorClickIconFgHov; } &:before, *:before { // *:before handles any nested containers that may contain glyph elements // Needed for c-togglebutton. font-size: 1.25em; } } @mixin cCtrlWrapper { // Provides a wrapper around buttons and other controls // Contains control and provides positioning context for contained menu/palette. // Wraps --menu elements, contains button and menu overflow: visible; .c-menu { // Default position of contained menu top: 100%; left: 0; } &[class*='--menus-up'] { .c-menu { top: auto; bottom: 100%; } } &[class*='--menus-left'] { .c-menu { left: auto; right: 0; } } } @mixin wrappedInput() { // An input that is wrapped. Optionally includes a __label or icon element. // Based on .c-search. @include nice-input(); display: flex; align-items: center; padding-left: 4px; padding-right: 4px; &:before, [class*='__label'] { opacity: 0.5; } &:before { // Adds an icon. Content defined in class. direction: rtl; // Aligns glyph to right-hand side of container, for transition display: block; font-family: symbolsfont; flex: 0 0 auto; overflow: hidden; padding: 2px 0; // Prevents clipping transition: width 250ms ease; width: 1em; } &:hover { box-shadow: inset rgba(black, 0.8) 0 0px 2px; &:before { opacity: 0.9; } } &--major { padding: 4px; } &__input, input[type='text'], input[type='search'], input[type='number'] { background: none !important; box-shadow: none !important; // !important needed to override default for [input] flex: 1 1 auto; padding-left: 2px !important; padding-right: 2px !important; min-width: 10px; // Must be set to allow input to collapse below browser min } &.is-active { &:before { padding: 2px 0px; width: 0px; } } } /************************** MATH */ @function percentToDecimal($p) { @return $p / 100%; } @function decimalToPercent($d) { @return percentage($d); } /************************** UTILITIES */ @mixin browserPrefix($prop, $val) { #{$prop}: $val; -ms-#{$prop}: $val; -moz-#{$prop}: $val; -webkit-#{$prop}: $val; } @mixin userSelectNone() { @include browserPrefix(user-select, none); } @mixin cursorGrab() { cursor: grab; cursor: -webkit-grab; &:active { cursor: grabbing; cursor: -webkit-grabbing; } } @mixin test($c: deeppink, $a: 0.3) { background-color: rgba($c, $a) !important; }