Skip to content

Commit 149d510

Browse files
authored
Merge pull request #125 from Wikia/XW-3085
XW-3085 | buttons with icons
2 parents 0de0e7d + fb01d0b commit 149d510

File tree

16 files changed

+148
-47
lines changed

16 files changed

+148
-47
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.fixed-width-140px {
22
width: 140px;
33
}
4+
5+
.fixed-width-180px {
6+
width: 180px;
7+
}

app/templates/route-components/buttons.hbs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@
1818
Other <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Attributes">
1919
valid HTML attributes</a> may be passed as well.
2020
</p>
21+
<p>
22+
Buttons can contain icons with text. Add <code class="format-code">.wds-has-icon</code> class to apply proper styles
23+
for using <code class="format-code">.wds-icon</code> inside the button. We assume that standard and stretched
24+
buttons contain small icons (18x18) and squished buttons contain tiny icons (12x12).
25+
</p>
2126

2227
<section>
2328
<h2 id="primary">Primary buttons</h2>
2429
<p>Default version for general use.</p>
2530
{{#component-demo}}
2631
{{#wds-button}}Primary button{{/wds-button}}
32+
{{#wds-button class='wds-has-icon'}}
33+
{{wds-icon name='fandom-heart' size='small'}}
34+
Primary button
35+
{{/wds-button}}
2736
{{#wds-button disabled=true}}Primary disabled{{/wds-button}}
2837
{{/component-demo}}
2938
</section>
@@ -33,6 +42,10 @@
3342
<p>Adding class <code class="format-code">.wds-is-secondary</code> changes the button's looks. It is used to create a button that draws less user's attention.</p>
3443
{{#component-demo}}
3544
{{#wds-button class='wds-is-secondary'}}Secondary button{{/wds-button}}
45+
{{#wds-button class='wds-is-secondary wds-has-icon'}}
46+
{{wds-icon name='fandom-heart' size='small'}}
47+
Secondary button
48+
{{/wds-button}}
3649
{{#wds-button class='wds-is-secondary' disabled=true}}Secondary disabled{{/wds-button}}
3750
{{/component-demo}}
3851
</section>
@@ -42,6 +55,10 @@
4255
<p>These buttons are denoted with <code class="format-code">.wds-is-text</code> class. They are the least obtrusive. Nevertheless, their paddings remain untouched, which provides the same clickable area.</p>
4356
{{#component-demo}}
4457
{{#wds-button class='wds-is-text'}}Text button{{/wds-button}}
58+
{{#wds-button class='wds-is-text wds-has-icon'}}
59+
{{wds-icon name='fandom-heart' size='small'}}
60+
Text button
61+
{{/wds-button}}
4562
{{#wds-button class='wds-is-text' disabled=true}}Text disabled{{/wds-button}}
4663
{{/component-demo}}
4764
</section>
@@ -51,6 +68,10 @@
5168
<p>Size of the button of any aforementioned variant can be adjusted. These are the default sizes of the buttons — for comparison.</p>
5269
{{#component-demo}}
5370
{{#wds-button}}Primary{{/wds-button}}
71+
{{#wds-button class='wds-has-icon'}}
72+
{{wds-icon name='fandom-heart' size='small'}}
73+
Primary button
74+
{{/wds-button}}
5475
{{#wds-button class='wds-is-secondary'}}Secondary{{/wds-button}}
5576
{{#wds-button class='wds-is-text'}}Text{{/wds-button}}
5677
{{/component-demo}}
@@ -61,6 +82,10 @@
6182
<p>To make the button smaller use <code class="format-code">.wds-is-squished</code> class. This can help with fitting a button in tighter layouts.</p>
6283
{{#component-demo}}
6384
{{#wds-button class='wds-is-squished'}}Primary{{/wds-button}}
85+
{{#wds-button class='wds-is-squished wds-has-icon'}}
86+
{{wds-icon name='fandom-heart-small' class='wds-icon-tiny'}}
87+
Primary
88+
{{/wds-button}}
6489
{{#wds-button class='wds-is-secondary wds-is-squished'}}Secondary{{/wds-button}}
6590
{{#wds-button class='wds-is-text wds-is-squished'}}Text{{/wds-button}}
6691
{{/component-demo}}
@@ -85,6 +110,10 @@ html[lang^='zh'] &__start-a-wiki-button {
85110
<p>For a button greater in size use <code class="format-code">.wds-is-stretched</code> class. This may come in handy to draw more user's attention to the button and increase the clickable area around the label.</p>
86111
{{#component-demo}}
87112
{{#wds-button class='wds-is-stretched'}}Primary{{/wds-button}}
113+
{{#wds-button class='wds-is-stretched wds-has-icon'}}
114+
{{wds-icon name='fandom-heart' size='small'}}
115+
Primary button
116+
{{/wds-button}}
88117
{{#wds-button class='wds-is-secondary wds-is-stretched'}}Secondary{{/wds-button}}
89118
{{#wds-button class='wds-is-text wds-is-stretched'}}Text{{/wds-button}}
90119
{{/component-demo}}
@@ -104,6 +133,10 @@ html[lang^='zh'] &__start-a-wiki-button {
104133
<p>Button labels can wrap to multiple lines.</p>
105134
{{#component-demo}}
106135
{{#wds-button class='fixed-width-140px'}}Multiline button label with 3rd line{{/wds-button}}
136+
{{#wds-button class='fixed-width-180px wds-has-icon'}}
137+
{{wds-icon name='fandom-heart' size='small'}}
138+
Multiline button label
139+
{{/wds-button}}
107140
{{/component-demo}}
108141
</section>
109142

@@ -112,6 +145,10 @@ html[lang^='zh'] &__start-a-wiki-button {
112145
<p>When no special handlers of the click event are needed — just navigation to a certain URL, consider using an anchor tag <code>&lt;a&gt;</code> styled as a button. It is achieved by adding a <code class="format-code">.wds-button</code> class just like for the <code>&lt;button&gt;</code> element. Optionally add any other desired button classes.</p>
113146
{{#component-demo}}
114147
{{#wds-button tagName='a' href='#'}}Link button{{/wds-button}}
148+
{{#wds-button tagName='a' href='#' class='wds-has-icon'}}
149+
{{wds-icon name='fandom-heart' size='small'}}
150+
Link button
151+
{{/wds-button}}
115152
{{#wds-button tagName='a' href='#' class='wds-is-secondary'}}Secondary link button{{/wds-button}}
116153
{{/component-demo}}
117154
</section>

dist/css/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/scss/wds-components/_buttons.scss

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
}
1919

2020
$active-color: darken($wds-color-link, 20%);
21+
$button-padding-horizontal: 18px;
22+
$button-squished-padding-horizontal: 12px;
2123
$line-height: 1.3em;
2224

2325
@include button-background-color($wds-color-link);
@@ -32,7 +34,7 @@
3234
letter-spacing: .15px;
3335
line-height: $line-height;
3436
outline: none;
35-
padding: 16px 18px 15px;
37+
padding: 16px $button-padding-horizontal 15px;
3638
text-align: center;
3739
text-decoration: none;
3840
text-transform: uppercase;
@@ -63,7 +65,7 @@
6365

6466
&.wds-is-squished {
6567
font-size: $wds-typescale-size-minus-3;
66-
padding: 10px 12px 9px;
68+
padding: 10px $button-squished-padding-horizontal 9px;
6769
}
6870

6971
&.wds-is-stretched {
@@ -98,6 +100,28 @@
98100
}
99101
}
100102

103+
&.wds-has-icon {
104+
padding-left: $button-padding-horizontal + $wds-icon-small-size + 6px;
105+
position: relative;
106+
107+
&.wds-is-squished {
108+
padding-left: $button-squished-padding-horizontal + $wds-icon-tiny-size + 6px;
109+
110+
.wds-icon {
111+
left: $button-squished-padding-horizontal;
112+
margin-top: -$wds-icon-tiny-size / 2;
113+
}
114+
}
115+
116+
.wds-icon {
117+
left: $button-padding-horizontal;
118+
margin-top: -$wds-icon-small-size / 2;
119+
pointer-events: none;
120+
position: absolute;
121+
top: 50%;
122+
}
123+
}
124+
101125
$social-colors: (
102126
facebook: $wds-color-social-facebook,
103127
googleplus: $wds-color-social-googleplus,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
.wds-icon {
22
fill: currentColor;
3-
@include square(24px);
3+
@include square($wds-icon-size);
44

55
&-small {
6-
@include square(18px);
6+
@include square($wds-icon-small-size);
77
}
88

99
&-tiny {
10-
@include square(12px);
10+
@include square($wds-icon-tiny-size);
1111
}
1212
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$wds-icon-size: 24px;
2+
$wds-icon-small-size: 18px;
3+
$wds-icon-tiny-size: 12px;

dist/scss/wds-variables/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Base variables
22
@import 'breakpoints';
33
@import 'colors';
4+
@import 'icons';
45
@import 'typography';
56
@import 'z-index-scale';
67

docs/assets/design-system.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/design-system.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/vendor.js

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)