Skip to content
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

IBX-3085: As a Developer, I want to have thumbnail twig component #478

Merged
merged 3 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/bundle/Resources/public/scss/_header-user-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@
font-size: $ibexa-text-font-size-small;
}

&__image {
width: calculateRem(24px);
height: calculateRem(24px);
border-radius: 50%;
cursor: pointer;
}

&__toggler {
display: flex;
align-items: center;
Expand All @@ -47,7 +40,7 @@
}
}

&__thumbnail {
&__thumbnail-wrapper {
display: flex;
border: calculateRem(3px) solid $ibexa-color-black;
border-radius: 50%;
Expand Down
7 changes: 7 additions & 0 deletions src/bundle/Resources/public/scss/_user-thumbnail.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.ibexa-user-thumbnail {
&--img {
width: calculateRem(24px);
height: calculateRem(24px);
border-radius: 50%;
}
}
1 change: 1 addition & 0 deletions src/bundle/Resources/public/scss/ibexa.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@
@import 'back-to-top';
@import 'date-time-picker';
@import 'middle-ellipsis';
@import 'user-thumbnail';
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{% import "@ibexadesign/ui/component/macros.html.twig" as html %}

{% trans_default_domain 'adaptive_filters' %}

{% set attr = attr|default({})|merge({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% import "@ibexadesign/ui/component/macros.html.twig" as html %}

{% set user_image = user_content.thumbnail %}

{% if user_image.mimeType == 'image/svg+xml' %}
{% set attr_svg = attr_svg|default({})|merge({
class: ('ibexa-user-thumbnail--svg ' ~ attr_svg.class|default(''))|trim,
width: attr_svg.width is defined ? attr_svg.width : '24',
height: attr_svg.height is defined ? attr_svg.height : '24',
xmlns: attr_svg.xmlns is defined ? attr_svg.xmlns : 'http://www.w3.org/2000/svg',
}) %}

<svg {{ html.attributes(attr_svg|default({})) }}>
<use xlink:href="{{ user_image.resource }}"></use>
</svg>
{% else %}
{% set attr_img = attr_img|default({})|merge({
class: ('ibexa-user-thumbnail--img ' ~ attr_img.class|default(''))|trim,
src: attr_img.src is defined ? attr_img.src : user_image.resource,
alt: attr_img.alt is defined ? attr_img.alt : user.name,
}) %}

<img {{ html.attributes(attr_img|default({})) }}/>
{% endif %}
16 changes: 4 additions & 12 deletions src/bundle/Resources/views/themes/admin/ui/menu/user.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@
<span class="ibexa-header-user-menu__notice-dot ibexa-header-user-menu__notice-dot--no-notice"></span>
</div>
<button class="ibexa-header-user-menu__toggler">
<div class="ibexa-header-user-menu__thumbnail">
{% if user_image.mimeType == "image/svg+xml" %}
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
<use xlink:href="{{ user_image.resource }}"></use>
</svg>
{% else %}
<img
class="ibexa-header-user-menu__image"
src="{{ user_image.resource }}"
alt="{{ user.name }}"
/>
{% endif %}
<div class="ibexa-header-user-menu__thumbnail-wrapper">
{% include '@ibexadesign/ui/component/user_thumbnail/user_thumbnail.html.twig' with {
user_content: user.content,
} %}
</div>
</button>

Expand Down