test_badges.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <?php
  2. //define("NOLOGIN",1); // This means this output page does not require to be logged.
  3. define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
  4. if (!defined('NOSESSION')) {
  5. define('NOSESSION', '1');
  6. }
  7. require_once '../../main.inc.php';
  8. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
  9. if ($dolibarr_main_prod) {
  10. accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1');
  11. }
  12. /*
  13. * View
  14. */
  15. header("Content-type: text/html; charset=UTF8");
  16. // Security options
  17. header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
  18. header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks)
  19. ?>
  20. <!doctype html>
  21. <html lang="en">
  22. <head>
  23. <meta charset="utf-8">
  24. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  25. <meta name="description" content="Documentation and examples for theme.">
  26. <link href="<?php echo DOL_URL_ROOT ?>/theme/eldy/style.css.php" rel="stylesheet">
  27. </head>
  28. <body class="docpage" style="padding: 20px;">
  29. <main role="main" >
  30. <h1 class="bd-title" id="content">Badges</h1>
  31. <p class="bd-lead">Documentation and examples for badges, our small count and labeling component.</p>
  32. <h2 id="example">Example</h2>
  33. <p>Badges scale to match the size of the immediate parent element by using relative font sizing and em units.</p>
  34. <div class="bd-example">
  35. <h1>Example heading <span class="badge badge-secondary">New</span></h1>
  36. <h2>Example heading <span class="badge badge-secondary">New</span></h2>
  37. <h3>Example heading <span class="badge badge-secondary">New</span></h3>
  38. <h4>Example heading <span class="badge badge-secondary">New</span></h4>
  39. <h5>Example heading <span class="badge badge-secondary">New</span></h5>
  40. <h6>Example heading <span class="badge badge-secondary">New</span></h6>
  41. </div>
  42. <figure class="highlight">
  43. <pre>
  44. &lt;h1&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h1&gt;
  45. &lt;h2&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h2&gt;
  46. &lt;h3&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h3&gt;
  47. &lt;h4&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h4&gt;
  48. &lt;h5&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h5&gt;
  49. &lt;h6&gt;Example heading &lt;span class=&quot;badge badge-secondary&quot;&gt;New&lt;/span&gt;&lt;/h6&gt;
  50. </pre>
  51. </figure>
  52. <p>Badges can be used as part of links or buttons to provide a counter.</p>
  53. <div class="bd-example">
  54. <button type="button" class="button">
  55. Notifications <span class="badge badge-primary">4</span>
  56. </button>
  57. </div>
  58. <figure class="highlight"><pre>
  59. &lt;button type=&quot;button&quot; class=&quot;button&quot;&gt;
  60. Notifications &lt;span class=&quot;badge badge-primary&quot;&gt;4&lt;/span&gt;
  61. &lt;/button&gt;
  62. </pre></figure>
  63. <div class="warning">
  64. <p>Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.</p>
  65. <p>Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.</p>
  66. <p><strong>Remember to use aria-label attribute for accessibility in Dolibarr. Don't forget to use aria-hidden on icons included in badges</strong></p>
  67. </div>
  68. <div class="bd-example">
  69. <button type="button" class="button">
  70. Profile <span class="badge badge-primary" aria-label="9 unread messages" >9</span>
  71. <span class="sr-only">unread messages</span>
  72. </button>
  73. </div>
  74. <figure class="highlight">
  75. <pre>
  76. &lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot;&gt;
  77. Profile &lt;span class=&quot;badge badge-light&quot; aria-label=&quot;9 unread messages&quot; &gt;9&lt;/span&gt;
  78. &lt;span class=&quot;sr-only&quot;&gt;unread messages&lt;/span&gt;
  79. &lt;/button&gt;
  80. </pre>
  81. </figure>
  82. <h2 id="contextual-variations">Contextual variations</h2>
  83. <p>Add any of the below mentioned modifier classes to change the appearance of a badge.</p>
  84. <div class="bd-example">
  85. <span class="badge badge-primary">Primary</span>
  86. <span class="badge badge-secondary">Secondary</span>
  87. <span class="badge badge-success">Success</span>
  88. <span class="badge badge-danger">Danger</span>
  89. <span class="badge badge-warning">Warning</span>
  90. <span class="badge badge-info">Info</span>
  91. <span class="badge badge-light">Light</span>
  92. <span class="badge badge-dark">Dark</span>
  93. </div>
  94. <figure class="highlight">
  95. <pre>
  96. &lt;span class=&quot;badge badge-primary&quot;&gt;Primary&lt;/span&gt;
  97. &lt;span class=&quot;badge badge-secondary&quot;&gt;Secondary&lt;/span&gt;
  98. &lt;span class=&quot;badge badge-success&quot;&gt;Success&lt;/span&gt;
  99. &lt;span class=&quot;badge badge-danger&quot;&gt;Danger&lt;/span&gt;
  100. &lt;span class=&quot;badge badge-warning&quot;&gt;Warning&lt;/span&gt;
  101. &lt;span class=&quot;badge badge-info&quot;&gt;Info&lt;/span&gt;
  102. &lt;span class=&quot;badge badge-light&quot;&gt;Light&lt;/span&gt;
  103. &lt;span class=&quot;badge badge-dark&quot;&gt;Dark&lt;/span&gt;
  104. </pre>
  105. </figure>
  106. <div class="warning">
  107. <h5 id="conveying-meaning-to-assistive-technologies">Conveying meaning to assistive technologies</h5>
  108. <p>Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.</p>
  109. </div>
  110. <h2 id="contextual-variations">Default status</h2>
  111. <p>Add any of the below mentioned modifier classes to change the appearance of a badge to be linked to a default status.</p>
  112. <div class="bd-example">
  113. <?php for ($i = 0; $i <= 9; $i++) : ?>
  114. <span class="badge badge-status<?php print $i; ?>" >status-<?php print $i; ?></span>
  115. <?php endfor; ?>
  116. </div>
  117. <figure class="highlight"><pre><pre>
  118. <?php for ($i = 0; $i <= 9; $i++) : ?>
  119. &lt;span class="badge badge-status<?php print $i; ?>" &gt;status<?php print $i; ?>&lt;/span&gt;
  120. <?php endfor; ?>
  121. </pre></figure>
  122. <h2 id="pill-badges">Pill badges</h2>
  123. <p>Use the .badge-pill modifier class to make badges more rounded (with a larger border-radius and additional horizontal padding).</p>
  124. <div class="bd-example">
  125. <span class="badge badge-pill badge-primary">Primary</span>
  126. <span class="badge badge-pill badge-secondary">Secondary</span>
  127. <span class="badge badge-pill badge-success">Success</span>
  128. <span class="badge badge-pill badge-danger">Danger</span>
  129. <span class="badge badge-pill badge-warning">Warning</span>
  130. <span class="badge badge-pill badge-info">Info</span>
  131. <span class="badge badge-pill badge-light">Light</span>
  132. <span class="badge badge-pill badge-dark">Dark</span>
  133. <?php for ($i = 0; $i <= 9; $i++) : ?>
  134. <span class="badge badge-pill badge-status<?php print $i; ?>" >status<?php print $i; ?></span>
  135. <?php endfor; ?>
  136. </div>
  137. <figure class="highlight">
  138. <pre>
  139. &lt;span class=&quot;badge badge-pill badge-primary&quot;&gt;Primary&lt;/span&gt;
  140. &lt;span class=&quot;badge badge-pill badge-secondary&quot;&gt;Secondary&lt;/span&gt;
  141. &lt;span class=&quot;badge badge-pill badge-success&quot;&gt;Success&lt;/span&gt;
  142. &lt;span class=&quot;badge badge-pill badge-danger&quot;&gt;Danger&lt;/span&gt;
  143. &lt;span class=&quot;badge badge-pill badge-warning&quot;&gt;Warning&lt;/span&gt;
  144. &lt;span class=&quot;badge badge-pill badge-info&quot;&gt;Info&lt;/span&gt;
  145. &lt;span class=&quot;badge badge-pill badge-light&quot;&gt;Light&lt;/span&gt;
  146. &lt;span class=&quot;badge badge-pill badge-dark&quot;&gt;Dark&lt;/span&gt;
  147. <?php for ($i = 0; $i <= 9; $i++) : ?>
  148. &lt;span class="badge badge-pill badge-status<?php print $i; ?>" &gt;status<?php print $i; ?>&lt;/span&gt;
  149. <?php endfor; ?>
  150. </pre></figure>
  151. <h2 id="dot-badges">Dot badges</h2>
  152. <p>.dot-pill modifier class to make badges circle.</p>
  153. <div class="bd-example">
  154. <span class="badge badge-dot badge-primary"></span>
  155. <span class="badge badge-dot badge-secondary"></span>
  156. <span class="badge badge-dot badge-success"></span>
  157. <span class="badge badge-dot badge-danger"></span>
  158. <span class="badge badge-dot badge-warning"></span>
  159. <span class="badge badge-dot badge-info"></span>
  160. <span class="badge badge-dot badge-light"></span>
  161. <span class="badge badge-dot badge-dark"></span>
  162. <?php for ($i = 0; $i <= 9; $i++) : ?>
  163. <span class="badge badge-dot badge-status<?php print $i; ?>" ></span>
  164. <?php endfor; ?>
  165. </div>
  166. <figure class="highlight">
  167. <pre>
  168. &lt;span class=&quot;badge badge-dot badge-primary&quot;&gt;&lt;/span&gt;
  169. &lt;span class=&quot;badge badge-dot badge-secondary&quot;&gt;&lt;/span&gt;
  170. &lt;span class=&quot;badge badge-dot badge-success&quot;&gt;&lt;/span&gt;
  171. &lt;span class=&quot;badge badge-dot badge-danger&quot;&gt;&lt;/span&gt;
  172. &lt;span class=&quot;badge badge-dot badge-warning&quot;&gt;&lt;/span&gt;
  173. &lt;span class=&quot;badge badge-dot badge-info&quot;&gt;&lt;/span&gt;
  174. &lt;span class=&quot;badge badge-dot badge-light&quot;&gt;&lt;/span&gt;
  175. &lt;span class=&quot;badge badge-dot badge-dark&quot;&gt;&lt;/span&gt;
  176. <?php for ($i = 0; $i <= 9; $i++) : ?>
  177. &lt;span class="badge badge-dot badge-status<?php print $i; ?>" &gt;&lt;/span&gt;
  178. <?php endfor; ?>
  179. </pre></figure>
  180. <div class="warning">
  181. <p>Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.</p>
  182. <p>Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.</p>
  183. <p><strong>Remember to use aria-label attribute for accessibility in Dolibarr. Don't forget to use aria-hidden on icons included in badges</strong></p>
  184. </div>
  185. <h2 id="links">Links</h2>
  186. <p>Using the contextual .badge-* classes on an &lt;a&gt; element quickly provide <em>actionable</em> badges with hover and focus states.</p>
  187. <div class="bd-example">
  188. <a href="#" class="badge badge-primary">Primary</a>
  189. <a href="#" class="badge badge-secondary">Secondary</a>
  190. <a href="#" class="badge badge-success">Success</a>
  191. <a href="#" class="badge badge-danger">Danger</a>
  192. <a href="#" class="badge badge-warning">Warning</a>
  193. <a href="#" class="badge badge-info">Info</a>
  194. <a href="#" class="badge badge-light">Light</a>
  195. <a href="#" class="badge badge-dark">Dark</a>
  196. <?php for ($i = 0; $i <= 9; $i++) : ?>
  197. <a href="#" class="badge badge-status<?php print $i; ?>" >status<?php print $i; ?></a>
  198. <?php endfor; ?>
  199. </div>
  200. <figure class="highlight"><pre>
  201. &lt;a href=&quot;#&quot; class=&quot;badge badge-primary&quot;&gt;Primary&lt;/a&gt;
  202. &lt;a href=&quot;#&quot; class=&quot;badge badge-secondary&quot;&gt;Secondary&lt;/a&gt;
  203. &lt;a href=&quot;#&quot; class=&quot;badge badge-success&quot;&gt;Success&lt;/a&gt;
  204. &lt;a href=&quot;#&quot; class=&quot;badge badge-danger&quot;&gt;Danger&lt;/a&gt;
  205. &lt;a href=&quot;#&quot; class=&quot;badge badge-warning&quot;&gt;Warning&lt;/a&gt;
  206. &lt;a href=&quot;#&quot; class=&quot;badge badge-info&quot;&gt;Info&lt;/a&gt;
  207. &lt;a href=&quot;#&quot; class=&quot;badge badge-light&quot;&gt;Light&lt;/a&gt;
  208. &lt;a href=&quot;#&quot; class=&quot;badge badge-dark&quot;&gt;Dark&lt;/a&gt;
  209. <?php for ($i = 0; $i <= 9; $i++) : ?>
  210. &lt;a href=&quot;#&quot; class="badge badge-status<?php print $i; ?>" &gt;status<?php print $i; ?>&lt;/a&gt;
  211. <?php endfor; ?>
  212. </pre></figure>
  213. <h2 id="helper">Use badge helper function</h2>
  214. <p>Using the dolGetBadge function provide in core/lib/functions.lib.php. This function is recommended for code uniformisation and easy maintain</p>
  215. <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'primary') ?>
  216. <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'danger', 'pill') ?>
  217. <?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'warning', 'dot') ?>
  218. <figure class="highlight"><pre>
  219. &lt;?php print dolGetBadge('your label for accessibility', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'danger', 'pill') ?&gt;
  220. &lt;?php print dolGetBadge('your label for accessibility', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'warning', 'dot') ?&gt;
  221. </pre></figure>
  222. <h2 id="helper">Use status helper function</h2>
  223. <p>Using the dolGetStatus function provide in core/lib/functions.lib.php. This function is recommended for code uniformisation and easy maintain</p>
  224. <?php
  225. $saveGlobalConf = $conf->global->MAIN_STATUS_USES_CSS;
  226. $conf->global->MAIN_STATUS_USES_CSS = 1;
  227. ?>
  228. <h4>Using hidden global conf MAIN_STATUS_USES_CSS=1</h4>
  229. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4') ?></p>
  230. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 1) ?></p>
  231. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 2) ?></p>
  232. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 3) ?></p>
  233. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 4) ?></p>
  234. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 5) ?></p>
  235. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 6) ?></p>
  236. <?php $conf->global->MAIN_STATUS_USES_CSS = 0; ?>
  237. <h4>Disabled hidden global conf : MAIN_STATUS_USES_CSS=0</h4>
  238. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 1) ?></p>
  239. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 2) ?></p>
  240. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 3) ?></p>
  241. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 4) ?></p>
  242. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 5) ?></p>
  243. <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4', 6) ?></p>
  244. <?php $conf->global->MAIN_STATUS_USES_CSS = $saveGlobalConf; ?>
  245. <figure class="highlight"><pre>
  246. &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4') ?&gt;
  247. &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',1) ?&gt;
  248. &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',2) ?&gt;
  249. &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',3) ?&gt;
  250. &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',4) ?&gt;
  251. &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',5) ?&gt;
  252. &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',6) ?&gt;
  253. </pre></figure>
  254. </main>
  255. </body>
  256. </html>