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