Skip to content
Snippets Groups Projects
Commit 1a4e85e2 authored by Florent Torregrosa's avatar Florent Torregrosa
Browse files

Issue #3506530 by grimreaper: Media Library Edit support

parent f3458320
Branches
Tags 5.1.0-alpha5
1 merge request!268Issue #3506530 by grimreaper: Media Library Edit support
Pipeline #429611 passed
/* Remove button of selected medias. */
button[name$="media-library-remove-button"] {
button.media-library-remove-button,
/* Edit button. */
a.media-library-edit__link {
position: absolute;
z-index: 1;
right: var(--bs-card-spacer-x);
margin: 0.25rem;
}
/* Edit button. */
a.media-library-edit__link {
top: 30px;
}
/* Remove button when creating a media. */
.media-added-remove-button {
position: absolute;
......
......@@ -13,12 +13,33 @@ use Drupal\ui_suite_bootstrap\Utility\Element;
class PreprocessMediaLibraryItem {
/**
* Add icons in media library view.
* Ensure the remove button is the first element.
*/
public const REMOVE_BUTTON_WEIGHT = -10;
/**
* Ensure the edit link is after the remove button.
*/
public const EDIT_LINK_WEIGHT = -5;
/**
* Add icons in media library item.
*
* @param array $variables
* The preprocessed variables.
*/
public function preprocess(array &$variables): void {
$this->preprocessRemoveButton($variables);
$this->preprocessEditLink($variables);
}
/**
* Add icon on remove button.
*
* @param array $variables
* The preprocessed variables.
*/
protected function preprocessRemoveButton(array &$variables): void {
if (!isset($variables['content']['remove_button'])) {
return;
}
......@@ -29,7 +50,35 @@ class PreprocessMediaLibraryItem {
'alt' => $element->getProperty('value'),
]));
$element->setProperty('icon_position', 'icon_only');
$element->addClass('btn-sm');
$element->addClass([
'btn-sm',
'media-library-remove-button',
]);
$element->setProperty('weight', static::REMOVE_BUTTON_WEIGHT);
}
/**
* Add icon and button style on edit link.
*
* @param array $variables
* The preprocessed variables.
*/
protected function preprocessEditLink(array &$variables): void {
if (!isset($variables['content']['media_edit'])) {
return;
}
$element = Element::create($variables['content']['media_edit']);
$element->setIcon(Bootstrap::icon('pencil-fill', 'bootstrap', [
'size' => '16px',
]));
$element->setProperty('icon_position', 'icon_only');
$element->addClass([
'btn',
'btn-sm',
'btn-success',
]);
$element->setProperty('weight', static::EDIT_LINK_WEIGHT);
}
}
......@@ -80,6 +80,10 @@ libraries-override:
commerce_checkout/form: false
commerce_checkout/login_pane: false
layout_builder_browser/browser: false
media_library_edit/admin:
css:
component:
css/media_library_edit.admin.css: false
paragraphs/drupal.paragraphs.unpublished: false
section_library/section_library:
css:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment