1441 |
ariadna |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace core\output\local\properties;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* Enum badge.
|
|
|
21 |
*
|
|
|
22 |
* This enum is used to define the different types of badges that can be used in the application.
|
|
|
23 |
*
|
|
|
24 |
* @package core
|
|
|
25 |
* @copyright 2025 Ferran Recio <ferran@moodle.com>
|
|
|
26 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
27 |
*/
|
|
|
28 |
enum badge: string {
|
|
|
29 |
case PRIMARY = 'primary';
|
|
|
30 |
case SECONDARY = 'secondary';
|
|
|
31 |
case SUCCESS = 'success';
|
|
|
32 |
case DANGER = 'danger';
|
|
|
33 |
case WARNING = 'warning';
|
|
|
34 |
case INFO = 'info';
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Returns the CSS classes for the property based on its type.
|
|
|
38 |
*
|
|
|
39 |
* @return string The CSS classes.
|
|
|
40 |
*/
|
|
|
41 |
public function classes(): string {
|
|
|
42 |
return match ($this) {
|
|
|
43 |
self::PRIMARY => ' badge rounded-pill text-bg-primary',
|
|
|
44 |
self::SECONDARY => ' badge rounded-pill text-bg-secondary',
|
|
|
45 |
self::SUCCESS => ' badge rounded-pill text-bg-success',
|
|
|
46 |
self::DANGER => ' badge rounded-pill text-bg-danger',
|
|
|
47 |
self::WARNING => ' badge rounded-pill text-bg-warning',
|
|
|
48 |
self::INFO => ' badge rounded-pill text-bg-info',
|
|
|
49 |
};
|
|
|
50 |
}
|
|
|
51 |
}
|