| 1 |
/** |
| 2 |
* MediaWiki UI icons specification 2.0 |
| 3 |
* |
| 4 |
* Applies the MinervaNeue icon styles, adding more mobile-friendly |
| 5 |
* features like increased touch-area sizes and highlights. |
| 6 |
* |
| 7 |
* - mw-ui-icon = base class. 20px square with icon. |
| 8 |
* - mw-ui-icon + mw-ui-icon-element = icon with padding & pseudo-states. |
| 9 |
* - mw-ui-icon + mw-ui-icon-before = *deprecated*, icon with text. |
| 10 |
* Labels should be placed in a separate element beside the icon. |
| 11 |
* |
| 12 |
*/ |
| 13 |
|
| 14 |
@import 'mediawiki.skin.variables.less'; |
| 15 |
@import 'mediawiki.mixins.less'; |
| 16 |
|
| 17 |
// == Icons == |
| 18 |
@icon-touch-area-sm: 32; // This is also used for touch areas at DESKTOP resolutions. |
| 19 |
@icon-touch-area-md: 44; |
| 20 |
@font-size-browser: 16; // Assumed browser default of `16px`. |
| 21 |
// Medium icon |
| 22 |
@icon-glyph-size-md: 20; |
| 23 |
@icon-size-md: unit( @icon-glyph-size-md / @font-size-browser, em ); |
| 24 |
@icon-padding-md: unit( ( @icon-touch-area-md - @icon-glyph-size-md ) / 2 / @font-size-browser, em ); |
| 25 |
|
| 26 |
// Includes 2px mw-ui-button border |
| 27 |
@icon-padding-md-button: unit( ( @icon-touch-area-md - @icon-glyph-size-md - 2 ) / 2 / @font-size-browser, em ); |
| 28 |
// At desktop resolution the icon touch area will shrink from @icon-touch-area-md to @icon-touch-area-sm |
| 29 |
@icon-padding-md-button--desktop: unit( ( @icon-touch-area-sm - @icon-glyph-size-md - 2 ) / 2 / @font-size-browser, em ); |
| 30 |
|
| 31 |
// Colors |
| 32 |
@icon-color: @color-subtle; |
| 33 |
@margin-icon-md-labelled: 6px; |
| 34 |
|
| 35 |
/** |
| 36 |
* Mixin for a pseudo-element with a background image. |
| 37 |
*/ |
| 38 |
.mixin-background-square( @size ) { |
| 39 |
// Sizing properties |
| 40 |
content: ''; |
| 41 |
display: block; |
| 42 |
width: 100%; |
| 43 |
height: 100%; |
| 44 |
// In case display: block is overridden and display gets set to `flex` |
| 45 |
// because of inheritance T233521. |
| 46 |
min-width: @size; |
| 47 |
min-height: @size; |
| 48 |
|
| 49 |
// Background properties. |
| 50 |
background-repeat: no-repeat; |
| 51 |
// Using static value instead of `background-size: contain` because of T233521#5545513. |
| 52 |
background-size: @size @size; |
| 53 |
background-position: center; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* A standalone 20px square with screen-reader text. Contains a :before element |
| 58 |
* to house the icon as a background image. Total size is increased with padding via |
| 59 |
* `box-sizing: content-box`. This separates control over size of icon vs the size of |
| 60 |
* the touch-area. |
| 61 |
*/ |
| 62 |
.mw-ui-icon { |
| 63 |
// reset font-size so the "em" value is relative to the more |
| 64 |
// predictable rem font size ...and no rems because we can't have nice things. |
| 65 |
font-size: initial; |
| 66 |
|
| 67 |
// sizing |
| 68 |
position: relative; |
| 69 |
display: inline-block; |
| 70 |
|
| 71 |
// this is important for increasing the size via padding. Overrides `.view-border-box *`. |
| 72 |
// stylelint-disable-next-line declaration-no-important |
| 73 |
box-sizing: content-box !important; |
| 74 |
width: @icon-size-md; |
| 75 |
height: @icon-size-md; |
| 76 |
|
| 77 |
// Guarding against flex-box variability. |
| 78 |
min-width: @icon-size-md; |
| 79 |
min-height: @icon-size-md; |
| 80 |
flex-basis: @icon-size-md; |
| 81 |
|
| 82 |
// alignment |
| 83 |
vertical-align: middle; |
| 84 |
line-height: 0; |
| 85 |
|
| 86 |
// Overflow ellipsis. |
| 87 |
.text-overflow( @visible: false ); |
| 88 |
|
| 89 |
// resetting styles for <button> elements |
| 90 |
-moz-appearance: none; |
| 91 |
-webkit-appearance: none; |
| 92 |
background-color: transparent; |
| 93 |
margin: 0; |
| 94 |
padding: 0; |
| 95 |
|
| 96 |
&:not( .mw-ui-button ) { |
| 97 |
border: 0; |
| 98 |
} |
| 99 |
|
| 100 |
&::before { |
| 101 |
.mixin-background-square( @icon-size-md ); |
| 102 |
} |
| 103 |
|
| 104 |
// Use `not` selector to ensure we don't add space for machine readable markup. More info: T307233 |
| 105 |
& + span:not( :empty ) { |
| 106 |
// Margin is added to separate accompanying text. |
| 107 |
margin-left: @margin-icon-md-labelled; |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
.mw-ui-icon-element { |
| 112 |
border-radius: @border-radius-base; |
| 113 |
padding: @icon-padding-md; |
| 114 |
// Override line-height applied by `.mw-ui-button`. |
| 115 |
line-height: 0; |
| 116 |
transition: background-color @transition-duration-base; |
| 117 |
|
| 118 |
&.mw-ui-button { |
| 119 |
padding: @icon-padding-md-button; |
| 120 |
} |
| 121 |
// Combined with nowrap & ellipsis from .mw-ui-icon, forms safe "screen-reader" text. |
| 122 |
color: transparent; |
| 123 |
|
| 124 |
&:focus, |
| 125 |
&:active, |
| 126 |
&:visited { |
| 127 |
color: transparent; |
| 128 |
} |
| 129 |
|
| 130 |
// In desktop these icons shrink in size as touch area no longer important. |
| 131 |
@media ( min-width: @min-width-breakpoint-desktop ) { |
| 132 |
&.mw-ui-button { |
| 133 |
padding: @icon-padding-md-button--desktop; |
| 134 |
} |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
.mw-ui-icon-before { |
| 139 |
width: auto; |
| 140 |
max-width: 100%; |
| 141 |
|
| 142 |
&::before { |
| 143 |
// sizing |
| 144 |
display: inline-block; |
| 145 |
font-size: initial; |
| 146 |
width: auto; |
| 147 |
min-width: @icon-size-md; |
| 148 |
min-height: @icon-size-md; |
| 149 |
|
| 150 |
// alignment. Margin is added to separate accompanying text. |
| 151 |
margin-right: @margin-icon-md-labelled; |
| 152 |
vertical-align: middle; |
| 153 |
} |
| 154 |
|
| 155 |
span { |
| 156 |
vertical-align: middle; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
@media all and ( min-width: @min-width-breakpoint-desktop ) { |
| 161 |
.mw-ui-icon-with-label-desktop { |
| 162 |
// stylelint-disable-next-line declaration-no-important |
| 163 |
color: @icon-color !important; |
| 164 |
width: auto; |
| 165 |
line-height: inherit; |
| 166 |
flex-basis: auto; |
| 167 |
// Special case outside of standard buttons styling due to surrounding |
| 168 |
// interface elements, see T237019. |
| 169 |
// stylelint-disable-next-line declaration-no-important |
| 170 |
font-weight: 500 !important; |
| 171 |
|
| 172 |
&:hover, |
| 173 |
&:focus, |
| 174 |
&:active, |
| 175 |
&:visited { |
| 176 |
color: @icon-color; |
| 177 |
text-decoration: none; |
| 178 |
} |
| 179 |
|
| 180 |
&::before { |
| 181 |
width: auto; |
| 182 |
display: inline-block; |
| 183 |
// Don't use `@icon-padding-md` as we are adjacent to text. |
| 184 |
margin-right: @margin-icon-md-labelled; |
| 185 |
// Seems to be more visually centered than `middle`. |
| 186 |
vertical-align: text-bottom; |
| 187 |
} |
| 188 |
} |
| 189 |
} |