-
Notifications
You must be signed in to change notification settings - Fork 12
UCPKN-3880: Pass attributes to modal and toast sections. #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6a5ccbb
UCPKN-3879: Allow passing attributes to modal header, body and footer.
kp77 70fce48
UCPKN-3880: Allow passing attributes to toast elements, add custom co…
kp77 b982b7d
UCPKN-3880: Add test for toast without close button.
kp77 2dafe73
UCPKN-3880: Avoid overriding toast close button aria-label attribute.
kp77 d0eb1aa
Merge branch 'development' into UCPKN-3880
tibi2303 71addc9
UCPKN-3880: Updated tests.
tibi2303 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,11 @@ | |
- toasts (object[]) format: [ | ||
{ | ||
- body (string) (default: '') | ||
- body_attributes (drupal attrs) | ||
- header (string) (default: '') | ||
- header_attributes (drupal attrs) | ||
- button_attributes (drupal attrs) | ||
- custom_content (string) (default: '') | ||
- role (string) (default: 'alert') | ||
- with_close (boolean) (default: true) | ||
- autohide (boolean) (default: false) | ||
|
@@ -66,6 +71,9 @@ | |
{% set _with_body_wrapper = _toast.with_body_wrapper ?? false %} | ||
{% set _body_wrapper_classes = _toast.body_wrapper_classes|default('') %} | ||
{% set _toast_attributes = _toast.attributes ?: create_attribute() %} | ||
{% set _body_attributes = _toast.body_attributes ?: create_attribute() %} | ||
{% set _header_attributes = _toast.header_attributes ?: create_attribute() %} | ||
{% set _button_attributes = _toast.button_attributes ?: create_attribute() %} | ||
{% set _toast_attributes = _toast_attributes.addClass(_classes).setAttribute('aria-atomic', 'true') %} | ||
{% if _aria_live is not empty %} | ||
{% set _toast_attributes = _toast_attributes.setAttribute('aria-live', _aria_live) %} | ||
|
@@ -82,16 +90,16 @@ | |
{% if _with_close or | ||
(_toast.header is defined and _toast.header is not empty) | ||
%} | ||
<div class="toast-header"> | ||
<div{{ _header_attributes.addClass(['toast-header']) }}> | ||
{{- _toast.header|default('') -}} | ||
{% if _with_close %} | ||
{% set button_attributes = create_attribute() | ||
.addClass(['btn-close']) | ||
.setAttribute('aria-label', 'close') | ||
.setAttribute('data-bs-dismiss', 'toast') | ||
%} | ||
{% if not _button_attributes.hasAttribute('aria-label') %} | ||
{% set _button_attributes = _button_attributes.setAttribute('aria-label', 'Close') %} | ||
{% endif %} | ||
{%- include '@oe-bcl/bcl-button/button.html.twig' with { | ||
attributes: button_attributes, | ||
attributes: _button_attributes | ||
.addClass(['btn-close']) | ||
.setAttribute('data-bs-dismiss', 'toast'), | ||
clean_class: true | ||
} only -%} | ||
{% endif %} | ||
|
@@ -104,12 +112,13 @@ | |
{% endif %} | ||
> | ||
{% endif %} | ||
<div class="toast-body"> | ||
<div{{ _body_attributes.addClass(['toast-body']) }}> | ||
{{- _body -}} | ||
</div> | ||
{% if _with_body_wrapper %} | ||
</div> | ||
{% endif %} | ||
{{- _toast.custom_content|default('') -}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
</div> | ||
{% endfor %} | ||
{% endif %} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we didnt approach correctly these toasts in the first version and now with your changes, it becomes even more complex.. I think we can simplify it but I need to think of the impact
I dont like: _body_wrapper_classes _with_body_wrapper parameters and by removing them we would have a more simple template. We can leave it like this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was also wondering about the body wrapper (there's no mention of that in the Bootstrap docs).