_alerts_pattern_library_shim.scss 3.88 KB
Newer Older
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
// lms alerts
// This file contains "I want alerts that look like the pattern library" sass
// and should be replaced when moving to the patter library proper
// https://github.com/edx/ux-pattern-library/blob/master/pattern-library/sass/patterns/_alerts.scss

// ------------------------------
// edX Pattern Library: Utilities - Alerts
//
// About: Contains base styling for alerts.
// ----------------------------

// #CONFIG
// #UTILITIES
// #GENERAL
// #INDIVIDUAL CASES


// ----------------------------
// #CONFIG
// ----------------------------

// alert colors
$alert-information-color: #6fa0ba;
$alert-warning-color: #fdbc56;
$alert-error-color: #b20610;
$alert-success-color: #25b85a;
$alert-background-color: #fcfcfc;
$alert-icon-color: #fcfcfc;
$alert-border-grey: #cdd7db;
$alert-shadow-grey: #eef1f2;

// alert borders
$alert-border-radius: 0.3125rem;
$alert-border: 0.0625rem solid $alert-border-grey;

// ----------------------------
// #UTILITIES
// ----------------------------
@mixin alert($alert-color) {
    border-top:  rem(2) solid $alert-color;

    .alert-icon {
        color: $alert-icon-color;
        background-color: $alert-color;
    }
}

@mixin alert-message($width) {
    @include float(left);
    width: $width;
    padding: 1.25rem;
    padding-top: 0;
    padding-bottom: 0;

    :last-child {
        // keeps the message compact
        margin-bottom: 0;
    }
}

// everything below here gets added specificity pattern-library-shim
.pattern-library-shim {

    // ----------------------------
    // #GENERAL
    // ----------------------------

    &.alert {
        background-color: $alert-background-color;
        border: $alert-border;
        border-radius: $alert-border-radius;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        padding: 1.25rem;
        overflow: auto;
        box-shadow: 0 rem(2) rem(2) 0 $alert-shadow-grey;
    }

    &.alert-icon {
        @include float(left);
        display: block;

        // create a circle around the icon
        border-radius: 50%;

        // create room around the icon for the circle
        padding: 0.625rem;
    }

    &.alert-message-with-action {
        // provide room for the action to be displayed next to the alert message
        @include alert-message(70%);
    }

    &.alert-message {
        @include alert-message(90%);
    }

    &.alert-title {
        @extend %hd-5;
        @extend %headings-emphasized;

        // shift the section up to make the alert more compact
        margin-top: -0.625rem;

    }

    &.alert-copy {
        @extend %copy-base;

        // shift the message down to be in line with the icon
        margin-top: 0.3125rem;
    }

    &.alert-copy-with-title {
        @extend %copy-base;
    }

    &.alert-action {
        @include float(right);
        width: inherit;
    }

    // ----------------------------
    // #INDIVIDUAL CASES
    // ----------------------------

    // information-based alert
    &.alert-information {
        @include alert($alert-information-color);
    }

    // warning-based alert
    &.alert-warning {
        @include alert($alert-warning-color);
    }

    // error-based alert
    &.alert-error {
        @include alert($alert-error-color);
    }

    // success-based alert
    &.alert-success {
        @include alert($alert-success-color);
    }

    // added from _icons.scss
    &.icon {
        display: inline-block;
        height: auto;
        width: auto;
        font-family: FontAwesome;
        speak: none;
        font-style: normal;
        font-weight: normal;
        font-variant: normal;
        text-transform: none;
        line-height: 1;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    &.icon-bullhorn:before {
        content: "\f0a1";
    }

    // handles negative margin on navigation bar
    &.subsection-header {
        margin-top: -4px;
        margin-bottom: 14px;
    }
}