_alerts_pattern_library_shim.scss 4.53 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
@mixin alert($shim-alert-color, $shim-alert-color-glow) {
46 47
  border: 1px solid $shim-alert-color;
  box-shadow: inset 0 0 0 4px $shim-alert-color-glow;
48

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

@mixin alert-message($width) {
56
  box-sizing: border-box;
57

58 59
  @media (min-width: $bp-screen-md) {
    @include float(left);
60

61 62 63 64 65 66 67 68 69 70
    width: $width;
    padding: $spacing-vertical-small;
    padding-top: 0;
    padding-bottom: 0;
  }

  :last-child {
    // keeps the message compact
    margin-bottom: 0;
  }
71 72 73 74
}

// everything below here gets added specificity pattern-library-shim
.pattern-library-shim {
75 76 77 78 79 80 81 82 83 84 85 86 87 88
  // ----------------------------
  // #GENERAL
  // ----------------------------
  &.alert {
    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;
    overflow: auto;

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

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

92 93
        .copy {
          margin-bottom: 0;
94
        }
95 96
      }
    }
97

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

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

105 106
        .copy {
          margin-bottom: 0;
107

108 109 110 111
          .icon {
            display: inline-block;
            margin-right: $baseline;
          }
112
        }
113
      }
114
    }
115
  }
116

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

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

124
      display: block;
125

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

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

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

139 140 141
  .alert-message {
    @include alert-message(90%);
  }
142

143 144 145
  .alert-title {
    @extend %hd-5;
    @extend %headings-emphasized;
146

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

152
  }
153

154 155
  .alert-copy {
    @extend %copy-base;
156

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

163 164 165
  .alert-copy-with-title {
    @extend %copy-base;
  }
166

167 168
  .alert-action {
    width: 100%;
169

170 171
    @media (min-width: $bp-screen-md) {
      @include float(right);
172

173
      width: inherit;
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
  }

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

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

  // warning-based alert
  &.alert-warning {
    @include alert($palette-warning-accent, $palette-warning-back);
  }

  // error-based alert
  &.alert-error {
    @include alert($palette-error-accent, $palette-error-back);
  }

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