_button-groups.scss 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. // Foundation by ZURB
  2. // foundation.zurb.com
  3. // Licensed under MIT Open Source
  4. @import 'global';
  5. @import 'buttons';
  6. //
  7. // Button Group Variables
  8. //
  9. $include-html-button-classes: $include-html-classes !default;
  10. // Sets the margin for the right side by default, and the left margin if right-to-left direction is used
  11. $button-bar-margin-opposite: rem-calc(10) !default;
  12. $button-group-border-width: 1px !default;
  13. //
  14. // Button Group Mixins
  15. //
  16. // We use this to add styles for a button group container
  17. @mixin button-group-container($styles:true, $float:false) {
  18. @if $styles {
  19. list-style: none;
  20. margin: 0;
  21. #{$default-float}: 0;
  22. @include clearfix();
  23. }
  24. @if $float {
  25. float: #{$default-float};
  26. margin-#{$opposite-direction}: $button-bar-margin-opposite;
  27. & div { overflow: hidden; }
  28. }
  29. }
  30. // We use this to control styles for button groups
  31. @mixin button-group-style($radius:false, $even:false, $float:false, $orientation:horizontal) {
  32. > button, .button {
  33. border-#{$default-float}: $button-group-border-width solid;
  34. border-color: rgba(255, 255, 255, .5);
  35. }
  36. &:first-child {
  37. button, .button {
  38. border-#{$default-float}: 0;
  39. }
  40. }
  41. $button-group-display: list-item;
  42. $button-group-margin: 0;
  43. // We use this to control the flow, or remove those styles completely.
  44. @if $float {
  45. $button-group-display: list-item;
  46. $button-group-margin: 0;
  47. float: $float;
  48. // Make sure the first child doesn't get the negative margin.
  49. &:first-child { margin-#{$default-float}: 0; }
  50. }
  51. @else {
  52. $button-group-display: inline-block;
  53. $button-group-margin: 0 -2px;
  54. }
  55. @if $orientation == vertical {
  56. $button-group-display: block;
  57. $button-group-margin: 0;
  58. > button, .button {
  59. border-color: rgba(255, 255, 255, .5);
  60. border-left-width: 0;
  61. border-top: $button-group-border-width solid;
  62. display: block;
  63. margin:0;
  64. }
  65. > button {
  66. width: 100%;
  67. }
  68. &:first-child {
  69. button, .button {
  70. border-top: 0;
  71. }
  72. }
  73. }
  74. display: $button-group-display;
  75. margin: $button-group-margin;
  76. // We use these to control left and right radius on first/last buttons in the group.
  77. @if $radius == true {
  78. &,
  79. > a,
  80. > button,
  81. > .button { @include radius(0); }
  82. &:first-child,
  83. &:first-child > a,
  84. &:first-child > button,
  85. &:first-child > .button {
  86. @if $orientation == vertical {
  87. @include side-radius(top, $button-radius);
  88. }
  89. @else {
  90. @include side-radius($default-float, $button-radius);
  91. }
  92. }
  93. &:last-child,
  94. &:last-child > a,
  95. &:last-child > button,
  96. &:last-child > .button {
  97. @if $orientation == vertical {
  98. @include side-radius(bottom, $button-radius);
  99. }
  100. @else {
  101. @include side-radius($opposite-direction, $button-radius);
  102. }
  103. }
  104. }
  105. @else if $radius {
  106. &,
  107. > a,
  108. > button,
  109. > .button { @include radius(0); }
  110. &:first-child,
  111. &:first-child > a,
  112. &:first-child > button,
  113. &:first-child > .button {
  114. @if $orientation == vertical {
  115. @include side-radius(top, $radius);
  116. }
  117. @else {
  118. @include side-radius($default-float, $radius);
  119. }
  120. }
  121. &:last-child,
  122. &:last-child > a,
  123. &:last-child > button,
  124. &:last-child > .button {
  125. @if $orientation == vertical {
  126. @include side-radius(bottom, $radius);
  127. }
  128. @else {
  129. @include side-radius($opposite-direction, $radius);
  130. }
  131. }
  132. }
  133. // We use this to make the buttons even width across their container
  134. @if $even {
  135. width: percentage((100/$even) / 100);
  136. button, .button { width: 100%; }
  137. }
  138. }
  139. @include exports("button-group") {
  140. @if $include-html-button-classes {
  141. .button-group { @include button-group-container;
  142. @for $i from 2 through 8 {
  143. &.even-#{$i} li { @include button-group-style($even:$i, $float:null); }
  144. }
  145. > li { @include button-group-style(); }
  146. &.stack {
  147. > li { @include button-group-style($orientation:vertical); float: none; }
  148. }
  149. &.stack-for-small {
  150. > li {
  151. @include button-group-style($orientation:horizontal);
  152. @media #{$small-only} {
  153. @include button-group-style($orientation:vertical);
  154. width: 100%;
  155. }
  156. }
  157. }
  158. &.radius > * { @include button-group-style($radius:$button-radius, $float:null); }
  159. &.radius.stack > * { @include button-group-style($radius:$button-radius, $float:null, $orientation:vertical); }
  160. &.radius.stack-for-small > * {
  161. @media #{$medium-up} {
  162. @include button-group-style($radius:$button-radius, $orientation:horizontal);
  163. }
  164. @media #{$small-only} {
  165. @include button-group-style($radius:$button-radius, $orientation:vertical);
  166. }
  167. }
  168. &.round > * { @include button-group-style($radius:$button-round, $float:null); }
  169. &.round.stack > * { @include button-group-style($radius:$button-med, $float:null, $orientation:vertical); }
  170. &.round.stack-for-small > * {
  171. @media #{$medium-up} {
  172. @include button-group-style($radius:$button-round, $orientation:horizontal);
  173. }
  174. @media #{$small-only} {
  175. @include button-group-style($radius:$button-med, $orientation:vertical);
  176. }
  177. }
  178. }
  179. .button-bar {
  180. @include clearfix;
  181. .button-group { @include button-group-container($styles:false, $float:true); }
  182. }
  183. }
  184. }