-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
split-buttons.html.erb
220 lines (172 loc) · 10.6 KB
/
split-buttons.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<% @side_nav = "buttons" %>
<div class="row">
<div class="large-9 push-3 columns">
<% @page_title = "Split Buttons" %>
<div class="row">
<div class="large-12 columns">
<h2><%= @page_title %></h2>
<h4 class="subheader">We've simplified our split buttons by getting rid of the dedicated dropdown associated with them. Instead, you'll use our <a href="#">new dropdown plugin</a> to attach a dropdown to the button style of your choice.</h4>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<a href="#" class="tiny button split">Split Button <span data-dropdown="drop"></span></a><br>
<a href="#" class="small secondary radius button split">Split Button <span data-dropdown="drop2"></span></a><br>
<a href="#" class="button alert round split">Split Button <span data-dropdown="drop3"></span></a><br>
<a href="#" class="large success button split">Split Button <span data-dropdown="drop4"></span></a><br>
<hr>
<h3>Build With Predefined HTML Classes</h3>
<p>There are two ways to build buttons in Foundation 4: with our predefined HTML classes or our structure and mixins. Building buttons using our predefined classes is simple, you'll need an <code><a></code>, <code><button></code> or <code><input></code> with a class of <code>.button.split</code>. This will create a default medium button. You can also use size, color and radius classes to control more of the style.</p>
<p>The classes options:</p>
<ul class="disc">
<li>The size classes include: <code>.tiny, .small, .medium</code> or <code>.large</code></li>
<li>The color classes include: <code>.secondary, .alert</code> or <code>.success</code></li>
<li>The radius classes include: <code>.radius</code> or <code>.round</code>.</li>
</ul>
<%= code_example '
<!-- Size Classes -->
<a href="#" class="button split">Default Button <span></span></a>
<a href="#" class="tiny button split">Tiny Button <span></span></a>
<a href="#" class="small button split">Small Button <span></span></a>
<a href="#" class="large button split">Large Button <span></span></a>
<!-- Color Classes -->
<a href="#" class="button split secondary">Secondary Button <span></span></a>
<a href="#" class="button split success">Success Button <span></span></a>
<a href="#" class="button split alert">Alert Button <span></span></a>
<!-- Radius Classes -->
<a href="#" class="button split radius">Radius Button <span></span></a>
<a href="#" class="button split round">Round Button <span></span></a>
', :html %>
<p>You may chain one class from each group to build up desired default styles. For these styles to take effect, make sure you have the <strong>default Foundation CSS package</strong> or that you've selected <strong>split buttons from a custom package</strong>. These should be linked up following our default <a href="#getting-started">HTML page structure</a>.</p>
<hr>
<h3>Build with Mixins</h3>
<p>We've included SCSS mixins used to style buttons. To use these mixins, you'll need to have the <a href="#extention-install">extension installed</a> or grab <a href="https://github.com/zurb/foundation/blob/master/scss/foundation/_foundation-global.scss">_foundation-global.scss</a>, <a href="#https://github.com/zurb/foundation/blob/master/scss/foundation/components/_buttons.scss">_buttons.scss</a>, <a href="https://github.com/zurb/foundation/blob/master/scss/foundation/components/_global.scss">_global.scss</a> and <a href="https://github.com/zurb/foundation/blob/master/scss/foundation/components/_split-buttons.scss">_split-buttons.scss</a> from Github and throw them into a Foundation folder in your project directory. From there, you can import the files at the top of your own SCSS stylesheet, like so:</p>
<%= code_example '
@import "foundation/foundation-global", "foundation/buttons", "foundation/split-buttons";
', :css %>
<p>If you are using the mixins, you may include the styles on whatever class or ID you'd like, just make sure you follow our markup structure:</p>
<%= code_example '
<a href="#" class="your-class-name">Split Button Text <span></span></a>
', :html %>
<h5>Quick Mixin</h5>
<p>You can quickly build an entire split buttons using our global mixin by including it on your custom class or ID in your stylesheet. The global mixin will create the necessary style for the button. The global mixin looks like this:</p>
<%= code_example '
/* Using the default styles */
.your-class-name {
@include button;
@include split-button;
}
', :css %>
<a href="" class="split button">Default Split Button<span data-dropdown="drop5"></span></a>
<p>There are also <strong>four options</strong> you can customize on the fly when writing this mixin. These control things like: padding size, pip color, border color and base styles. Setting any of these options to <strong>false</strong> will not include the styles.</p>
<%= code_example '
/* Using the available options */
.your-class-name {
@include button;
@include split-button($padding, $pip-color, $span-border, $base-style);
}
/* This controls padding around the dropdown buttons. Use tiny, small, medium, or large */
$padding: $button-med
/* This controls the dropdown pip color. Set to one of our variables or a custom hex value */
$pip-color: $split-button-pip-color
/* This controls the border color of the triangle span area. This can be a variable or color value. */
$span-border: $primary-color
/* This controls whether or not base styles come through. Set to false to negate */
/* Handy when you want to have many different styles */
$base-style: true
', :css %>
<h5>Default SCSS Variables</h5>
<%= code_example '
/* We use these to control different shared styles for Split Buttons */
$split-button-function-factor: 15%;
$split-button-pip-color: #fff;
$split-button-pip-color-alt: #333;
$split-button-active-bg-tint: rgba(0,0,0,0.1);
/* We use these to control tiny split buttons */
$split-button-padding-tny: $button-tny * 9;
$split-button-span-width-tny: $button-tny * 6.5;
$split-button-pip-size-tny: $button-tny;
$split-button-pip-top-tny: $button-tny * 2;
$split-button-pip-left-tny: emCalc(-5px);
/* We use these to control small split buttons */
$split-button-padding-sml: $button-sml * 7;
$split-button-span-width-sml: $button-sml * 5;
$split-button-pip-size-sml: $button-sml;
$split-button-pip-top-sml: $button-sml * 1.5;
$split-button-pip-left-sml: emCalc(-9px);
/* We use these to control medium split buttons */
$split-button-padding-med: $button-med * 6.4;
$split-button-span-width-med: $button-med * 4;
$split-button-pip-size-med: $button-med - emCalc(3px);
$split-button-pip-top-med: $button-med * 1.5;
$split-button-pip-left-med: emCalc(-9px);
/* We use these to control large split buttons */
$split-button-padding-lrg: $button-lrg * 6;
$split-button-span-width-lrg: $button-lrg * 3.75;
$split-button-pip-size-lrg: $button-lrg - emCalc(6px);
$split-button-pip-top-lrg: $button-lrg + emCalc(5px);
$split-button-pip-left-lrg: emCalc(-9px);
', :css %>
<p><strong>Note:</strong> <code>emCalc();</code> is a function we wrote to convert <code>px</code> to <code>em</code>. It is included in <strong>_foundation-global.scss</strong>.</p>
<hr>
<h3>Using the JavaScript</h3>
<p>You don't need ths JS to create dropdown button styles with Foundation. The only reason you'll need to include <code>foundation.dropdown.js</code> is if you want to add one of our dropdowns to the button. You'll also need to make sure to include <code>zepto.js</code> and <code>foundation.js</code> above the dropdown plugin.</p>
<p>Above your closing <code></body></code> tag include the following line of code and make sure you have the JS file in your directory:</p>
<p><a href="../javascript.html" title="How to install Foundation JavaScript">Read how to install Foundation JavaScript</a></p>
<p>Required Foundation Library: <code>foundation.dropdown.js</code></p>
<h5>Creating the Dropdown</h5>
<p>To create a dropdown, you'll need to attach a data-attribute to whatever element you want the dropdown attached to (in this case a button). From there, you'll create a list that holds the links or content and add another data-attribute that associates with the element it belongs to. Here's an example of that markup:</p>
<%= code_example '
<a href="#" data-dropdown="drop1" class="button dropdown">Dropdown Button <span data-dropdown="drop1"></span></a><br>
<ul id="drop1" class="f-dropdown">
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
', :html %>
<a href="#" class="button split">Dropdown Button <span data-dropdown="drop1"></span></a><br>
<p>You'll notice that <code>data-dropdown="drop1"</code> and <code>id="drop1"</code> have similar values. This is what tells the dropdown plugin where to look to find the position to attach the dropdown element to.</p>
<h5>Optional JavaScript Configuration</h5>
<p>Dropdwon button options can only be passed in during initialization at this time.</p>
<%= code_example "
{
// specify the class used for active sections
activeClass: 'open'
}", :json %>
</div>
</div>
</div>
<div class="large-3 pull-9 columns">
<%= render "_sidebar-components.html.erb" %>
</div>
</div>
<ul id="drop" class="f-dropdown" data-dropdown-content>
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
<ul id="drop1" class="f-dropdown" data-dropdown-content>
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
<ul id="drop2" class="f-dropdown" data-dropdown-content>
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
<ul id="drop3" class="f-dropdown" data-dropdown-content>
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
<ul id="drop4" class="f-dropdown" data-dropdown-content>
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
<ul id="drop5" class="f-dropdown" data-dropdown-content>
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>