_rating.less 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. // /**
  2. // * Copyright © Magento, Inc. All rights reserved.
  3. // * See COPYING.txt for license details.
  4. // */
  5. // # Ratings
  6. //
  7. // Ratings styling mixins are based on using font icons as rate symbols. There are two types of ratings: rating which allows user to vote and rating which displays voting results summary. Depending on the rating type mixin <code>.lib-rating-vote()</code> or <code>.lib-rating-summary()</code> is used.
  8. //
  9. // # Global rating variables
  10. //
  11. // Global styles for both types of ratings can be modified by changing global variables. To set different styles to types of ratings these variables should be used directly in the mixin call.
  12. //
  13. // <pre>
  14. // <table>
  15. // <tr>
  16. // <th class="vars_head">Mixin variable</th>
  17. // <th class="vars_head">Global variable</th>
  18. // <th class="vars_head">Default value</th>
  19. // <th class="vars_head">Allowed values</th>
  20. // <th class="vars_head">Comment</th>
  21. // </tr>
  22. // <tr>
  23. // <th>@_icon-content</th>
  24. // <td>@rating-icon__content</td>
  25. // <td class="vars_value">@icon-star</td>
  26. // <td class="vars_value">'' | false | icon code</td>
  27. // <td>Rating icon symbol code</td>
  28. // </tr>
  29. // <tr>
  30. // <th>@_icon-count</th>
  31. // <td>@rating-icon__count</td>
  32. // <td class="vars_value">5</td>
  33. // <td class="vars_value">'' | value</td>
  34. // <td>Number of rating icon symbols</td>
  35. // </tr>
  36. // <tr>
  37. // <th>@_icon-font</th>
  38. // <td>@rating-icon__font</td>
  39. // <td class="vars_value">@icon-font</td>
  40. // <td class="vars_value">'' | false | value</td>
  41. // <td>Icon font</td>
  42. // </tr>
  43. // <tr>
  44. // <th>@_icon-font-size</th>
  45. // <td>@rating-icon__font-size</td>
  46. // <td class="vars_value">28px</td>
  47. // <td class="vars_value">'' | false | value</td>
  48. // <td>Icon font size</td>
  49. // </tr>
  50. // <tr>
  51. // <th>@_icon-letter-spacing</th>
  52. // <td>@rating-icon__letter-spacing</td>
  53. // <td class="vars_value">-10px</td>
  54. // <td class="vars_value">'' | false | value</td>
  55. // <td>Icon letter spacing</td>
  56. // </tr>
  57. // <tr>
  58. // <th>@_icon-color</th>
  59. // <td>@rating-icon__color</td>
  60. // <td class="vars_value">#c7c7c7</td>
  61. // <td class="vars_value">'' | false | value</td>
  62. // <td>Unselected icons color</td>
  63. // </tr>
  64. // <tr>
  65. // <th>@_icon-color-active</th>
  66. // <td>@rating-icon__active__color</td>
  67. // <td class="vars_value">#ff5601</td>
  68. // <td class="vars_value">'' | false | value</td>
  69. // <td>Selected and hovered icons color</td>
  70. // </tr>
  71. // <tr>
  72. // <th>@_label-hide</th>
  73. // <td>@rating-label__hide</td>
  74. // <td class="vars_value">false</td>
  75. // <td class="vars_value">true | false</td>
  76. // <td>Rating label is displayed</td>
  77. // </tr>
  78. // </table>
  79. // </pre>
  80. //
  81. // # Rating with vote
  82. //
  83. // To implement rating with vote, use the <code>.lib-rating-vote()</code> mixin.
  84. // ``` html
  85. // <div class="rating vote example-ratings-1">
  86. // <input type="radio" name="rating-price" id="rating-price-1" value="1" />
  87. // <label class="rating-1" for="rating-price-1" title="1 star">
  88. // <span>1 star</span>
  89. // </label>
  90. // <input type="radio" name="rating-price" id="rating-price-2" value="2" />
  91. // <label class="rating-2" for="rating-price-2" title="2 stars">
  92. // <span>2 stars</span>
  93. // </label>
  94. // <input type="radio" name="rating-price" id="rating-price-3" value="3" />
  95. // <label class="rating-3" for="rating-price-3" title="3 stars">
  96. // <span>3 stars</span>
  97. // </label>
  98. // <input type="radio" name="rating-price" id="rating-price-4" value="4" />
  99. // <label class="rating-4" for="rating-price-4" title="4 stars">
  100. // <span>4 stars</span>
  101. // </label>
  102. // <input type="radio" name="rating-price" id="rating-price-5" value="5" />
  103. // <label class="rating-5" for="rating-price-5" title="5 stars">
  104. // <span>5 stars</span>
  105. // </label>
  106. // </div>
  107. // ```
  108. .example-ratings-1 {
  109. .lib-rating-vote();
  110. }
  111. // # Rating with vote icons number customization
  112. //
  113. // To change number of icons, add desired number of rating icons (input + label) to the markup. Then set this number to the <code>@_icon-count</code> mixin variable.
  114. //
  115. // ``` html
  116. // <div class="rating vote example-ratings-2">
  117. // <input type="radio" name="rating-price" id="rating-price-1" value="1" />
  118. // <label class="rating-1" for="rating-price-1" title="1 star">
  119. // <span>1 star</span>
  120. // </label>
  121. // <input type="radio" name="rating-price" id="rating-price-2" value="2" />
  122. // <label class="rating-2" for="rating-price-2" title="2 stars">
  123. // <span>2 stars</span>
  124. // </label>
  125. // <input type="radio" name="rating-price" id="rating-price-3" value="3" />
  126. // <label class="rating-3" for="rating-price-3" title="3 stars">
  127. // <span>3 stars</span>
  128. // </label>
  129. // <input type="radio" name="rating-price" id="rating-price-4" value="4" />
  130. // <label class="rating-4" for="rating-price-4" title="4 stars">
  131. // <span>4 stars</span>
  132. // </label>
  133. // <input type="radio" name="rating-price" id="rating-price-5" value="5" />
  134. // <label class="rating-5" for="rating-price-5" title="5 stars">
  135. // <span>5 stars</span>
  136. // </label>
  137. // <input type="radio" name="rating-price" id="rating-price-6" value="6" />
  138. // <label class="rating-6" for="rating-price-6" title="6 stars">
  139. // <span>6 stars</span>
  140. // </label>
  141. // <input type="radio" name="rating-price" id="rating-price-7" value="7" />
  142. // <label class="rating-7" for="rating-price-7" title="7 stars">
  143. // <span>7 stars</span>
  144. // </label>
  145. // <input type="radio" name="rating-price" id="rating-price-8" value="8" />
  146. // <label class="rating-8" for="rating-price-8" title="8 stars">
  147. // <span>8 stars</span>
  148. // </label>
  149. // </div>
  150. // ```
  151. .example-ratings-2 {
  152. .lib-rating-vote(
  153. @_icon-count: 8
  154. );
  155. }
  156. // # Rating with vote icons colors customization
  157. //
  158. // These variables control default and active icon colors:
  159. // ```css
  160. // @_icon-color: value,
  161. // @_icon-color-active: value
  162. // ```
  163. //
  164. // ``` html
  165. // <div class="rating vote example-ratings-3">
  166. // <input type="radio" name="rating-price" id="rating-price-1" value="1" />
  167. // <label class="rating-1" for="rating-price-1" title="1 star">
  168. // <span>1 star</span>
  169. // </label>
  170. // <input type="radio" name="rating-price" id="rating-price-2" value="2" />
  171. // <label class="rating-2" for="rating-price-2" title="2 stars">
  172. // <span>2 stars</span>
  173. // </label>
  174. // <input type="radio" name="rating-price" id="rating-price-3" value="3" />
  175. // <label class="rating-3" for="rating-price-3" title="3 stars">
  176. // <span>3 stars</span>
  177. // </label>
  178. // <input type="radio" name="rating-price" id="rating-price-4" value="4" />
  179. // <label class="rating-4" for="rating-price-4" title="4 stars">
  180. // <span>4 stars</span>
  181. // </label>
  182. // <input type="radio" name="rating-price" id="rating-price-5" value="5" />
  183. // <label class="rating-5" for="rating-price-5" title="5 stars">
  184. // <span>5 stars</span>
  185. // </label>
  186. // </div>
  187. // ```
  188. .example-ratings-3 {
  189. .lib-rating-vote(
  190. @_icon-color: #aff5e3,
  191. @_icon-color-active: #0a6767
  192. );
  193. }
  194. // # Rating with vote icons symbol customization
  195. //
  196. // To set custom icon symbol, use the <code>@_icon-content</code> variable
  197. //
  198. // ``` html
  199. // <div class="rating vote example-ratings-4">
  200. // <input type="radio" name="rating-price" id="rating-price-1" value="1" />
  201. // <label class="rating-1" for="rating-price-1" title="1 star">
  202. // <span>1 star</span>
  203. // </label>
  204. // <input type="radio" name="rating-price" id="rating-price-2" value="2" />
  205. // <label class="rating-2" for="rating-price-2" title="2 stars">
  206. // <span>2 stars</span>
  207. // </label>
  208. // <input type="radio" name="rating-price" id="rating-price-3" value="3" />
  209. // <label class="rating-3" for="rating-price-3" title="3 stars">
  210. // <span>3 stars</span>
  211. // </label>
  212. // <input type="radio" name="rating-price" id="rating-price-4" value="4" />
  213. // <label class="rating-4" for="rating-price-4" title="4 stars">
  214. // <span>4 stars</span>
  215. // </label>
  216. // <input type="radio" name="rating-price" id="rating-price-5" value="5" />
  217. // <label class="rating-5" for="rating-price-5" title="5 stars">
  218. // <span>5 stars</span>
  219. // </label>
  220. // </div>
  221. // ```
  222. .example-ratings-4 {
  223. .lib-rating-vote(
  224. @_icon-content: @icon-wishlist-full
  225. );
  226. }
  227. // # Accessible rating with vote
  228. //
  229. // The following markup corresponds to **accesibility** demands
  230. // ``` html
  231. // <fieldset class="exapmle-ratings-5 fieldset ratings vote">
  232. // <legend>How do you rate this product?</legend>
  233. // <div class="field price">
  234. // <label class="label" for="rating-1" id="price-rating-label"><span>Price</span></label>
  235. // <div class="control rating vote">
  236. // <input type="radio" name="rating-price" id="rating-price-1" value="1" aria-labelledby="price-rating-label rating-price-label-1" />
  237. // <label class="rating-1" for="rating-price-1" title="1 star" id="rating-price-label-1">
  238. // <span>1 star</span>
  239. // </label>
  240. // <input type="radio" name="rating-price" id="rating-price-2" value="2" aria-labelledby="price-rating-label rating-price-label-2" />
  241. // <label class="rating-2" for="rating-price-2" title="2 stars" id="rating-price-label-2">
  242. // <span>2 stars</span>
  243. // </label>
  244. // <input type="radio" name="rating-price" id="rating-price-3" value="3" aria-labelledby="price-rating-label rating-price-label-3" />
  245. // <label class="rating-3" for="rating-price-3" title="3 stars" id="rating-price-label-3">
  246. // <span>3 stars</span>
  247. // </label>
  248. // <input type="radio" name="rating-price" id="rating-price-4" value="4" aria-labelledby="price-rating-label rating-price-label-4" />
  249. // <label class="rating-4" for="rating-price-4" title="4 stars" id="rating-price-label-4">
  250. // <span>4 stars</span>
  251. // </label>
  252. // <input type="radio" name="rating-price" id="rating-price-5" value="5" aria-labelledby="price-rating-label rating-price-label-5" />
  253. // <label class="rating-5" for="rating-price-5" title="5 stars" id="rating-price-label-5">
  254. // <span>5 stars</span>
  255. // </label>
  256. // </div>
  257. // </div>
  258. // </fieldset>
  259. // ```
  260. .exapmle-ratings-5 {
  261. .control.rating.vote {
  262. .lib-rating-vote();
  263. }
  264. }
  265. // # Rating summary
  266. //
  267. // To implement rating summary, use the following markup
  268. // ``` html
  269. // <div class="example-rating-summary-1">
  270. // <span class="label"><span>Rating</span></span>
  271. // <div class="rating-result" title="60%">
  272. // <span style="width:60%"><span>60</span></span>
  273. // </div>
  274. // </div>
  275. // ```
  276. .example-rating-summary-1 {
  277. .lib-rating-summary();
  278. }
  279. // # Rating summary icons number customization
  280. //
  281. // To set up number of icons, use the variable:
  282. // ```css
  283. // @_icon-count: number
  284. // ```
  285. //
  286. // ``` html
  287. // <div class="example-rating-summary-2">
  288. // <span class="label"><span>Rating</span></span>
  289. // <div class="rating-result" title="40%">
  290. // <span style="width:40%"><span>40</span></span>
  291. // </div>
  292. // </div>
  293. // ```
  294. .example-rating-summary-2 {
  295. .lib-rating-summary(
  296. @_icon-count: 8
  297. );
  298. }
  299. // # Rating summary icons color customization
  300. //
  301. // To set up the icons default and selected color, use variables:
  302. // ```css
  303. // @_icon-color: value
  304. // @_icon-color-active: value
  305. // ```
  306. //
  307. // ``` html
  308. // <div class="example-rating-summary-3">
  309. // <span class="label"><span>Rating</span></span>
  310. // <div class="rating-result" title="40%">
  311. // <span style="width:40%"><span>40</span></span>
  312. // </div>
  313. // </div>
  314. // ```
  315. .example-rating-summary-3 {
  316. .lib-rating-summary(
  317. @_icon-color: #aff5e3,
  318. @_icon-color-active: #0a6767
  319. );
  320. }
  321. // # Rating summary icons symbol customization
  322. //
  323. // To set up the icons symbol use variable:
  324. // ```css
  325. // @_icon-content: icon_code
  326. // ```
  327. //
  328. // ``` html
  329. // <div class="example-rating-summary-4">
  330. // <span class="label"><span>Rating</span></span>
  331. // <div class="rating-result" title="40%">
  332. // <span style="width:40%"><span>40</span></span>
  333. // </div>
  334. // </div>
  335. // ```
  336. .example-rating-summary-4 {
  337. .lib-rating-summary(
  338. @_icon-content: @icon-wishlist-full
  339. );
  340. }
  341. // # Rating summary hide label
  342. //
  343. // To hide the rating summary label set:
  344. // ```css
  345. // @_label-hide: true
  346. // ```
  347. //
  348. // ``` html
  349. // <div class="example-rating-summary-5">
  350. // <span class="label"><span>Rating</span></span>
  351. // <div class="rating-result" title="40%">
  352. // <span style="width:40%"><span>40</span></span>
  353. // </div>
  354. // </div>
  355. // ```
  356. .example-rating-summary-5 {
  357. .lib-rating-summary(
  358. @_label-hide: true
  359. );
  360. }
  361. // # Rating summary multiple ratings
  362. //
  363. // ``` html
  364. // <div class="example-rating-summary-6" tabindex="1">
  365. // <strong>Your Rating:</strong>
  366. // <div class="rating-summary item">
  367. // <span class="label"><span>Value</span></span>
  368. // <div class="rating-result" title="100%" >
  369. // <span style="width:100%"><span>100%</span></span>
  370. // </div>
  371. // </div>
  372. // <div class="rating-summary item">
  373. // <span class="label"><span>Quality</span></span>
  374. // <div class="rating-result" title="100%">
  375. // <span style="width:100%"><span>100%</span></span>
  376. // </div>
  377. // </div>
  378. // <div class="rating-summary item">
  379. // <span class="label"><span>rating +</span></span>
  380. // <div class="rating-result" title="20%">
  381. // <span style="width:20%"><span>20%</span></span>
  382. // </div>
  383. // </div>
  384. // <div class="rating-summary item">
  385. // <span class="label"><span>Price</span></span>
  386. // <div class="rating-result" title="40%">
  387. // <span style="width:40%"><span>40%</span></span>
  388. // </div>
  389. // </div>
  390. // </div>
  391. // ```
  392. .example-rating-summary-6 {
  393. .rating-summary {
  394. .lib-rating-summary();
  395. }
  396. }
  397. // # Rating hide label mixin
  398. //
  399. // The <code>.lib-rating-summary-label-hide()</code> mixin is used to hide rating label in summary rating.
  400. //
  401. // ``` html
  402. // <div class="example-rating-summary-7">
  403. // <span class="label"><span>Rating</span></span>
  404. // <div class="rating-result" title="40%">
  405. // <span style="width:40%"><span>40</span></span>
  406. // </div>
  407. // </div>
  408. // ```
  409. .example-rating-summary-7 {
  410. .lib-rating-summary();
  411. .lib-rating-summary-label-hide();
  412. }