dolibarr 21.0.0-alpha
badges.inc.php
1<?php
2/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
3 */
4if (!defined('ISLOADEDBYSTEELSHEET')) {
5 die('Must be called by steelsheet');
6}
7
8// From theme_vars.inc, must be included by steelsheet
9'
10@phan-var-force string $badgePrimary
11@phan-var-force string $badgeSecondary
12@phan-var-force string $badgeSuccess
13@phan-var-force string $badgeDanger
14@phan-var-force string $badgeWarning
15@phan-var-force string $badgeInfo
16@phan-var-force string $badgeLight
17@phan-var-force string $badgeDark
18@phan-var-force string $colorblind_deuteranopes_badgeWarning
19';
20?>
21/* <style type="text/css" > */
22/*
23 Badge style is based on bootstrap framework
24 */
25
26.badge {
27 display: inline-block;
28 padding: .1em .35em;
29 font-size: 80%;
30 font-weight: 700 !important;
31 line-height: 1;
32 text-align: center;
33 white-space: nowrap;
34 vertical-align: baseline;
35 border-radius: .25rem;
36 transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
37 border-width: 2px;
38 border-style: solid;
39 border-color: rgba(255,255,255,0);
40 box-sizing: border-box;
41}
42
43.badge-status {
44 font-size: 1em;
45 padding: .19em .35em; /* more than 0.19 generate a change into height of lines */
46}
47.tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status {
48 font-size: 1.1em;
49 padding: .4em .4em;
50}
51/* Force values for small screen 767 */
52@media only screen and (max-width: 767px)
53{
54 .tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status {
55 font-size: 0.95em;
56 padding: .3em .2em;
57 }
58}
59
60.badge-pill, .tabs .badge {
61 padding-right: .5em;
62 padding-left: .5em;
63 border-radius: 0.25rem;
64}
65
66.badge-dot {
67 padding: 0;
68 border-radius: 50%;
69 padding: 0.45em;
70 vertical-align: unset;
71}
72
73a.badge:focus, a.badge:hover {
74 text-decoration: none;
75}
76
77.liste_titre .badge:not(.nochangebackground) {
78 background-color: <?php print $badgeSecondary; ?>;
79 color: #fff;
80}
81
82span.badgeneutral {
83 padding: 2px 7px 2px 7px;
84 background-color: #e4e4e4;
85 color: #666;
86 border-radius: 10px;
87 white-space: nowrap;
88}
89
90
91/* PRIMARY */
92.badge-primary{
93 color: #fff !important;
94 background-color: <?php print $badgePrimary; ?>;
95}
96a.badge-primary.focus, a.badge-primary:focus {
97 outline: 0;
98 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgePrimary, 0.5); ?>;
99}
100a.badge-primary:focus, a.badge-primary:hover {
101 color: #fff !important;
102 background-color: <?php print colorDarker($badgePrimary, 10); ?>;
103}
104
105/* SECONDARY */
106.badge-secondary, .tabs .badge {
107 color: #fff !important;
108 background-color: <?php print $badgeSecondary; ?>;
109}
110a.badge-secondary.focus, a.badge-secondary:focus {
111 outline: 0;
112 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSecondary, 0.5); ?>;
113}
114a.badge-secondary:focus, a.badge-secondary:hover {
115 color: #fff !important;
116 background-color: <?php print colorDarker($badgeSecondary, 10); ?>;
117}
118
119/* SUCCESS */
120.badge-success {
121 color: #fff !important;
122 background-color: <?php print $badgeSuccess; ?>;
123}
124a.badge-success.focus, a.badge-success:focus {
125 outline: 0;
126 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSuccess, 0.5); ?>;
127}
128a.badge-success:focus, a.badge-success:hover {
129 color: #fff !important;
130 background-color: <?php print colorDarker($badgeSuccess, 10); ?>;
131}
132
133/* DANGER */
134.badge-danger {
135 color: #fff !important;
136 background-color: <?php print $badgeDanger; ?>;
137}
138a.badge-danger.focus, a.badge-danger:focus {
139 outline: 0;
140 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDanger, 0.5); ?>;
141}
142a.badge-danger:focus, a.badge-danger:hover {
143 color: #fff !important;
144 background-color: <?php print colorDarker($badgeDanger, 10); ?>;
145}
146
147/* WARNING */
148.badge-warning {
149 color: #fff !important;
150 background-color: <?php print $badgeWarning; ?>;
151}
152a.badge-warning.focus, a.badge-warning:focus {
153 outline: 0;
154 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeWarning, 0.5); ?>;
155}
156a.badge-warning:focus, a.badge-warning:hover {
157 color: #212529 !important;
158 background-color: <?php print colorDarker($badgeWarning, 10); ?>;
159}
160
161/* WARNING colorblind */
162body[class*="colorblind-"] .badge-warning {
163 background-color: <?php print $colorblind_deuteranopes_badgeWarning; ?>;
164 }
165body[class*="colorblind-"] a.badge-warning.focus,body[class^="colorblind-"] a.badge-warning:focus {
166 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($colorblind_deuteranopes_badgeWarning, 0.5); ?>;
167}
168body[class*="colorblind-"] a.badge-warning:focus, a.badge-warning:hover {
169 background-color: <?php print colorDarker($colorblind_deuteranopes_badgeWarning, 10); ?>;
170}
171
172/* INFO */
173.badge-info {
174 color: #fff !important;
175 background-color: <?php print $badgeInfo; ?>;
176}
177a.badge-info.focus, a.badge-info:focus {
178 outline: 0;
179 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeInfo, 0.5); ?>;
180}
181a.badge-info:focus, a.badge-info:hover {
182 color: #fff !important;
183 background-color: <?php print colorDarker($badgeInfo, 10); ?>;
184}
185
186/* LIGHT */
187.badge-light {
188 color: #212529 !important;
189 background-color: <?php print $badgeLight; ?>;
190}
191a.badge-light.focus, a.badge-light:focus {
192 outline: 0;
193 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeLight, 0.5); ?>;
194}
195a.badge-light:focus, a.badge-light:hover {
196 color: #212529 !important;
197 background-color: <?php print colorDarker($badgeLight, 10); ?>;
198}
199
200/* DARK */
201.badge-dark {
202 color: #fff !important;
203 background-color: <?php print $badgeDark; ?>;
204}
205a.badge-dark.focus, a.badge-dark:focus {
206 outline: 0;
207 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDark, 0.5); ?>;
208}
209a.badge-dark:focus, a.badge-dark:hover {
210 color: #fff !important;
211 background-color: <?php print colorDarker($badgeDark, 10); ?>;
212}
213
214
215@media only screen and (max-width: 570px)
216{
217 span.badge.badge-status {
218 overflow: hidden;
219 max-width: 130px;
220 text-overflow: ellipsis;
221 }
222}
223
224
225/* STATUS BADGES */
226<?php
227for ($i = 0; $i <= 10; $i++) {
228 /* Default Status */
229 _createStatusBadgeCss((string) $i, '', "STATUS".$i);
230
231 // create status for accessibility
232 _createStatusBadgeCss((string) $i, 'colorblind_deuteranopes_', "COLORBLIND STATUS".$i, 'body[class*="colorblind-"] ');
233}
234
235_createStatusBadgeCss('1b', '', "STATUS1b");
236_createStatusBadgeCss('4b', '', "STATUS4b");
237
247function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentLabel = '', $cssPrefix = '')
248{
249 global ${$statusVarNamePrefix.'badgeStatus'.$statusName}, ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
250
251 if (!empty(${$statusVarNamePrefix.'badgeStatus'.$statusName})) {
252 print "\n/* ".strtoupper($commentLabel)." */\n";
253
254 $thisBadgeBackgroundColor = $thisBadgeBorderColor = ${$statusVarNamePrefix.'badgeStatus'.$statusName};
255
256
257 $TBadgeBorderOnly = array('0', '1b', '3', '4b', '5', '7', '10');
258 $thisBadgeTextColor = colorIsLight(${$statusVarNamePrefix.'badgeStatus'.$statusName}) ? '#212529' : '#ffffff';
259
260 if (!empty(${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName})) {
261 $thisBadgeTextColor = ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
262 }
263
264 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
265 $thisBadgeTextColor = '#212529';
266 $thisBadgeBackgroundColor = "#fff";
267 }
268
269 if (in_array((string) $statusName, array('0', '5', '9'))) {
270 $thisBadgeTextColor = '#999999';
271 }
272 if (in_array((string) $statusName, array('6'))) {
273 $thisBadgeTextColor = '#777777';
274 }
275
276 // badge-statusX
277 print $cssPrefix.".badge-status".$statusName." {\n";
278 print " color: ".$thisBadgeTextColor." !important;\n";
279 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
280 print " border-color: ".$thisBadgeBorderColor." !important;\n";
281 }
282 if ($thisBadgeBackgroundColor != '') {
283 print " background-color: ".$thisBadgeBackgroundColor." !important;\n";
284 }
285 print "}\n";
286
287 print $cssPrefix.".font-status".$statusName." {\n";
288 if ($thisBadgeBackgroundColor != '') {
289 print " color: ".$thisBadgeBackgroundColor." !important;\n";
290 }
291 print "}\n";
292
293 // badge-statusX:focus
294 print $cssPrefix.".badge-status".$statusName.".focus, ".$cssPrefix.".badge-status".$statusName.":focus {\n";
295 print " outline: 0;\n";
296 print " box-shadow: 0 0 0 0.2rem ".colorHexToRgb($thisBadgeBackgroundColor, 0.5)." !important;\n";
297 print "}\n";
298
299 print $cssPrefix.".badge-status".$statusName.":focus, ".$cssPrefix.".badge-status".$statusName.":hover {\n";
300 print " color: ".$thisBadgeTextColor." !important;\n";
301 //print " background-color: ".colorDarker($thisBadgeBackgroundColor, 10).";\n";
302 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
303 print " border-color: ".colorDarker($thisBadgeBorderColor, 10)." !important;\n";
304 }
305 print "}\n";
306 }
307}
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:162
colorHexToRgb($hex, $alpha=false, $returnArray=false)
colorDarker($hex, $percent)
colorIsLight($stringcolor)
Return true if the color is light.