_alert-boxes.scss 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Foundation by ZURB
  2. // foundation.zurb.com
  3. // Licensed under MIT Open Source
  4. @import 'global';
  5. //
  6. // Alert Box Variables
  7. //
  8. $include-html-alert-classes: $include-html-classes !default;
  9. // We use this to control alert padding.
  10. $alert-padding-top: rem-calc(14) !default;
  11. $alert-padding-default-float: $alert-padding-top !default;
  12. $alert-padding-opposite-direction: $alert-padding-top + rem-calc(10) !default;
  13. $alert-padding-bottom: $alert-padding-top !default;
  14. // We use these to control text style.
  15. $alert-font-weight: $font-weight-normal !default;
  16. $alert-font-size: rem-calc(13) !default;
  17. $alert-font-color: $white !default;
  18. $alert-font-color-alt: scale-color($secondary-color, $lightness: -66%) !default;
  19. // We use this for close hover effect.
  20. $alert-function-factor: -14% !default;
  21. // We use these to control border styles.
  22. $alert-border-style: solid !default;
  23. $alert-border-width: 1px !default;
  24. $alert-border-color: scale-color($primary-color, $lightness: $alert-function-factor) !default;
  25. $alert-bottom-margin: rem-calc(20) !default;
  26. // We use these to style the close buttons
  27. $alert-close-color: $oil !default;
  28. $alert-close-top: 50% !default;
  29. $alert-close-position: rem-calc(4) !default;
  30. $alert-close-font-size: rem-calc(22) !default;
  31. $alert-close-opacity: .3 !default;
  32. $alert-close-opacity-hover: .5 !default;
  33. $alert-close-padding: 0 6px 4px !default;
  34. $alert-close-background: inherit !default;
  35. // We use this to control border radius
  36. $alert-radius: $global-radius !default;
  37. $alert-transition-speed: 300ms !default;
  38. $alert-transition-ease: ease-out !default;
  39. //
  40. // Alert Mixins
  41. //
  42. // We use this mixin to create a default alert base.
  43. @mixin alert-base {
  44. border-style: $alert-border-style;
  45. border-width: $alert-border-width;
  46. display: block;
  47. font-size: $alert-font-size;
  48. font-weight: $alert-font-weight;
  49. margin-bottom: $alert-bottom-margin;
  50. padding: $alert-padding-top $alert-padding-opposite-direction $alert-padding-bottom $alert-padding-default-float;
  51. position: relative;
  52. @include single-transition(opacity, $alert-transition-speed, $alert-transition-ease)
  53. }
  54. // We use this mixin to add alert styles
  55. //
  56. // $bg - The background of the alert. Default: $primary-color.
  57. @mixin alert-style($bg:$primary-color) {
  58. // This finds the lightness percentage of the background color.
  59. $bg-lightness: lightness($bg);
  60. // We control which background color and border come through.
  61. background-color: $bg;
  62. border-color: scale-color($bg, $lightness: $alert-function-factor);
  63. // We control the text color for you based on the background color.
  64. @if $bg-lightness > 70% { color: $alert-font-color-alt; }
  65. @else { color: $alert-font-color; }
  66. }
  67. // We use this to create the close button.
  68. @mixin alert-close {
  69. #{$opposite-direction}: $alert-close-position;
  70. background: $alert-close-background;
  71. color: $alert-close-color;
  72. font-size: $alert-close-font-size;
  73. line-height: .9;
  74. margin-top: -($alert-close-font-size / 2);
  75. opacity: $alert-close-opacity;
  76. padding: $alert-close-padding;
  77. position: absolute;
  78. top: $alert-close-top;
  79. &:hover,
  80. &:focus { opacity: $alert-close-opacity-hover; }
  81. }
  82. // We use this to quickly create alerts with a single mixin.
  83. //
  84. // $bg - Background of alert. Default: $primary-color.
  85. // $radius - Radius of alert box. Default: false.
  86. @mixin alert($bg:$primary-color, $radius:false) {
  87. @include alert-base;
  88. @include alert-style($bg);
  89. @include radius($radius);
  90. }
  91. @include exports("alert-box") {
  92. @if $include-html-alert-classes {
  93. .alert-box {
  94. @include alert;
  95. .close { @include alert-close; }
  96. &.radius { @include radius($alert-radius); }
  97. &.round { @include radius($global-rounded); }
  98. &.success { @include alert-style($success-color); }
  99. &.alert { @include alert-style($alert-color); }
  100. &.secondary { @include alert-style($secondary-color); }
  101. &.warning { @include alert-style($warning-color); }
  102. &.info { @include alert-style($info-color); }
  103. &.alert-close { opacity: 0}
  104. }
  105. }
  106. }