Merge "Document type for class properties in ResourceLoaderImageModule"
[lhc/web/wiklou.git] / resources / src / mediawiki.ui / components / icons.less
1 @import 'mediawiki.mixins';
2 @import 'mediawiki.ui/variables';
3
4 // Mixins
5 .mixin-mw-ui-icon-bgimage( @iconSvg, @iconPng ) {
6 &.mw-ui-icon {
7 &:before {
8 .background-image-svg( @iconSvg, @iconPng );
9 }
10 }
11 }
12
13 // Icons
14 //
15 // To use icons you must be using a browser that supports pseudo elements.
16 // This includes support for IE 8.
17 // https://caniuse.com/#feat=css-gencontent
18 //
19 // For elements that are intended to have both an icon and text, browsers that
20 // do not support pseudo-selectors will degrade to text-only.
21 //
22 // However, icon-only elements do not yet degrade to text-only elements in these
23 // browsers.
24 //
25 // Styleguide 6.
26
27 .mw-ui-icon {
28 position: relative;
29 line-height: @iconSize;
30 min-height: @iconSize;
31 min-width: @iconSize;
32
33 // If an inline element has been marked as a mw-ui-icon element it must be inline-block
34 span& {
35 display: inline-block;
36 }
37
38 // Standalone icons
39 //
40 // Markup:
41 // <div class="mw-ui-icon mw-ui-icon-element mw-ui-icon-ok">OK</div><br>
42 // <div class="mw-ui-icon mw-ui-icon-element mw-ui-icon-ok mw-ui-button mw-ui-progressive">OK</div><br>
43 // <button class="mw-ui-icon mw-ui-icon-ok mw-ui-icon-element mw-ui-button mw-ui-quiet" title="">Close</button>
44 //
45 // Styleguide 6.1.1.
46 &.mw-ui-icon-element {
47 @marginIcon: 2 * @iconGutterWidth;
48 @width: @iconSize + @marginIcon;
49 @sizeIconLarge: ( @iconSize * 1.75) + @marginIcon;
50 text-indent: -999px;
51 overflow: hidden;
52 width: @width;
53 min-width: @width;
54 max-width: @width;
55
56 &:before {
57 left: 0;
58 right: 0;
59 position: absolute;
60 margin: 0 @iconGutterWidth;
61 }
62
63 &.mw-ui-icon-large {
64 width: @sizeIconLarge;
65 min-width: @sizeIconLarge;
66 max-width: @sizeIconLarge;
67 line-height: @sizeIconLarge;
68 min-height: @sizeIconLarge;
69
70 &:before {
71 min-height: @sizeIconLarge;
72 }
73 }
74 }
75
76 &.mw-ui-icon-before:before,
77 &.mw-ui-icon-element:before {
78 background-position: 50% 50%;
79 background-repeat: no-repeat;
80 background-size: 100% auto;
81 float: left;
82 display: block;
83 min-height: @iconSize;
84 content: '';
85 }
86
87 // Icons with text
88 //
89 // Markup:
90 // <div class="mw-ui-icon mw-ui-icon-before mw-ui-icon-ok">OK</div>
91 // <div class="mw-ui-icon mw-ui-icon-before mw-ui-icon-ok mw-ui-progressive mw-ui-button">OK</div>
92 //
93 // Styleguide 6.1.2
94 &.mw-ui-icon-before {
95 &:before {
96 position: relative;
97 width: @iconSize;
98 margin-right: @iconGutterWidth;
99 }
100 }
101
102 // Icons small for elements like indicators
103 //
104 // Markup:
105 // <div class="mw-ui-icon mw-ui-icon-small mw-ui-icon-help"></div>
106 //
107 // Styleguide 6.1.3
108 &.mw-ui-icon-small:before {
109 background-size: 66.67% auto; // 66.67% of 24px equals 16px
110 }
111 }