_alerts_pattern_library_shim.scss 5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// 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
// ----------------------------

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
// Overrides for other things available in the UXPL but not here
// This is super gross. Don't do this in other places if you can avoid it.
$palette-brand-accent: #2991c3;
$palette-brand-back: #cce3f0;
$palette-warning-accent: #ffc01f;
$palette-warning-back: #fff9eb;
$palette-error-accent: #cb0712;
$palette-error-back: #feeced;
$palette-success-accent: #009b00;
$palette-success-back: #ecfaec;
$palette-grey-accent: #a0a0a0;
$palette-grey-back: #d9d9d9;
$spacing-vertical-xx-small: ($baseline / 4);
$spacing-vertical-x-small: ($baseline / 2);
$spacing-vertical-small: $baseline;
$spacing-horizontal-small: ($baseline / 2);
$spacing-horizontal-base: $baseline;
$font-size-small: 14px;
$bp-screen-md: 768px !default;
41 42 43 44

// ----------------------------
// #UTILITIES
// ----------------------------
45 46 47
@mixin alert($shim-alert-color, $shim-alert-color-glow) {
    border: 1px solid $shim-alert-color;
    box-shadow: inset 0 0 0 4px $shim-alert-color-glow;
48 49

    .alert-icon {
50 51
        color: $white;
        background-color: $shim-alert-color;
52 53 54 55
    }
}

@mixin alert-message($width) {
56 57 58 59 60 61 62 63 64
    box-sizing: border-box;

    @media (min-width: $bp-screen-md) {
        @include float(left);
        width: $width;
        padding: $spacing-vertical-small;
        padding-top: 0;
        padding-bottom: 0;
    }
65 66 67 68 69 70 71 72 73 74 75 76 77

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

// everything below here gets added specificity pattern-library-shim
.pattern-library-shim {
    // ----------------------------
    // #GENERAL
    // ----------------------------
    &.alert {
78 79 80 81
        background-color: $white;
        border: 1px solid $palette-grey-accent;
        padding: $spacing-vertical-small $spacing-horizontal-base;
        box-shadow: inset 0 0 0 4px $palette-grey-back;
82
        overflow: auto;
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

        &.alert-slim {
            padding: $spacing-vertical-x-small;

            .alert-message {
                padding: $spacing-vertical-small $spacing-horizontal-base;
                font-size: $font-size-small;

                .copy {
                    margin-bottom: 0;
                }
            }
        }

        &.alert-tiny {
            padding: $spacing-vertical-x-small;

            .alert-message {
                padding: $spacing-vertical-x-small $spacing-horizontal-small;
                font-size: $font-size-small;

                .copy {
                    margin-bottom: 0;

                    .icon {
                        display: inline-block;
                        margin-right: $baseline;
                    }
                }
            }
        }
114 115
    }

116 117 118
    .alert-icon {
        // hide icons on small screens
        display: none;
119

120 121 122
        @media (min-width: $bp-screen-md) {
            @include float(left);
            display: block;
123

124 125 126 127 128 129
            // create a circle around the icon
            border-radius: 50%;

            // create room around the icon for the circle
            padding: $spacing-vertical-x-small;
        }
130 131
    }

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

137
    .alert-message {
138 139 140
        @include alert-message(90%);
    }

141
    .alert-title {
142 143 144
        @extend %hd-5;
        @extend %headings-emphasized;

145 146 147 148
        @media (min-width: $bp-screen-md) {
            // shift the section up to make the alert more compact
            margin-top: - $spacing-vertical-x-small;
        }
149 150 151

    }

152
    .alert-copy {
153 154
        @extend %copy-base;

155 156 157 158
        @media (min-width: $bp-screen-md) {
            // shift the message down to be in line with the icon
            margin-top: $spacing-vertical-xx-small;
        }
159 160
    }

161
    .alert-copy-with-title {
162 163 164
        @extend %copy-base;
    }

165 166 167 168 169 170 171
    .alert-action {
        width: 100%;

        @media (min-width: $bp-screen-md) {
            @include float(right);
            width: inherit;
        }
172 173 174 175 176 177 178 179
    }

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

    // information-based alert
    &.alert-information {
180
        @include alert($palette-brand-accent, $palette-brand-back);
181 182 183 184
    }

    // warning-based alert
    &.alert-warning {
185
        @include alert($palette-warning-accent, $palette-warning-back);
186 187 188 189
    }

    // error-based alert
    &.alert-error {
190
        @include alert($palette-error-accent, $palette-error-back);
191 192 193 194
    }

    // success-based alert
    &.alert-success {
195
        @include alert($palette-success-accent, $palette-success-back);
196 197
    }
}