mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°3791 - Panel: Use style defined in the DM for classes
Note that for now, semantic colors cannot be used directly in a <main_color> or <complementary_color> tag. Only valid CSS color (hexa, hsla, ...)
This commit is contained in:
@@ -19,11 +19,31 @@ $ibo-panel--base-transition: $ibo-panel--base-transition-property $ibo-panel--ba
|
||||
transition: $ibo-panel--base-transition;
|
||||
}
|
||||
|
||||
$ibo-panel-colors: (
|
||||
'primary': $ibo-color-primary-600,
|
||||
'secondary': $ibo-color-secondary-600,
|
||||
'neutral': $ibo-color-grey-600,
|
||||
'information': $ibo-color-information-600,
|
||||
'success': $ibo-color-success-600,
|
||||
'failure': $ibo-color-danger-600,
|
||||
'warning': $ibo-color-warning-600,
|
||||
'danger': $ibo-color-danger-600,
|
||||
'grey' : $ibo-color-grey-600,
|
||||
'blue-grey': $ibo-color-blue-grey-600,
|
||||
'blue': $ibo-color-blue-800,
|
||||
'cyan': $ibo-color-cyan-600,
|
||||
'green': $ibo-color-green-600,
|
||||
'orange' : $ibo-color-orange-600,
|
||||
'red': $ibo-color-red-600,
|
||||
'pink': $ibo-color-pink-600,
|
||||
) !default;
|
||||
|
||||
/* - Specific variables for the block */
|
||||
$ibo-panel--spacing-top: 24px !default;
|
||||
|
||||
$ibo-panel--highlight--width: 100% !default;
|
||||
$ibo-panel--highlight--height: 8px !default;
|
||||
$ibo-panel--highlight--background-color: 8px !default;
|
||||
$ibo-panel--highlight--border-radius: $ibo-border-radius-400 $ibo-border-radius-400 0 0 !default;
|
||||
$ibo-panel--highlight--padding-bottom: $ibo-panel--highlight--height !default;
|
||||
|
||||
@@ -68,47 +88,14 @@ $ibo-panel--collapsible-toggler--margin-right: 8px !default;
|
||||
$ibo-panel--collapsible-toggler--font-size: $ibo-font-size-250 !default;
|
||||
$ibo-panel--collapsible-toggler--color: $ibo-color-grey-700 !default;
|
||||
|
||||
$ibo-panel-colors: (
|
||||
'primary': $ibo-color-primary-600,
|
||||
'secondary': $ibo-color-secondary-600,
|
||||
'neutral': $ibo-color-grey-600,
|
||||
'information': $ibo-color-information-600,
|
||||
'success': $ibo-color-success-600,
|
||||
'failure': $ibo-color-danger-600,
|
||||
'warning': $ibo-color-warning-600,
|
||||
'danger': $ibo-color-danger-600,
|
||||
'grey' : $ibo-color-grey-600,
|
||||
'blue-grey': $ibo-color-blue-grey-600,
|
||||
'blue': $ibo-color-blue-800,
|
||||
'cyan': $ibo-color-cyan-600,
|
||||
'green': $ibo-color-green-600,
|
||||
'orange' : $ibo-color-orange-600,
|
||||
'red': $ibo-color-red-600,
|
||||
'pink': $ibo-color-pink-600,
|
||||
) !default;
|
||||
|
||||
@each $sColor, $sColorValue in $ibo-panel-colors {
|
||||
.ibo-panel.ibo-is-#{$sColor} > .ibo-panel--body::before {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
|
||||
background-color: $sColorValue;
|
||||
content: "";
|
||||
|
||||
width: $ibo-panel--highlight--width;
|
||||
height: $ibo-panel--highlight--height;
|
||||
padding-bottom: $ibo-panel--highlight--padding-bottom;
|
||||
}
|
||||
}
|
||||
|
||||
/* Rules */
|
||||
.ibo-panel + .ibo-panel {
|
||||
margin-top: $ibo-panel--spacing-top;
|
||||
}
|
||||
|
||||
.ibo-panel {
|
||||
--ibo-main-color: map-get($ibo-panel-colors, 'neutral'); /* --ibo-main-color is to allow overload from custom dynamic value from the DM. The overload will be done through an additional CSS class of a particular DM class or DM attribute */
|
||||
|
||||
position: relative;
|
||||
|
||||
&.ibo-has-icon {
|
||||
@@ -214,6 +201,26 @@ $ibo-panel-colors: (
|
||||
overflow: hidden; /* To force highlight color to be cropped by the border radius */
|
||||
|
||||
@extend %ibo-font-size-150;
|
||||
|
||||
&::before {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
|
||||
background-color: var(--ibo-main-color); /* Default value defined in .ibo-panel, can be overloaded by custom CSS classes */
|
||||
content: "";
|
||||
|
||||
width: $ibo-panel--highlight--width;
|
||||
height: $ibo-panel--highlight--height;
|
||||
padding-bottom: $ibo-panel--highlight--padding-bottom;
|
||||
}
|
||||
}
|
||||
|
||||
@each $sColor, $sColorValue in $ibo-panel-colors {
|
||||
.ibo-panel.ibo-is-#{$sColor} > .ibo-panel--body::before {
|
||||
background-color: $sColorValue;
|
||||
}
|
||||
}
|
||||
|
||||
.ibo-panel--collapsible-toggler {
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -392,7 +392,7 @@ try
|
||||
continue;
|
||||
}
|
||||
|
||||
$oAuditCategoryPanelBlock->SetColor($sClass);
|
||||
$oAuditCategoryPanelBlock->SetColorFromSemantic($sClass);
|
||||
$oAuditCategoryPanelBlock->AddCSSClass('ibo-audit--audit-category--panel');
|
||||
$aData = [];
|
||||
foreach($aResults as $aRow)
|
||||
|
||||
@@ -2262,14 +2262,14 @@ EOF
|
||||
if ($sElementType === self::ENUM_STYLE_HOST_ELEMENT_TYPE_CLASS) {
|
||||
$sMainColorForOrm = $this->GetPropString($oNode, 'main_color', null);
|
||||
if (is_null($sMainColorForOrm)) {
|
||||
// TODO 3.0.0: Should check for main color in parent classes definition
|
||||
// TODO: Check for main color in parent classes definition is currently done in MetaModel::GetClassStyle() at runtime but it should be done here at compile time
|
||||
$sMainColorForOrm = "null";
|
||||
}
|
||||
$sMainColorForCss = $this->GetPropString($oNode, 'main_color', null, false);
|
||||
|
||||
$sComplementaryColorForOrm = $this->GetPropString($oNode, 'complementary_color', null);
|
||||
if (is_null($sComplementaryColorForOrm)) {
|
||||
// TODO 3.0.0: Should check for complementary color in parent classes definition
|
||||
// TODO: Check for main color in parent classes definition is currently done in MetaModel::GetClassStyle() at runtime but it should be done here at compile time
|
||||
$sComplementaryColorForOrm = "null";
|
||||
}
|
||||
$sComplementaryColorForCss = $this->GetPropString($oNode, 'complementary_color', null, false);
|
||||
|
||||
@@ -126,8 +126,8 @@ class Panel extends UIContentBlock
|
||||
protected $sIconCoverMethod;
|
||||
/** @var bool Whether the icon should be rendered as a medallion (rounded with border) or a standalone image */
|
||||
protected $bIconAsMedallion;
|
||||
/** @var string $sColor */
|
||||
protected $sColor;
|
||||
/** @var string $sCSSColorClass CSS class that will be used on the block to define its accent color */
|
||||
protected $sCSSColorClass;
|
||||
/** @var bool $bIsCollapsible */
|
||||
protected $bIsCollapsible;
|
||||
/** @var bool $bIsHeaderVisibleOnScroll True if the header of the panel should remain visible when scrolling */
|
||||
@@ -138,10 +138,10 @@ class Panel extends UIContentBlock
|
||||
*
|
||||
* @param string $sTitle
|
||||
* @param \Combodo\iTop\Application\UI\Base\iUIBlock[] $aSubBlocks
|
||||
* @param string $sColor
|
||||
* @param string $sSemanticColor $sSemanticColor Semantic color code such as "success", "failure", "active", ... {@see css/backoffice/components/_panel.scss}
|
||||
* @param string|null $sId
|
||||
*/
|
||||
public function __construct(string $sTitle = '', array $aSubBlocks = [], string $sColor = self::DEFAULT_COLOR, ?string $sId = null)
|
||||
public function __construct(string $sTitle = '', array $aSubBlocks = [], string $sSemanticColor = self::DEFAULT_COLOR, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
|
||||
@@ -156,7 +156,7 @@ class Panel extends UIContentBlock
|
||||
$this->sIconUrl = static::DEFAULT_ICON_URL;
|
||||
$this->sIconCoverMethod = static::DEFAULT_ICON_COVER_METHOD;
|
||||
$this->bIconAsMedallion = static::DEFAULT_ICON_AS_MEDALLION;
|
||||
$this->sColor = $sColor;
|
||||
$this->SetColorFromSemantic($sSemanticColor);
|
||||
$this->SetMainBlocks([]);
|
||||
$this->SetToolBlocks([]);
|
||||
$this->bIsCollapsible = false;
|
||||
@@ -387,21 +387,36 @@ class Panel extends UIContentBlock
|
||||
}
|
||||
|
||||
/**
|
||||
* @see static::$sCSSColorClass
|
||||
* @return string
|
||||
*/
|
||||
public function GetColor()
|
||||
public function GetCSSColorClass()
|
||||
{
|
||||
return $this->sColor;
|
||||
return $this->sCSSColorClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sColor
|
||||
* @param string $sCSSColorClass
|
||||
*
|
||||
* @see static::$sCSSColorClass
|
||||
* @return $this
|
||||
*/
|
||||
public function SetColor(string $sColor)
|
||||
public function SetCSSColorClass(string $sCSSColorClass)
|
||||
{
|
||||
$this->sColor = $sColor;
|
||||
$this->sCSSColorClass = $sCSSColorClass;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sSemanticColor
|
||||
*
|
||||
* @see static::$sCSSColorClass
|
||||
* @return $this
|
||||
*/
|
||||
public function SetColorFromSemantic(string $sSemanticColor)
|
||||
{
|
||||
$this->SetCSSColorClass("ibo-is-$sSemanticColor");
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -414,12 +429,16 @@ class Panel extends UIContentBlock
|
||||
*
|
||||
* @param \ormStyle $oStyle
|
||||
*
|
||||
* @see static::$sCSSColorClass
|
||||
* @return $this
|
||||
*/
|
||||
public function SetColorFromOrmStyle(ormStyle $oStyle)
|
||||
{
|
||||
$sColor = empty($oStyle->GetMainColor()) ? static::DEFAULT_COLOR : $oStyle->GetMainColor();
|
||||
$this->SetColor($sColor);
|
||||
if (strlen($oStyle->GetStyleClass()) === 0) {
|
||||
$this->SetColorFromSemantic(static::DEFAULT_COLOR);
|
||||
} else {
|
||||
$this->SetCSSColorClass($oStyle->GetStyleClass());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -432,13 +451,14 @@ class Panel extends UIContentBlock
|
||||
*
|
||||
* @param string $sClass
|
||||
*
|
||||
* @see static::$sCSSColorClass
|
||||
* @return $this
|
||||
*/
|
||||
public function SetColorFromClass(string $sClass)
|
||||
{
|
||||
$oStyle = MetaModel::GetClassStyle($sClass);
|
||||
if (empty($oStyle)) {
|
||||
$this->SetColor(static::DEFAULT_COLOR_FOR_CLASS);
|
||||
$this->SetColorFromSemantic(static::DEFAULT_COLOR_FOR_CLASS);
|
||||
} else {
|
||||
$this->SetColorFromOrmStyle($oStyle);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class PanelUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (!is_null($sSubTitle)) {
|
||||
$oPanel->SetSubTitle($sSubTitle);
|
||||
}
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_NEUTRAL);
|
||||
$oPanel->SetColorFromSemantic(Panel::ENUM_COLOR_NEUTRAL);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class PanelUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (!is_null($sSubTitle)) {
|
||||
$oPanel->SetSubTitle($sSubTitle);
|
||||
}
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_INFORMATION);
|
||||
$oPanel->SetColorFromSemantic(Panel::ENUM_COLOR_INFORMATION);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class PanelUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (!is_null($sSubTitle)) {
|
||||
$oPanel->SetSubTitle($sSubTitle);
|
||||
}
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_SUCCESS);
|
||||
$oPanel->SetColorFromSemantic(Panel::ENUM_COLOR_SUCCESS);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class PanelUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (!is_null($sSubTitle)) {
|
||||
$oPanel->SetSubTitle($sSubTitle);
|
||||
}
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_WARNING);
|
||||
$oPanel->SetColorFromSemantic(Panel::ENUM_COLOR_WARNING);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class PanelUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (!is_null($sSubTitle)) {
|
||||
$oPanel->SetSubTitle($sSubTitle);
|
||||
}
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_DANGER);
|
||||
$oPanel->SetColorFromSemantic(Panel::ENUM_COLOR_DANGER);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ class PanelUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (!is_null($sSubTitle)) {
|
||||
$oPanel->SetSubTitle($sSubTitle);
|
||||
}
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_FAILURE);
|
||||
$oPanel->SetColorFromSemantic(Panel::ENUM_COLOR_FAILURE);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class PanelUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (!is_null($sSubTitle)) {
|
||||
$oPanel->SetSubTitle($sSubTitle);
|
||||
}
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_PRIMARY);
|
||||
$oPanel->SetColorFromSemantic(Panel::ENUM_COLOR_PRIMARY);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ class PanelUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (!is_null($sSubTitle)) {
|
||||
$oPanel->SetSubTitle($sSubTitle);
|
||||
}
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_SECONDARY);
|
||||
$oPanel->SetColorFromSemantic(Panel::ENUM_COLOR_SECONDARY);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
{% apply spaceless %}
|
||||
<div id="{{ oUIBlock.GetId() }}"
|
||||
class="ibo-panel ibo-is-{{ oUIBlock.GetColor() }} {{ oUIBlock.GetBlocksInheritanceCSSClassesAsString() }} {{ oUIBlock.GetAdditionalCSSClassesAsString() }} {% if oUIBlock.HasIcon() %}ibo-has-icon{% endif %} {% if oUIBlock.IsIconAsMedallion() %}ibo-has-medallion-icon{% endif %} {% if oUIBlock.IsHidden() %}ibo-is-hidden{% endif %} ibo-is-opened"
|
||||
class="ibo-panel {{ oUIBlock.GetCSSColorClass() }} {{ oUIBlock.GetBlocksInheritanceCSSClassesAsString() }} {{ oUIBlock.GetAdditionalCSSClassesAsString() }} {% if oUIBlock.HasIcon() %}ibo-has-icon{% endif %} {% if oUIBlock.IsIconAsMedallion() %}ibo-has-medallion-icon{% endif %} {% if oUIBlock.IsHidden() %}ibo-is-hidden{% endif %} ibo-is-opened"
|
||||
{% block iboPanelMetaData %}{% endblock %}
|
||||
data-role="ibo-panel">
|
||||
<div class="ibo-panel--header" data-role="ibo-panel--header">
|
||||
|
||||
Reference in New Issue
Block a user