_button-groups.scss 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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, 0.5);
  35. }
  36. &:first-child {
  37. button, .button {
  38. border-#{$default-float}: 0;
  39. }
  40. }
  41. // We use this to control the flow, or remove those styles completely.
  42. @if $float {
  43. margin: 0;
  44. float: $float;
  45. display: list-item;
  46. // Make sure the first child doesn't get the negative margin.
  47. &:first-child { margin-#{$default-float}: 0; }
  48. }
  49. @else {
  50. margin: 0 -2px;
  51. display: inline-block;
  52. }
  53. @if $orientation == vertical {
  54. display:block;
  55. margin:0;
  56. > button, .button {
  57. border-top: $button-group-border-width solid;
  58. border-color: rgba(255, 255, 255, 0.5);
  59. border-left-width: 0;
  60. margin:0;
  61. display: block;
  62. }
  63. > button {
  64. width: 100%;
  65. }
  66. &:first-child {
  67. button, .button {
  68. border-top: 0;
  69. }
  70. }
  71. }
  72. // We use these to control left and right radius on first/last buttons in the group.
  73. @if $radius == true {
  74. &,
  75. & > a,
  76. & > button,
  77. & > .button { @include radius(0); }
  78. &:first-child,
  79. &:first-child > a,
  80. &:first-child > button,
  81. &:first-child > .button {
  82. @if $orientation == vertical {
  83. @include side-radius(top, $button-radius);
  84. }
  85. @else {
  86. @include side-radius($default-float, $button-radius);
  87. }
  88. }
  89. &:last-child,
  90. &:last-child > a,
  91. &:last-child > button,
  92. &:last-child > .button {
  93. @if $orientation == vertical {
  94. @include side-radius(bottom, $button-radius);
  95. }
  96. @else {
  97. @include side-radius($opposite-direction, $button-radius);
  98. }
  99. }
  100. }
  101. @else if $radius {
  102. &,
  103. & > a,
  104. & > button,
  105. & > .button { @include radius(0); }
  106. &:first-child,
  107. &:first-child > a,
  108. &:first-child > button,
  109. &:first-child > .button {
  110. @if $orientation == vertical {
  111. @include side-radius(top, $radius);
  112. }
  113. @else {
  114. @include side-radius($default-float, $radius);
  115. }
  116. }
  117. &:last-child,
  118. &:last-child > a,
  119. &:last-child > button,
  120. &:last-child > .button {
  121. @if $orientation == vertical {
  122. @include side-radius(bottom, $radius);
  123. }
  124. @else {
  125. @include side-radius($opposite-direction, $radius);
  126. }
  127. }
  128. }
  129. // We use this to make the buttons even width across their container
  130. @if $even {
  131. width: percentage((100/$even) / 100);
  132. button, .button { width: 100%; }
  133. }
  134. }
  135. @include exports("button-group") {
  136. @if $include-html-button-classes {
  137. .button-group { @include button-group-container;
  138. @for $i from 2 through 8 {
  139. &.even-#{$i} li { @include button-group-style($even:$i, $float:null); }
  140. }
  141. & > li { @include button-group-style(); }
  142. &.stack {
  143. & > li { @include button-group-style($orientation:vertical); float: none; }
  144. }
  145. &.stack-for-small {
  146. & > li {
  147. @include button-group-style($orientation:horizontal);
  148. @media #{$small-only} {
  149. @include button-group-style($orientation:vertical);
  150. }
  151. }
  152. }
  153. &.radius > * { @include button-group-style($radius:$button-radius, $float:null); }
  154. &.radius.stack > * { @include button-group-style($radius:$button-radius, $float:null, $orientation:vertical); }
  155. &.radius.stack-for-small > * {
  156. @media #{$medium-up} {
  157. @include button-group-style($radius:$button-radius, $orientation:horizontal);
  158. }
  159. @media #{$small-only} {
  160. @include button-group-style($radius:$button-radius, $orientation:vertical);
  161. }
  162. }
  163. &.round > * { @include button-group-style($radius:$button-round, $float:null); }
  164. &.round.stack > * { @include button-group-style($radius:$button-med, $float:null, $orientation:vertical); }
  165. &.round.stack-for-small > * {
  166. @media #{$medium-up} {
  167. @include button-group-style($radius:$button-round, $orientation:horizontal);
  168. }
  169. @media #{$small-only} {
  170. @include button-group-style($radius:$button-med, $orientation:vertical);
  171. }
  172. }
  173. }
  174. .button-bar {
  175. @include clearfix;
  176. .button-group { @include button-group-container($styles:false, $float:true); }
  177. }
  178. }
  179. }