_split-buttons.scss 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. // Foundation by ZURB
  2. // foundation.zurb.com
  3. // Licensed under MIT Open Source
  4. @import "global";
  5. @import "buttons";
  6. @import "dropdown-buttons";
  7. //
  8. // @name _split-buttons.scss
  9. // @dependencies _buttons.scss, _global.scss
  10. //
  11. //
  12. // @variables
  13. //
  14. $include-html-button-classes: $include-html-classes !default;
  15. // We use these to control different shared styles for Split Buttons
  16. $split-button-function-factor: 10% !default;
  17. $split-button-pip-color: $white !default;
  18. $split-button-pip-color-alt: $oil !default;
  19. $split-button-active-bg-tint: rgba(0,0,0,0.1) !default;
  20. // We use these to control tiny split buttons
  21. $split-button-padding-tny: $button-pip-tny * 10 !default;
  22. $split-button-span-width-tny: $button-pip-tny * 6 !default;
  23. $split-button-pip-size-tny: $button-pip-tny !default;
  24. $split-button-pip-top-tny: $button-pip-tny * 2 !default;
  25. $split-button-pip-default-float-tny: rem-calc(-6) !default;
  26. // We use these to control small split buttons
  27. $split-button-padding-sml: $button-pip-sml * 10 !default;
  28. $split-button-span-width-sml: $button-pip-sml * 6 !default;
  29. $split-button-pip-size-sml: $button-pip-sml !default;
  30. $split-button-pip-top-sml: $button-pip-sml * 1.5 !default;
  31. $split-button-pip-default-float-sml: rem-calc(-6) !default;
  32. // We use these to control medium split buttons
  33. $split-button-padding-med: $button-pip-med * 9 !default;
  34. $split-button-span-width-med: $button-pip-med * 5.5 !default;
  35. $split-button-pip-size-med: $button-pip-med - rem-calc(3) !default;
  36. $split-button-pip-top-med: $button-pip-med * 1.5 !default;
  37. $split-button-pip-default-float-med: rem-calc(-6) !default;
  38. // We use these to control large split buttons
  39. $split-button-padding-lrg: $button-pip-lrg * 8 !default;
  40. $split-button-span-width-lrg: $button-pip-lrg * 5 !default;
  41. $split-button-pip-size-lrg: $button-pip-lrg - rem-calc(6) !default;
  42. $split-button-pip-top-lrg: $button-pip-lrg + rem-calc(5) !default;
  43. $split-button-pip-default-float-lrg: rem-calc(-6) !default;
  44. //
  45. // @mixins
  46. //
  47. // We use this mixin to create split buttons that build upon the button mixins
  48. //
  49. // $padding - Type of padding to apply. Default: medium. Options: tiny, small, medium, large.
  50. // $pip-color - Color of the triangle. Default: $split-button-pip-color.
  51. // $span-border - Border color of button divider. Default: $primary-color.
  52. // $base-style - Apply base style to split button. Default: true.
  53. @mixin split-button(
  54. $padding:medium,
  55. $pip-color:$split-button-pip-color,
  56. $span-border:$primary-color,
  57. $base-style:true) {
  58. // With this, we can control whether or not the base styles come through.
  59. @if $base-style {
  60. position: relative;
  61. // Styling for the split arrow clickable area
  62. span {
  63. display: block;
  64. height: 100%;
  65. position: absolute;
  66. #{$opposite-direction}: 0;
  67. top: 0;
  68. border-#{$default-float}: solid 1px;
  69. // Building the triangle pip indicator
  70. &:after {
  71. position: absolute;
  72. content: "";
  73. width: 0;
  74. height: 0;
  75. display: block;
  76. border-style: inset;
  77. top: 50%;
  78. #{$default-float}: 50%;
  79. }
  80. &:active { background-color: $split-button-active-bg-tint; }
  81. }
  82. }
  83. // Control the border color for the span area of the split button
  84. @if $span-border {
  85. span {
  86. border-#{$default-float}-color: rgba(255,255,255,0.5);
  87. }
  88. }
  89. // Style of the button and clickable area for tiny sizes
  90. @if $padding == tiny {
  91. padding-#{$opposite-direction}: $split-button-padding-tny;
  92. span { width: $split-button-span-width-tny;
  93. &:after {
  94. border-top-style: solid;
  95. border-width: $split-button-pip-size-tny;
  96. top: 48%;
  97. margin-#{$default-float}: $split-button-pip-default-float-tny;
  98. }
  99. }
  100. }
  101. // Style of the button and clickable area for small sizes
  102. @else if $padding == small {
  103. padding-#{$opposite-direction}: $split-button-padding-sml;
  104. span { width: $split-button-span-width-sml;
  105. &:after {
  106. border-top-style: solid;
  107. border-width: $split-button-pip-size-sml;
  108. top: 48%;
  109. margin-#{$default-float}: $split-button-pip-default-float-sml;
  110. }
  111. }
  112. }
  113. // Style of the button and clickable area for default (medium) sizes
  114. @else if $padding == medium {
  115. padding-#{$opposite-direction}: $split-button-padding-med;
  116. span { width: $split-button-span-width-med;
  117. &:after {
  118. border-top-style: solid;
  119. border-width: $split-button-pip-size-med;
  120. top: 48%;
  121. margin-#{$default-float}: $split-button-pip-default-float-med;
  122. }
  123. }
  124. }
  125. // Style of the button and clickable area for large sizes
  126. @else if $padding == large {
  127. padding-#{$opposite-direction}: $split-button-padding-lrg;
  128. span { width: $split-button-span-width-lrg;
  129. &:after {
  130. border-top-style: solid;
  131. border-width: $split-button-pip-size-lrg;
  132. top: 48%;
  133. margin-#{$default-float}: $split-button-pip-default-float-lrg;
  134. }
  135. }
  136. }
  137. // Control the color of the triangle pip
  138. @if $pip-color {
  139. span:after { border-color: $pip-color transparent transparent transparent; }
  140. }
  141. }
  142. @include exports("split-button") {
  143. @if $include-html-button-classes {
  144. .split.button { @include split-button;
  145. &.secondary { @include split-button(false, $split-button-pip-color, $secondary-color, false); }
  146. &.alert { @include split-button(false, false, $alert-color, false); }
  147. &.success { @include split-button(false, false, $success-color, false); }
  148. &.tiny { @include split-button(tiny, false, false, false); }
  149. &.small { @include split-button(small, false, false, false); }
  150. &.large { @include split-button(large, false, false, false); }
  151. &.expand { padding-left: 2rem; }
  152. &.secondary { @include split-button(false, $split-button-pip-color-alt, false, false); }
  153. &.radius span { @include side-radius($opposite-direction, $global-radius); }
  154. &.round span { @include side-radius($opposite-direction, 1000px); }
  155. &.no-pip{
  156. span:before{ border-style:none; }
  157. span:after{ border-style:none; }
  158. span>i{
  159. top: 50%;
  160. display: block;
  161. position: absolute;
  162. left: 50%;
  163. margin-left: -0.28889em;
  164. margin-top: -0.48889em;
  165. }
  166. }
  167. }
  168. }
  169. }