_dropdown-buttons.scss 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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:$dropdown-button-pip-color, $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. // This creates the base styles for the triangle pip
  51. &::after {
  52. border-color: $dropdown-button-pip-color transparent transparent transparent;
  53. border-style: solid;
  54. content: "";
  55. display: block;
  56. height: 0;
  57. position: absolute;
  58. top: 50%;
  59. width: 0;
  60. }
  61. }
  62. // If we're dealing with tiny buttons, use these styles
  63. @if $padding == tiny {
  64. padding-#{$opposite-direction}: $dropdown-button-padding-tny;
  65. &:after {
  66. border-width: $dropdown-button-pip-size-tny;
  67. #{$opposite-direction}: $dropdown-button-pip-opposite-tny;
  68. margin-top: $dropdown-button-pip-top-tny;
  69. }
  70. }
  71. // If we're dealing with small buttons, use these styles
  72. @if $padding == small {
  73. padding-#{$opposite-direction}: $dropdown-button-padding-sml;
  74. &::after {
  75. border-width: $dropdown-button-pip-size-sml;
  76. #{$opposite-direction}: $dropdown-button-pip-opposite-sml;
  77. margin-top: $dropdown-button-pip-top-sml;
  78. }
  79. }
  80. // If we're dealing with default (medium) buttons, use these styles
  81. @if $padding == medium {
  82. padding-#{$opposite-direction}: $dropdown-button-padding-med;
  83. &::after {
  84. border-width: $dropdown-button-pip-size-med;
  85. #{$opposite-direction}: $dropdown-button-pip-opposite-med;
  86. margin-top: $dropdown-button-pip-top-med;
  87. }
  88. }
  89. // If we're dealing with large buttons, use these styles
  90. @if $padding == large {
  91. padding-#{$opposite-direction}: $dropdown-button-padding-lrg;
  92. &::after {
  93. border-width: $dropdown-button-pip-size-lrg;
  94. #{$opposite-direction}: $dropdown-button-pip-opposite-lrg;
  95. margin-top: $dropdown-button-pip-top-lrg;
  96. }
  97. }
  98. // We can control the pip color. We didn't use logic in this case, just set it and forget it.
  99. @if $pip-color {
  100. &::after { border-color: $pip-color transparent transparent transparent; }
  101. }
  102. }
  103. @include exports("dropdown-button") {
  104. @if $include-html-button-classes {
  105. .dropdown.button, button.dropdown { @include dropdown-button;
  106. &.tiny { @include dropdown-button(tiny, $base-style:false); }
  107. &.small { @include dropdown-button(small, $base-style:false); }
  108. &.large { @include dropdown-button(large, $base-style:false); }
  109. &.secondary:after { border-color: $dropdown-button-pip-color-alt transparent transparent transparent; }
  110. }
  111. }
  112. }