Skip to content

Introduce Callout#358

Open
TheSyscall wants to merge 7 commits intomainfrom
callouts
Open

Introduce Callout#358
TheSyscall wants to merge 7 commits intomainfrom
callouts

Conversation

@TheSyscall
Copy link
Copy Markdown

@TheSyscall TheSyscall commented Mar 13, 2026

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 FormDescription and FormNotification decorators, 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:
image

Callout full width:
image

Callout with optional title:
image

Callout above a form element:
image

closes #349

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.
@TheSyscall TheSyscall self-assigned this Mar 13, 2026
@TheSyscall TheSyscall added the enhancement New feature or request label Mar 13, 2026
@cla-bot cla-bot Bot added the cla/signed label Mar 13, 2026
Comment thread src/Widget/Callout.php Outdated
Comment thread src/Widget/Callout.php Outdated
@flourish86
Copy link
Copy Markdown
Contributor

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.
This is usually done by setting a max width of ~50em to the element containing the paragraph.

@TheSyscall Would be nice, if you could post a screenshot of the element positioned on top of the page.

@TheSyscall
Copy link
Copy Markdown
Author

On the top of a configuration form without any limit. (limited only by the content)
image

Limited to 80ch/50em.
image

Setting the limit like that breaks the use over form elements.
Note the large blank space on the right side of the callout.
image

flourish86
flourish86 previously approved these changes Mar 24, 2026
Copy link
Copy Markdown
Contributor

@flourish86 flourish86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread asset/css/callout.less Outdated
Comment thread src/Common/CalloutType.php Outdated
Comment thread src/Common/CalloutType.php Outdated
Comment thread src/Widget/Callout.php Outdated
Comment thread src/Widget/Callout.php Outdated
@TheSyscall TheSyscall requested a review from Al2Klimov March 24, 2026 12:08
@Al2Klimov Al2Klimov mentioned this pull request Mar 24, 2026
Copy link
Copy Markdown
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested together with Icinga/icingaweb2#5477 (review).

@Al2Klimov Al2Klimov requested a review from flourish86 March 31, 2026 10:01
@jrauh01
Copy link
Copy Markdown
Contributor

jrauh01 commented May 6, 2026

Would love to see this feature soon, so I don't have to create an own callout widget for Icinga/icingaweb2#5430.

@lippserd lippserd requested a review from jrauh01 May 6, 2026 08:31
Copy link
Copy Markdown
Contributor

@jrauh01 jrauh01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the different kinds and types and think it looks great. First, please rebase.

Comment thread src/Widget/Callout.php
$this->addAttributes(Attributes::create(['class' => $type->value]));
}

public function assemble(): void
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be protected.

Suggested change
public function assemble(): void
protected function assemble(): void

Comment thread src/Widget/Callout.php
if ($isFormElement) {
$this->addAttributes(Attributes::create(['class' => 'form-callout']));
} else {
$this->removeAttribute('class', 'from-callout');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->removeAttribute('class', 'from-callout');
$this->removeAttribute('class', 'form-callout');

Comment thread src/Widget/Callout.php
Comment on lines +13 to +19
/**
* 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
Copy link
Copy Markdown
Contributor

@jrauh01 jrauh01 May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Widget/Callout.php
Comment on lines +58 to +66
/**
* 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a short description without a full stop in the first line of the docs block.

Comment thread src/Widget/Callout.php
Comment on lines +77 to +85
/**
* 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a short description without a full stop in the first line of the docs block.

Comment thread src/Widget/Callout.php
public function setFormElement(bool $isFormElement = true): static
{
if ($isFormElement) {
$this->addAttributes(Attributes::create(['class' => 'form-callout']));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Widget/Callout.php
Comment on lines +30 to +32
* @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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first letter of each param doc should be uppercase.

Comment thread src/Widget/Callout.php
* 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
Copy link
Copy Markdown
Contributor

@jrauh01 jrauh01 May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First letter should be uppercase.

Suggested change
* @param bool $fullwidth should the callout be fullwidth
* @param bool $fullwidth Should the callout be fullwidth

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be changed to

Suggested change
* @param bool $fullwidth should the callout be fullwidth
* @param bool $fullwidth Whether the callout should be full width

Comment thread src/Widget/Callout.php
* 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
Copy link
Copy Markdown
Contributor

@jrauh01 jrauh01 May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First letter should be uppercase.

Suggested change
* @param bool $isFormElement should the callout be used for a form element
* @param bool $isFormElement Should the callout be used for a form element

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be changed to

Suggested change
* @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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better form hints

5 participants