Introduce Callout#358
Conversation
Implement a callout box element that can be used to convey important information to the user. This element is designed to be used above certain form elements, or over the whole form or page.
|
I like the design, especially the color matching border. The spacing of text and headline are well done. We should check, though, if there are elements, that have the same or a similar purpose and make sure that the design is consistent. Please make also sure, that the in this case the line breaks after max. 80 characters to ensure readability. @TheSyscall Would be nice, if you could post a screenshot of the element positioned on top of the page. |
Al2Klimov
left a comment
There was a problem hiding this comment.
Tested together with Icinga/icingaweb2#5477 (review).
|
Would love to see this feature soon, so I don't have to create an own callout widget for Icinga/icingaweb2#5430. |
| $this->addAttributes(Attributes::create(['class' => $type->value])); | ||
| } | ||
|
|
||
| public function assemble(): void |
There was a problem hiding this comment.
Should be protected.
| public function assemble(): void | |
| protected function assemble(): void |
| if ($isFormElement) { | ||
| $this->addAttributes(Attributes::create(['class' => 'form-callout'])); | ||
| } else { | ||
| $this->removeAttribute('class', 'from-callout'); |
There was a problem hiding this comment.
| $this->removeAttribute('class', 'from-callout'); | |
| $this->removeAttribute('class', 'form-callout'); |
| /** | ||
| * An information box that can be used to display information to the user. | ||
| * It consists of a set of standardized colors and icons that can be used to visually distinguish the type of | ||
| * information. | ||
| * A content string and an optional title can be passed to the constructor. | ||
| */ | ||
| class Callout extends BaseHtmlElement |
There was a problem hiding this comment.
The formatting looks a bit odd. Please adjust this so that the line lengths are more equal. The line does not need to end after a full stop.
| /** | ||
| * Callouts are only as wide as their content. | ||
| * Setting it to fullwidth will force the callout to be as wide as its container. | ||
| * | ||
| * @param bool $fullwidth should the callout be fullwidth | ||
| * | ||
| * @return $this | ||
| */ | ||
| public function setFullwidth(bool $fullwidth = true): static |
There was a problem hiding this comment.
Maybe add a short description without a full stop in the first line of the docs block.
| /** | ||
| * Setting this to true will allow the callout to be used for a single form element. | ||
| * This is used to visually align the callout to the content of the form element. | ||
| * | ||
| * @param bool $isFormElement should the callout be used for a form element | ||
| * | ||
| * @return $this | ||
| */ | ||
| public function setFormElement(bool $isFormElement = true): static |
There was a problem hiding this comment.
Maybe add a short description without a full stop in the first line of the docs block.
| public function setFormElement(bool $isFormElement = true): static | ||
| { | ||
| if ($isFormElement) { | ||
| $this->addAttributes(Attributes::create(['class' => 'form-callout'])); |
There was a problem hiding this comment.
All CSS classes use the callout-* pattern, while this one is *-callout. I understand the intention to indicate that it’s a different kind of callout. Maybe it could be named something like callout-form-element. Another option would be to rename callout-fullwidth to fullwidth-callout to keep things consistent.
| * @param CalloutType $type the type of the callout. The type determines the color and icon that is used. | ||
| * @param ValidHtml|string $content the content of the callout | ||
| * @param string|null $title an optional title, displayed above the content |
There was a problem hiding this comment.
The first letter of each param doc should be uppercase.
| * Callouts are only as wide as their content. | ||
| * Setting it to fullwidth will force the callout to be as wide as its container. | ||
| * | ||
| * @param bool $fullwidth should the callout be fullwidth |
There was a problem hiding this comment.
First letter should be uppercase.
| * @param bool $fullwidth should the callout be fullwidth | |
| * @param bool $fullwidth Should the callout be fullwidth |
There was a problem hiding this comment.
Maybe this could be changed to
| * @param bool $fullwidth should the callout be fullwidth | |
| * @param bool $fullwidth Whether the callout should be full width |
| * Setting this to true will allow the callout to be used for a single form element. | ||
| * This is used to visually align the callout to the content of the form element. | ||
| * | ||
| * @param bool $isFormElement should the callout be used for a form element |
There was a problem hiding this comment.
First letter should be uppercase.
| * @param bool $isFormElement should the callout be used for a form element | |
| * @param bool $isFormElement Should the callout be used for a form element |
There was a problem hiding this comment.
Maybe this could be changed to
| * @param bool $isFormElement should the callout be used for a form element | |
| * @param bool $isFormElement Whether the callout should be used for a form element |



Implement a callout box element that can be used to convey important information to the user.
This element is designed to be used above certain form elements, over the whole form or page.
It seems like the use of callout could conflict with the existing
FormDescriptionandFormNotificationdecorators, at least within IW2 forms.Callouts are not meant as a direct replacement for these decorators but as a more universal ipl widget that can be used even outside of forms to convey essential information to the user.
Merging these two concepts by extending the form-notification would be a viable alternative to this PR.
Callout types:

Callout full width:

Callout with optional title:

Callout above a form element:

closes #349