Skip to content
Snippets Groups Projects
Commit c65f571c authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

small adjustments to icon tag generation

parent f65081a8
No related branches found
No related tags found
1 merge request!1Draft: Adjust icon handling
...@@ -36,16 +36,10 @@ class Icon ...@@ -36,16 +36,10 @@ class Icon
const ROLE_SORT = 'sort'; const ROLE_SORT = 'sort';
const ROLE_STATUS_YELLOW = 'status-yellow'; const ROLE_STATUS_YELLOW = 'status-yellow';
protected $shape;
protected $role;
protected $attributes = [];
/** /**
* This is the magical Role to Color mapping. * This is the magical Role to Color mapping.
*/ */
private static $roles_to_colors = [ const ROLES_TO_COLORS = [
self::ROLE_INFO => 'black', self::ROLE_INFO => 'black',
self::ROLE_CLICKABLE => 'blue', self::ROLE_CLICKABLE => 'blue',
self::ROLE_ACCEPT => 'green', self::ROLE_ACCEPT => 'green',
...@@ -60,13 +54,18 @@ class Icon ...@@ -60,13 +54,18 @@ class Icon
self::ROLE_STATUS_YELLOW => 'yellow' self::ROLE_STATUS_YELLOW => 'yellow'
]; ];
protected $shape;
protected $role;
protected $attributes = [];
// return the color associated to a role // return the color associated to a role
private static function roleToColor($role) public static function roleToColor($role)
{ {
if (!isset(self::$roles_to_colors[$role])) { if (!isset(self::ROLES_TO_COLORS[$role])) {
throw new \InvalidArgumentException('Unknown role: "' . $role . '"'); throw new \InvalidArgumentException('Unknown role: "' . $role . '"');
} }
return self::$roles_to_colors[$role]; return self::ROLES_TO_COLORS[$role];
} }
// return the roles! associated to a color // return the roles! associated to a color
...@@ -75,7 +74,7 @@ class Icon ...@@ -75,7 +74,7 @@ class Icon
static $colors_to_roles; static $colors_to_roles;
if (!$colors_to_roles) { if (!$colors_to_roles) {
foreach (self::$roles_to_colors as $r => $c) { foreach (self::ROLES_TO_COLORS as $r => $c) {
$colors_to_roles[$c][] = $r; $colors_to_roles[$c][] = $r;
} }
} }
...@@ -169,7 +168,7 @@ class Icon ...@@ -169,7 +168,7 @@ class Icon
{ {
// only defined roles // only defined roles
if (!isset(self::$roles_to_colors[$role])) { if (!isset(self::ROLES_TO_COLORS[$role])) {
throw new \InvalidArgumentException('Creating an Icon without proper role: "' . $role . '"'); throw new \InvalidArgumentException('Creating an Icon without proper role: "' . $role . '"');
} }
...@@ -227,7 +226,7 @@ class Icon ...@@ -227,7 +226,7 @@ class Icon
*/ */
public function signalsAttention() public function signalsAttention()
{ {
return $this->roleToColor($this->role) === 'red'; return self::roleToColor($this->role) === 'red';
} }
/** /**
...@@ -436,7 +435,7 @@ class Icon ...@@ -436,7 +435,7 @@ class Icon
$result['alt'] = ''; $result['alt'] = '';
} }
$classNames = 'icon-role-' . $this->role; $classNames = 'icon-role-' . str_replace('_', '-', $this->role);
if (!self::isStatic($this->shape)) { if (!self::isStatic($this->shape)) {
$classNames .= ' icon-shape-' . $this->shape; $classNames .= ' icon-shape-' . $this->shape;
......
...@@ -299,7 +299,8 @@ div.overdiv { ...@@ -299,7 +299,8 @@ div.overdiv {
p { color: #000; } p { color: #000; }
} }
} }
img { img,
svg {
height: calc(100% - 20px); height: calc(100% - 20px);
position: absolute; position: absolute;
top: 10px; top: 10px;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment