_dropdown-buttons.scss 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Foundation by ZURB
  2. // foundation.zurb.com
  3. // Licensed under MIT Open Source
  4. @import "global";
  5. //
  6. // @variables
  7. //
  8. $include-html-button-classes: $include-html-classes !default;
  9. // We use these to set the color of the pip in dropdown buttons
  10. $dropdown-button-pip-color: $white !default;
  11. $dropdown-button-pip-color-alt: $oil !default;
  12. // We use these to set the size of the pip in dropdown buttons
  13. $button-pip-tny: rem-calc(6) !default;
  14. $button-pip-sml: rem-calc(7) !default;
  15. $button-pip-med: rem-calc(9) !default;
  16. $button-pip-lrg: rem-calc(11) !default;
  17. // We use these to style tiny dropdown buttons
  18. $dropdown-button-padding-tny: $button-pip-tny * 7 !default;
  19. $dropdown-button-pip-size-tny: $button-pip-tny !default;
  20. $dropdown-button-pip-opposite-tny: $button-pip-tny * 3 !default;
  21. $dropdown-button-pip-top-tny: (-$button-pip-tny / 2) + rem-calc(1) !default;
  22. // We use these to style small dropdown buttons
  23. $dropdown-button-padding-sml: $button-pip-sml * 7 !default;
  24. $dropdown-button-pip-size-sml: $button-pip-sml !default;
  25. $dropdown-button-pip-opposite-sml: $button-pip-sml * 3 !default;
  26. $dropdown-button-pip-top-sml: (-$button-pip-sml / 2) + rem-calc(1) !default;
  27. // We use these to style medium dropdown buttons
  28. $dropdown-button-padding-med: $button-pip-med * 6 + rem-calc(3) !default;
  29. $dropdown-button-pip-size-med: $button-pip-med - rem-calc(3) !default;
  30. $dropdown-button-pip-opposite-med: $button-pip-med * 2.5 !default;
  31. $dropdown-button-pip-top-med: (-$button-pip-med / 2) + rem-calc(2) !default;
  32. // We use these to style large dropdown buttons
  33. $dropdown-button-padding-lrg: $button-pip-lrg * 5 + rem-calc(3) !default;
  34. $dropdown-button-pip-size-lrg: $button-pip-lrg - rem-calc(6) !default;
  35. $dropdown-button-pip-opposite-lrg: $button-pip-lrg * 2.5 !default;
  36. $dropdown-button-pip-top-lrg: (-$button-pip-lrg / 2) + rem-calc(3) !default;
  37. // @mixins
  38. //
  39. // Dropdown Button Mixin
  40. //
  41. // We use this mixin to build off of the button mixin and add dropdown button styles
  42. //
  43. // $padding - Determines the size of button you're working with. Default: medium. Options [tiny, small, medium, large]
  44. // $pip-color - Color of the little triangle that points to the dropdown. Default: $white.
  45. // $base-style - Add in base-styles. This can be set to false. Default:true
  46. @mixin dropdown-button($padding:medium, $pip-color:$white, $base-style:true) {
  47. // We add in base styles, but they can be negated by setting to 'false'.
  48. @if $base-style {
  49. position: relative;
  50. outline: none;
  51. // This creates the base styles for the triangle pip
  52. &::after {
  53. position: absolute;
  54. content: "";
  55. width: 0;
  56. height: 0;
  57. display: block;
  58. border-style: solid;
  59. border-color: $dropdown-button-pip-color transparent transparent transparent;
  60. top: 50%;
  61. }
  62. }
  63. // If we're dealing with tiny buttons, use these styles
  64. @if $padding == tiny {
  65. padding-#{$opposite-direction}: $dropdown-button-padding-tny;
  66. &:after {
  67. border-width: $dropdown-button-pip-size-tny;
  68. #{$opposite-direction}: $dropdown-button-pip-opposite-tny;
  69. margin-top: $dropdown-button-pip-top-tny;
  70. }
  71. }
  72. // If we're dealing with small buttons, use these styles
  73. @if $padding == small {
  74. padding-#{$opposite-direction}: $dropdown-button-padding-sml;
  75. &::after {
  76. border-width: $dropdown-button-pip-size-sml;
  77. #{$opposite-direction}: $dropdown-button-pip-opposite-sml;
  78. margin-top: $dropdown-button-pip-top-sml;
  79. }
  80. }
  81. // If we're dealing with default (medium) buttons, use these styles
  82. @if $padding == medium {
  83. padding-#{$opposite-direction}: $dropdown-button-padding-med;
  84. &::after {
  85. border-width: $dropdown-button-pip-size-med;
  86. #{$opposite-direction}: $dropdown-button-pip-opposite-med;
  87. margin-top: $dropdown-button-pip-top-med;
  88. }
  89. }
  90. // If we're dealing with large buttons, use these styles
  91. @if $padding == large {
  92. padding-#{$opposite-direction}: $dropdown-button-padding-lrg;
  93. &::after {
  94. border-width: $dropdown-button-pip-size-lrg;
  95. #{$opposite-direction}: $dropdown-button-pip-opposite-lrg;
  96. margin-top: $dropdown-button-pip-top-lrg;
  97. }
  98. }
  99. // We can control the pip color. We didn't use logic in this case, just set it and forget it.
  100. @if $pip-color {
  101. &::after { border-color: $pip-color transparent transparent transparent; }
  102. }
  103. }
  104. @include exports("dropdown-button") {
  105. @if $include-html-button-classes {
  106. .dropdown.button, button.dropdown { @include dropdown-button;
  107. &.tiny { @include dropdown-button(tiny,$base-style:false); }
  108. &.small { @include dropdown-button(small,$base-style:false); }
  109. &.large { @include dropdown-button(large,$base-style:false); }
  110. &.secondary:after { border-color: $dropdown-button-pip-color-alt transparent transparent transparent; }
  111. }
  112. }
  113. }