1+ //
2+ // Buttons
3+ // --------------------------------------------------
4+
5+
6+ // Base styles
7+ // --------------------------------------------------
8+
9+ // Core
10+
11+ /*
12+ @styleguide Buttons
13+
14+ ### Button Styles
15+
16+ ```html
17+ <p>
18+ <button class="Button" type="button">.Button</button>
19+
20+ <button class="Button" type="button" disabled>&[disabled]</button>
21+
22+ <button class="Button Button--active" type="button" style="pointer-events: none">&.Button--active</button>
23+ </p>
24+ <p>
25+ <button class="Button Button--primary" type="button">.Button.Button--primary</button>
26+
27+ <button class="Button Button--primary" type="button" disabled>&[disabled]</button>
28+
29+ <button class="Button Button--primary Button--active" type="button" style="pointer-events: none">&.Button--active</button>
30+ </p>
31+ <p>
32+ <button class="Button Button--secondary" type="button">.Button.Button--secondary</button>
33+
34+ <button class="Button Button--secondary" type="button" disabled>&[disabled]</button>
35+
36+ <button class="Button Button--secondary Button--active" type="button" style="pointer-events: none">&.Button--active</button>
37+ </p>
38+ <p>
39+ <button class="Button Button--success" type="button">.Button.Button--success</button>
40+
41+ <button class="Button Button--success" type="button" disabled>&[disabled]</button>
42+
43+ <button class="Button Button--success Button--active" type="button" style="pointer-events: none">&.Button--active</button>
44+ </p>
45+ <p>
46+ <button class="Button Button--warning" type="button">.Button.Button--danger</button>
47+
48+ <button class="Button Button--warning" type="button" disabled>&[disabled]</button>
49+
50+ <button class="Button Button--warning Button--active" type="button" style="pointer-events: none">&.Button--active</button>
51+ </p>
52+ <p>
53+ <button class="Button Button--danger" type="button">.Button.Button--danger</button>
54+
55+ <button class="Button Button--danger" type="button" disabled>&[disabled]</button>
56+
57+ <button class="Button Button--danger Button--active" type="button" style="pointer-events: none">&.Button--active</button>
58+ </p>
59+ <p>
60+ <button class="Button Button--link" type="button">.Button.Button--link</button>
61+
62+ <button class="Button Button--link" type="button" disabled>&[disabled]</button>
63+
64+ <button class="Button Button--link Button--active" type="button" style="pointer-events: none">&.Button--active</button>
65+ </p>
66+ ```
67+
68+ ### Button Sizes
69+
70+ Add an additional class `.btn-large`, `.btn-small`, `.btn-mini` to change button sizes
71+
72+ ```html
73+ <p>
74+ <button class="btn btn-large" type="button">Large button</button>
75+ </p>
76+ <p>
77+ <button class="btn" type="button">Default button</button>
78+ </p>
79+ <p>
80+ <button class="btn btn-small" type="button">Small button</button>
81+ </p>
82+ <p>
83+ <button class="btn btn-mini" type="button">Mini button</button>
84+ </p>
85+ ```
86+
87+ ### Artificial buttons
88+
89+ To create something that acts like a button when you can't use a button element,
90+ listen to the "click" and "keyclick" events and add tabindex="0" and role="button".
91+
92+ ```html
93+ <div class="btn" tabindex="0" role="button">Activate me</div>
94+ ```
95+ */
96+
97+ .btn , // <-- deprecated- do not use
98+ .Button {
99+ @if $use_new_styles { @include canvas-button (darken ($canvas-neutral , 1% ), $textColor , true); }
100+ @else { @include canvas-button (darken ($canvas-light , 3% ), $textColor , true); }
101+ border-radius : $baseBorderRadius ;
102+ transition : background-color 0.2s ease-in-out ;
103+ display : inline-block ;
104+ position : relative ;
105+ padding : 8px 14px ;
106+ margin-bottom : 0 ; // For input.btn
107+ font-size : $baseFontSize ;
108+ line-height : $baseLineHeight ;
109+ text-align : center ;
110+ vertical-align : middle ;
111+ cursor : pointer ;
112+ text-decoration : none ;
113+ overflow : hidden ;
114+ text-shadow : none ;
115+
116+ // Hover state
117+ & :hover { text-decoration : none ; }
118+
119+ // Focus state for keyboard and accessibility ONLY IN HIGH CONTRAST MODE
120+ @if $use_high_contrast {
121+ & :focus { @include button-focus ; }
122+ }
123+ // If not high-contrast, the "canvas-button" mixin has the :focus state share the same styles as :hover
124+ @else { & :focus { outline : none ; } }
125+
126+ }
127+
128+
129+ // Button Sizes
130+ // --------------------------------------------------
131+
132+ // Large
133+ .btn-large , // <-- deprecated- do not use
134+ .Button--large {
135+ padding : $paddingLarge ;
136+ font-size : $fontSizeLarge ;
137+ border-radius : $borderRadiusLarge ;
138+
139+ [class ^= " icon-" ], [class *= " icon-" ] { margin-top : 2px ; }
140+
141+ }
142+
143+
144+ // Small
145+ .btn-small , // <-- deprecated- do not use
146+ .Button--small {
147+ padding : $paddingSmall ;
148+ font-size : $fontSizeSmall ;
149+
150+ [class ^= " icon-" ], [class *= " icon-" ] { margin-top : 0 ; }
151+
152+ }
153+
154+
155+ // Mini
156+ .btn-mini , // <-- deprecated- do not use
157+ .Button--mini {
158+ padding : $paddingMini ;
159+ font-size : $fontSizeMini ;
160+ border-radius : $borderRadiusSmall ;
161+ }
162+
163+
164+ // Block button
165+ // -------------------------
166+
167+ .btn-block , // <-- deprecated- do not use
168+ .Button--block {
169+ display : block ;
170+ width : 100% ;
171+ padding-left : 0 ;
172+ padding-right : 0 ;
173+ @include box-sizing (border-box );
174+ }
175+
176+ // Vertically space out stacked block buttons
177+ .btn-block + .btn-block , .Button--block + .Button--block { margin-top : 6px ; }
178+
179+ // Specificity overrides
180+ input [type = " submit" ],
181+ input [type = " reset" ],
182+ input [type = " button" ] {
183+ & .btn-block {
184+ width : 100% ;
185+ }
186+ }
187+
188+ // Set the backgrounds
189+ // -------------------------
190+
191+ .btn-primary , // <-- deprecated- do not use
192+ .Button--primary {
193+ @include canvas-button ($canvas-primary , $canvas-light , false);
194+ @if $use_high_contrast {
195+ & :focus { @include button-focus ($canvas-action ); }
196+ }
197+ }
198+ // Warning appears are orange
199+ .btn-warning , // <-- deprecated- do not use
200+ .Button--warning {
201+ @include canvas-button ($canvas-alert , $canvas-light , false);
202+ }
203+ // Danger and error appear as red
204+ .btn-danger , // <-- deprecated- do not use
205+ .Button--danger {
206+ @if $use_high_contrast { @include canvas-button ($canvas-danger , $canvas-light , false); }
207+ @else { @include canvas-button (lighten ($canvas-danger , 4% ), $canvas-light , false); }
208+ }
209+ // Success appears as green
210+ .btn-success , // <-- deprecated- do not use
211+ .Button--success {
212+ @if $use_high_contrast { @include canvas-button ($canvas-success , $canvas-light , false); }
213+ @else { @include canvas-button (lighten ($canvas-success , 5% ), $canvas-light , false); }
214+ }
215+ // Info appears as a neutral blue
216+ .btn-info , // <-- deprecated- do not use
217+ .Button--secondary {
218+ @include canvas-button ($canvas-secondary , $canvas-light , false);
219+ }
220+
221+ // Inverse appears as dark gray <-- deprecated- do not use
222+ .btn-inverse {
223+ @include buttonBackground ($btnInverseBackground , $btnInverseBackgroundHighlight );
224+ }
225+
226+
227+ // Link buttons
228+ // --------------------------------------------------
229+
230+ // Make a button look and behave like a link
231+
232+ .btn-link , .btn-link :active , .btn-link [disabled ], // <-- deprecated - do not use
233+ .Button--link , .Button--link :active , .Button--link [disabled ] {
234+ background : transparent ;
235+ background-image : none ;
236+ box-shadow : none ;
237+ }
238+
239+ .btn-link , // <-- deprecated- do not use
240+ .Button--link {
241+ border-color : transparent ;
242+ cursor : pointer ;
243+ color : $linkColor ;
244+
245+ & :hover {
246+ color : $linkColorHover ;
247+ text-decoration : underline ;
248+ background : transparent ;
249+ }
250+
251+ & .active , & .Button--active , & :active {
252+ background : rgba ($canvas-dark , 0.05 );
253+ box-shadow : none ;
254+ border-color : transparent ;
255+ color : $linkColor ;
256+ }
257+
258+ & .disabled , & [disabled ] {
259+ color : $textColor ;
260+ background : transparent ;
261+ }
262+ }
0 commit comments