1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | $buttongroup-margin: 1rem !default;
|
12 |
|
13 |
|
14 |
|
15 | $buttongroup-spacing: 1px !default;
|
16 |
|
17 |
|
18 |
|
19 | $buttongroup-child-selector: '.button' !default;
|
20 |
|
21 |
|
22 |
|
23 | $buttongroup-expand-max: 6 !default;
|
24 |
|
25 |
|
26 |
|
27 | $buttongroup-radius-on-each: true !default;
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | @mixin button-group(
|
33 | $child-selector: $buttongroup-child-selector,
|
34 | $spacing: $buttongroup-spacing
|
35 | ) {
|
36 | @include clearfix;
|
37 | margin-bottom: $buttongroup-margin;
|
38 |
|
39 | @if $global-flexbox {
|
40 | display: flex;
|
41 | flex-wrap: nowrap;
|
42 | align-items: stretch;
|
43 | }
|
44 | @else {
|
45 | font-size: 0;
|
46 | }
|
47 |
|
48 | #{$child-selector} {
|
49 | margin: 0;
|
50 | margin-#{$global-right}: $spacing;
|
51 | margin-bottom: $spacing;
|
52 | font-size: map-get($button-sizes, default);
|
53 |
|
54 | @if $global-flexbox {
|
55 | flex: 0 0 auto;
|
56 | }
|
57 |
|
58 | &:last-child {
|
59 | margin-#{$global-right}: 0;
|
60 | }
|
61 |
|
62 | @if not $buttongroup-radius-on-each {
|
63 | border-radius: 0;
|
64 |
|
65 | &:first-child {
|
66 | border-top-#{$global-left}-radius: $button-radius;
|
67 | border-bottom-#{$global-left}-radius: $button-radius;
|
68 | }
|
69 |
|
70 | &:last-child {
|
71 | border-top-#{$global-right}-radius: $button-radius;
|
72 | border-bottom-#{$global-right}-radius: $button-radius;
|
73 | }
|
74 | }
|
75 |
|
76 | }
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | @mixin button-group-expand(
|
83 | $selector: $buttongroup-child-selector,
|
84 | $spacing: $buttongroup-spacing,
|
85 | $count: null
|
86 | ) {
|
87 | @if not $global-flexbox {
|
88 | margin-#{$global-right}: -$spacing;
|
89 |
|
90 | &::before,
|
91 | &::after {
|
92 | display: none;
|
93 | }
|
94 | }
|
95 |
|
96 | #{$selector} {
|
97 | @if $global-flexbox {
|
98 | flex: 1 1 0px;
|
99 | }
|
100 | @else {
|
101 |
|
102 | &:first-child:last-child {
|
103 | width: 100%
|
104 | }
|
105 |
|
106 | // Two or more childreen
|
107 | @for $i from 2 through $buttongroup-expand-max {
|
108 | &:first-child:nth-last-child(#{$i}) {
|
109 | &, &:first-child:nth-last-child(#{$i}) ~ #{$selector} {
|
110 | display: inline-block;
|
111 | width: calc(#{percentage(1 / $i)} - #{$spacing});
|
112 | margin-#{$global-right}: $spacing;
|
113 |
|
114 | &:last-child {
|
115 | margin-#{$global-right}: $spacing * -$buttongroup-expand-max;
|
116 | }
|
117 | }
|
118 | }
|
119 | }
|
120 | }
|
121 | }
|
122 | }
|
123 |
|
124 |
|
125 |
|
126 | @mixin button-group-stack(
|
127 | $selector: $buttongroup-child-selector
|
128 | ) {
|
129 | @if $global-flexbox {
|
130 | flex-wrap: wrap;
|
131 | }
|
132 |
|
133 | #{$selector} {
|
134 | @if $global-flexbox {
|
135 | flex: 0 0 100%;
|
136 | }
|
137 | @else {
|
138 | width: 100%;
|
139 | }
|
140 |
|
141 | &:last-child {
|
142 | margin-bottom: 0;
|
143 | }
|
144 |
|
145 |
|
146 | @if not $buttongroup-radius-on-each {
|
147 | border-radius: 0;
|
148 |
|
149 | &:first-child{
|
150 | border-top-#{$global-left}-radius: $global-radius;
|
151 | border-top-#{$global-right}-radius: $global-radius;
|
152 | }
|
153 |
|
154 | &:last-child {
|
155 | margin-bottom: 0;
|
156 | border-bottom-#{$global-left}-radius: $global-radius;
|
157 | border-bottom-#{$global-right}-radius: $global-radius;
|
158 | }
|
159 | }
|
160 |
|
161 | }
|
162 | }
|
163 |
|
164 |
|
165 |
|
166 | @mixin button-group-unstack(
|
167 | $selector: $buttongroup-child-selector
|
168 | ) {
|
169 | #{$selector} {
|
170 | @if $global-flexbox {
|
171 | flex: 1 1 0px;
|
172 | }
|
173 | @else {
|
174 | width: auto;
|
175 | }
|
176 | margin-bottom: 0;
|
177 |
|
178 | @if not $buttongroup-radius-on-each {
|
179 | &:first-child {
|
180 | border-top-#{$global-left}-radius: $global-radius;
|
181 | border-top-#{$global-right}-radius: 0;
|
182 | border-bottom-#{$global-left}-radius: $global-radius;
|
183 | }
|
184 |
|
185 | &:last-child {
|
186 | border-top-#{$global-right}-radius: $global-radius;
|
187 | border-bottom-#{$global-right}-radius: $global-radius;
|
188 | border-bottom-#{$global-left}-radius: 0;
|
189 | }
|
190 | }
|
191 |
|
192 | }
|
193 | }
|
194 |
|
195 | @mixin foundation-button-group {
|
196 | .button-group {
|
197 | @include button-group;
|
198 |
|
199 |
|
200 | @each $size, $value in map-remove($button-sizes, default) {
|
201 | &.#{$size} #{$buttongroup-child-selector} {
|
202 | font-size: $value;
|
203 | }
|
204 | }
|
205 |
|
206 |
|
207 | &.expanded { @include button-group-expand; }
|
208 |
|
209 |
|
210 | @each $name, $color in $foundation-palette {
|
211 | @if $button-fill != hollow {
|
212 | &.#{$name} #{$buttongroup-child-selector} {
|
213 | @include button-style($color, auto, auto);
|
214 | }
|
215 | }
|
216 | @else {
|
217 | &.#{$name} #{$buttongroup-child-selector} {
|
218 | @include button-hollow;
|
219 | @include button-hollow-style($color);
|
220 | }
|
221 | }
|
222 | }
|
223 |
|
224 | &.stacked,
|
225 | &.stacked-for-small,
|
226 | &.stacked-for-medium {
|
227 | @include button-group-stack;
|
228 | }
|
229 |
|
230 | &.stacked-for-small {
|
231 | @include breakpoint(medium) {
|
232 | @include button-group-unstack;
|
233 | }
|
234 | }
|
235 |
|
236 | &.stacked-for-medium {
|
237 | @include breakpoint(large) {
|
238 | @include button-group-unstack;
|
239 | }
|
240 | }
|
241 |
|
242 | &.stacked-for-small.expanded {
|
243 | @include breakpoint(small only) {
|
244 | display: block;
|
245 |
|
246 | #{$buttongroup-child-selector} {
|
247 | display: block;
|
248 | margin-#{$global-right}: 0;
|
249 | }
|
250 | }
|
251 | }
|
252 | }
|
253 | }
|