-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat(file): Added download attributes. - OEL-2772 #573
Conversation
🚀 Deployed on https://preview-573--oelibrary.netlify.app |
[skip chromatic]
[skip chromatic]
{% if _download is not empty and _download.icon is not empty %} | ||
{% set _download = _download|merge({ | ||
icon: _download.icon | ||
}) %} | ||
{% else %} | ||
{% set _download = _download|merge({ | ||
icon: { | ||
name: "download", | ||
size: "fluid", | ||
path: _icon_path, | ||
}, | ||
}) %} | ||
{% endif %} | ||
{% if _download.attributes is empty %} | ||
{% set _download = _download|merge({ | ||
attributes: create_attribute() | ||
}) %} | ||
{% endif %} |
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.
{% if _download is not empty and _download.icon is not empty %} | |
{% set _download = _download|merge({ | |
icon: _download.icon | |
}) %} | |
{% else %} | |
{% set _download = _download|merge({ | |
icon: { | |
name: "download", | |
size: "fluid", | |
path: _icon_path, | |
}, | |
}) %} | |
{% endif %} | |
{% if _download.attributes is empty %} | |
{% set _download = _download|merge({ | |
attributes: create_attribute() | |
}) %} | |
{% endif %} | |
{% set _download = _download|merge({ | |
icon: _download.icon|default({}|merge({ | |
name: "download", | |
size: "fluid", | |
path: _icon_path, | |
}), | |
attributes: _download.attributes|default(create_attribute())|merge({ | |
download: true, | |
target: _blank, | |
}) | |
}) %} |
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.
Maybe I am missing something but what we are trying to do is nested array merges. With the above, we set into icon the value that it already has, defaulted to an empty object in case it's not there, and then merged with the default icon settings.
For attributes we do the same: if it was passed down in _download.attributes we use it, otherwise we default to a clean one. Then we merge, not set, the values.
attributes: _download.attributes | ||
.setAttribute('download', true) | ||
.setAttribute('target', '_blank') | ||
.addClass(['standalone', 'align-self-center', 'd-inline-block', 'mt-1', 'mt-md-0', 'flex-shrink-0']) |
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.
attributes: _download.attributes | |
.setAttribute('download', true) | |
.setAttribute('target', '_blank') | |
.addClass(['standalone', 'align-self-center', 'd-inline-block', 'mt-1', 'mt-md-0', 'flex-shrink-0']) | |
attributes: _download.attributes | |
.addClass(['standalone', 'align-self-center', 'd-inline-block', 'mt-1', 'mt-md-0', 'flex-shrink-0']) |
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.
It was failing like this, it's more or less how you suggested now but without the attributes merge.
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.
Hello misters,
Why not keeping my original logic #583 ?
- Set the BCL default attributes
- Merge with possible provided child that can eventually remove/update/add attributes
For example, in your case you are forcing the download=true
, I do not need it sometimes
See : https://historia.europa.eu/en/about-us/press (icon changed + attributes changed)
path: "/example.html", | ||
icon: { | ||
name: "cloud-download", | ||
size: "fluid", |
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 wish we could test this with a different icon set :) But it's ok.
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.
In the test you can see that it's not populated... I could add but we have only that sprite :)) and i think it's enough that it's not populated if you dont add it (that means you can change it how you want).
[skip chromatic]
[skip chromatic]
No description provided.