_utilities.less 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. // /**
  2. // * Copyright © Magento, Inc. All rights reserved.
  3. // * See COPYING.txt for license details.
  4. // */
  5. // # Utilities
  6. // <code>_utilities.less</code> is a reuseable collection of basic Less mixins.
  7. //
  8. // # .lib-clearfix()
  9. //
  10. // The <code>.lib-clearfix()</code> mixin is a modern solution for healing container`s height which have floated elements. Also its applying prevents top-margins from collapsing.
  11. //
  12. .example-clearfix-container-1 {
  13. border: 1px solid #f00;
  14. }
  15. .example-clearfix-container-2 {
  16. .lib-clearfix();
  17. border: 1px solid #0f0;
  18. }
  19. .example-clearfix-item.left {
  20. float: left;
  21. }
  22. .example-clearfix-item.right {
  23. float: right;
  24. }
  25. // Container with floated child elements without <code>.lib-clearfix()</code>
  26. // ```
  27. // <div class="example-clearfix-container-1">
  28. // <div class="example-clearfix-item left">
  29. // Float left
  30. // </div>
  31. // <div class="example-clearfix-item right">
  32. // Float right
  33. // </div>
  34. // </div>
  35. // ```
  36. // Container with floated child elements with <code>.lib-clearfix()</code>
  37. // ```
  38. // <div class="example-clearfix-container-2">
  39. // <div class="example-clearfix-item left">
  40. // Float left
  41. // </div>
  42. // <div class="example-clearfix-item right">
  43. // Float right
  44. // </div>
  45. // </div>
  46. // ```
  47. // # .lib-visibility-hidden()
  48. //
  49. // The <code>.lib-visibility-hidden()()</code> mixin changes element`s visibility to hidden and height to 0.
  50. //
  51. .example-visibility-hidden {
  52. .lib-visibility-hidden();
  53. }
  54. //
  55. // This is a block with applied <code>.lib-visibility-hidden()</code> mixin.
  56. //
  57. // ```
  58. // <div class="example-visibility-hidden">
  59. // <div>
  60. // This is hidden text
  61. // </div>
  62. // </div>
  63. // ```
  64. // # .lib-visually-hidden()
  65. //
  66. // The <code>.lib-visually-hidden()</code> mixin safely hides the element for accessibility reasons.
  67. //
  68. .example-visually-hidden-1 {
  69. .lib-visually-hidden();
  70. }
  71. //
  72. // This is a block with applied <code>.lib-visually-hidden()</code> mixin.
  73. //
  74. // ```
  75. // <div class="example-visually-hidden-1">
  76. // <div>
  77. // This is hidden text
  78. // </div>
  79. // </div>
  80. // ```
  81. // # .lib-visually-hidden-reset()
  82. //
  83. // The <code>.lib-visually-hidden-reset()</code> mixin resets hidden visibility and makes element again visible.
  84. //
  85. .example-visually-hidden-2 {
  86. background: #fdf0d5;
  87. padding: 5px;
  88. .lib-visually-hidden();
  89. }
  90. .example-visually-hidden-2 {
  91. .lib-visually-hidden-reset();
  92. }
  93. //
  94. // This is a block with applied <code>.lib-visually-hidden-reset()</code> mixin after <code>.lib-visually-hidden()</code> applying.
  95. //
  96. // ```
  97. // <div class="example-visually-hidden-2">
  98. // <div>
  99. // The text is visible again
  100. // </div>
  101. // </div>
  102. // ```
  103. // # .lib-css()
  104. //
  105. // The <code>.lib-css()</code> mixin is used to set any css property if there is a value passed to it by a variable. Also <code>.lib-css()</code> can add -ms-, -webkit- and -moz- prefixes if needed.
  106. //
  107. .example-css-container {
  108. .lib-css(padding, @indent__base);
  109. .lib-css(background, @secondary__color);
  110. }
  111. //
  112. // If the variable is set to <code>false</code>, the <code>.lib-css()</code> mixin will add nothing to the code.
  113. //
  114. // ```
  115. // <div class="example-css-container">
  116. // Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt..
  117. // </div>
  118. // ```
  119. //
  120. .example-css-container-2 {
  121. .lib-css(background, false);
  122. }
  123. // ```
  124. // <div class="example-css-container-2">
  125. // Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt..
  126. // </div>
  127. // ```
  128. //
  129. // # .lib-css() variables
  130. //
  131. // <pre>
  132. // <table>
  133. // <tr>
  134. // <th class="vars_head">Mixin variable</th>
  135. // <th class="vars_head">Default value </th>
  136. // <th class="vars_head">Allowed values</th>
  137. // <th class="vars_head">Comment</th>
  138. // </tr>
  139. // <tr>
  140. // <th>@_property</th>
  141. // <td class="vars_value">false</td>
  142. // <td class="vars_value">'' | false | value</td>
  143. // <td>Any css property</td>
  144. // </tr>
  145. // <tr>
  146. // <th>@_value</th>
  147. // <td class="vars_value">false</td>
  148. // <td class="vars_value">'' | false | value</td>
  149. // <td>Any css value</td>
  150. // </tr>
  151. // <tr>
  152. // <th>@_prefix</th>
  153. // <td class="vars_value">0</td>
  154. // <td class="vars_value">'' | false | 1</td>
  155. // <td>If set to "1" adds -ms-, -webkit- and -moz- prefixes to the property</td>
  156. // </tr>
  157. // </table>
  158. // </pre>
  159. // # .lib-rotate()
  160. //
  161. // The <code>.lib-rotate()</code> mixin is a wrapper for css3 transform property with rotate value.
  162. //
  163. .example-rotate {
  164. background: #f00;
  165. position: absolute;
  166. height: 20px;
  167. width: 40px;
  168. .lib-rotate(
  169. @_rotation: 45deg;
  170. );
  171. }
  172. //
  173. // ```
  174. // <div class="example-rotate"></div>
  175. // ```
  176. // # .lib-rotate() variables
  177. //
  178. // <pre>
  179. // <table>
  180. // <tr>
  181. // <th class="vars_head">Mixin variable</th>
  182. // <th class="vars_head">Default value </th>
  183. // <th class="vars_head">Allowed values</th>
  184. // <th class="vars_head">Comment</th>
  185. // </tr>
  186. // <tr>
  187. // <th>@rotation</th>
  188. // <td class="vars_value">''</td>
  189. // <td class="vars_value">'' | false | value</td>
  190. // <td>Transform rotate value, false or ''</td>
  191. // </tr>
  192. // </table>
  193. // </pre>
  194. // # .lib-input-placeholder()
  195. //
  196. // The <code>.lib-input-placeholder()</code> mixin is used to change placeholder font-color and font-weight.
  197. //
  198. .example-placeholder {
  199. .lib-input-placeholder(#808080, bold);
  200. }
  201. //
  202. // ```
  203. // <input placeholder="Default text" class="example-placeholder" type="text" />
  204. // ```
  205. //
  206. // # .lib-input-placeholder() variables
  207. //
  208. // <pre>
  209. // <table>
  210. // <tr>
  211. // <th class="vars_head">Mixin variable</th>
  212. // <th class="vars_head">Default value</th>
  213. // <th class="vars_head">Allowed values</th>
  214. // <th class="vars_head">Comment</th>
  215. // </tr>
  216. // <tr>
  217. // <th>@_input-placeholder-color</th>
  218. // <td class="vars_value">@form-element-input-placeholder__color</td>
  219. // <td class="vars_value">'' | false | value</td>
  220. // <td>Input placeholder color</td>
  221. // </tr>
  222. // <tr>
  223. // <th>@_input-placeholder-font-weight</th>
  224. // <td class="vars_value">@form-element-input__font-weight</td>
  225. // <td class="vars_value">'' | false | value</td>
  226. // <td>Input placeholder font-weight</td>
  227. // </tr>
  228. // </table>
  229. // </pre>
  230. // # .lib-background-gradient()
  231. //
  232. // The <code>.lib-background-gradient()</code> mixin is used for applying custom css3 gradient.
  233. //
  234. .example-background-gradient-1 {
  235. .lib-background-gradient(
  236. @_background-gradient: true,
  237. @_background-gradient-direction: vertical,
  238. @_background-gradient-color-start: #cff,
  239. @_background-gradient-color-end: #ccf
  240. );
  241. }
  242. .example-background-gradient-2 {
  243. .lib-background-gradient(
  244. @_background-gradient: true,
  245. @_background-gradient-direction: horizontal,
  246. @_background-gradient-color-start: #cff,
  247. @_background-gradient-color-end: #ccf
  248. );
  249. }
  250. .example-background-gradient-3-wrapper {
  251. background: #ffc;
  252. padding: 10px;
  253. }
  254. .example-background-gradient-3 {
  255. .lib-background-gradient(
  256. @_background-gradient: true,
  257. @_background-gradient-direction: horizontal,
  258. @_background-gradient-color-start: rgba(255,255,255,0),
  259. @_background-gradient-color-end: #ccf,
  260. @_background-gradient-color-position: false
  261. );
  262. }
  263. //
  264. // ```
  265. // <div class="example-background-gradient-1">
  266. // I`m gradient with vertical direction
  267. // </div>
  268. // ```
  269. //
  270. //
  271. // ```
  272. // <div class="example-background-gradient-2">
  273. // I`m gradient with horizontal direction
  274. // </div>
  275. // ```
  276. //
  277. //
  278. // ```
  279. // <div class="example-background-gradient-3-wrapper">
  280. // <div class="example-background-gradient-3">
  281. // I`m gradient with horizontal direction from transparent to a color
  282. // </div>
  283. // </div>
  284. // ```
  285. //
  286. // # .lib-background-gradient() variables
  287. //
  288. // <pre>
  289. // <table>
  290. // <tr>
  291. // <th class="vars_head">Mixin variable</th>
  292. // <th class="vars_head">Default value</th>
  293. // <th class="vars_head">Allowed values</th>
  294. // <th class="vars_head">Comment</th>
  295. // </tr>
  296. // <tr>
  297. // <th>@_background-gradient</th>
  298. // <td class="vars_value">false</td>
  299. // <td class="vars_value">'' | false | true</td>
  300. // <td>If set to 'true' the element has gradient background</td>
  301. // </tr>
  302. // <tr>
  303. // <th>@_background-gradient-direction</th>
  304. // <td class="vars_value">''</td>
  305. // <td class="vars_value">'' | horizontal | vertical</td>
  306. // <td>Gradient direction (horizontal or vertical)</td>
  307. // </tr>
  308. // <tr>
  309. // <th>@_background-gradient-color-start</th>
  310. // <td class="vars_value">''</td>
  311. // <td class="vars_value">'' | false | value</td>
  312. // <td>Gradient start color (any css color)</td>
  313. // </tr>
  314. // <tr>
  315. // <th>@_background-gradient-color-end</th>
  316. // <td class="vars_value">''</td>
  317. // <td class="vars_value">'' | false | value</td>
  318. // <td>Gradient end color (any css color) </td>
  319. // </tr>
  320. // <tr>
  321. // <th>@_background-gradient-color-position</th>
  322. // <td class="vars_value">false</td>
  323. // <td class="vars_value">'' | false | true</td>
  324. // <td>Sets the background-color fallback property. When set to 'false', the background-color property will be set to @_background-gradient-color-end. When set to 'true', the background-color property will be set to @_background-gradient-color-start</td>
  325. // </tr>
  326. // </table>
  327. // </pre>