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