Issue# 3489112: Integrate responsive preview with Navigation top bar
Closes #3489112
Merge request reports
Activity
added 1 commit
- c98063ee - Issue# 3489112: Fixed phpstan and stylelint issues
added 1 commit
- fcc57964 - Issue# 3489112: Styling changes on Edit page
added 1 commit
- c1d054f4 - Issue# 3489112: Revert responsive preview module changes and created a submodule
- src/Plugin/TopBarItem/ResponsiveIcons.php 0 → 100644
changed this file in version 6 of the diff
166 166 ]; 167 167 } 168 168 169 // Add a configuration link. changed this line in version 6 of the diff
1 name: 'Responsive Preview Toolbar' changed this line in version 6 of the diff
1 <?php 2 3 /** 4 * Implements hook_theme(). 5 */ 6 function responsive_preview_toolbar_theme() { changed this line in version 6 of the diff
1 name: 'Responsive Preview Toolbar' 2 type: module 3 description: 'Provides a toolbar with responsive preview icons.' 4 core_version_requirement: ^10 || ^11 changed this line in version 6 of the diff
71 */ 72 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): static { 73 return new static( 74 $configuration, 75 $plugin_id, 76 $plugin_definition, 77 $container->get('responsive_preview'), 78 $container->get('current_user'), 79 ); 80 } 81 82 /** 83 * {@inheritdoc} 84 */ 85 public function build(): array { 86 try { changed this line in version 6 of the diff
80 } 81 82 /** 83 * {@inheritdoc} 84 */ 85 public function build(): array { 86 try { 87 // Check if the user has the required permission. 88 if (!$this->currentUser->hasPermission('access responsive preview')) { 89 return []; 90 } 91 92 $url = $this->responsivePreview->getPreviewUrl(); 93 94 // Add cache tags and contexts. 95 $cache_tags = ['config:node_type_list']; changed this line in version 6 of the diff
102 '#cache' => [ 103 'tags' => $cache_tags, 104 'contexts' => $cache_contexts, 105 ], 106 '#attached' => [ 107 'library' => [ 108 'responsive_preview/drupal.responsive-preview', 109 'responsive_preview_toolbar/drupal.responsive-preview-toolbar', 110 ], 111 'drupalSettings' => [ 112 'responsive_preview' => [ 113 'url' => ltrim($url, '/'), 114 ], 115 ], 116 ], 117 '#items' => [ changed this line in version 6 of the diff
139 '#attributes' => [ 140 'data-responsive-preview-name' => 'mobile', 141 'data-responsive-preview-width' => 768, 142 'data-responsive-preview-height' => 1280, 143 'data-responsive-preview-dppx' => 2, 144 'data-responsive-preview-orientation' => 'portrait', 145 'class' => [ 146 'responsive-preview-device', 147 'responsive-preview-icon', 148 'device-icon-mobile', 149 ], 150 ], 151 ], 152 ], 153 '#attributes' => [ 154 'id' => 'responsive-preview-toolbar-tab', The usage of the id attribute here could be problematic in the unlikely scenario where the plugin is shown more than once, or Navigation and Toolbar are being shown at the same time.
Would be great if we could get rid of explicit references to id attributes, but it would imply to modify the original module JS architecture.
I think this is a tradeoff we can live with for now, but needs to be confirmed.
changed this line in version 6 of the diff
74 $configuration, 75 $plugin_id, 76 $plugin_definition, 77 $container->get('responsive_preview'), 78 $container->get('current_user'), 79 ); 80 } 81 82 /** 83 * {@inheritdoc} 84 */ 85 public function build(): array { 86 try { 87 // Check if the user has the required permission. 88 if (!$this->currentUser->hasPermission('access responsive preview')) { 89 return []; changed this line in version 6 of the diff
@plopesc Do you mean to add like this
if (!$this->currentUser->hasPermission('access responsive preview')) { return [ '#cache' => [ 'contexts' => ['user.permissions'], ], ]; }
Edited by Roshni Upadhyay
100 '#theme' => 'responsive_preview_navigation', 101 '#cache' => [ 102 'contexts' => $cache_contexts, 103 ], 104 '#attached' => [ 105 'library' => [ 106 'responsive_preview/drupal.responsive-preview', 107 'responsive_preview_navigation/drupal.responsive-preview-navigation', 108 ], 109 'drupalSettings' => [ 110 'responsive_preview' => [ 111 'url' => ltrim($url, '/'), 112 ], 113 ], 114 ], 115 '#items' => [ @roshni-upadhyay Could we move the definition of these items to a separate method? That would help to increase code readability and make easier the edition of the items in the fture if needed.
changed this line in version 7 of the diff
added 1 commit
added 1 commit
added 1 commit