-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paththeme_breakpoints_js.module
More file actions
31 lines (25 loc) · 944 Bytes
/
theme_breakpoints_js.module
File metadata and controls
31 lines (25 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* @file
* Theme Breakpoints for Javascript module file.
*/
use Drupal\Component\Serialization\Json;
/**
* Implements hook_page_attachments().
*/
function theme_breakpoints_js_page_attachments(array &$page) {
$breakpoints = [];
/** @var \Drupal\theme_breakpoints_js\ThemeBreakpointsJs $theme_breakpoints_js */
$theme_breakpoints_js = \Drupal::service('theme_breakpoints_js');
/** @var \Drupal\breakpoint\BreakpointInterface[] $theme_breakpoints */
$theme_breakpoints = $theme_breakpoints_js->getBreakpointsForActiveTheme();
foreach ($theme_breakpoints as $name => $definition) {
$breakpoints[] = [
'name' => $name,
'mediaQuery' => $definition->getMediaQuery(),
'multipliers' => $definition->getMultipliers(),
];
}
$page['#attached']['drupalSettings']['theme_breakpoints'] = Json::encode($breakpoints);
$page['#attached']['library'][] = 'theme_breakpoints_js/breakpointsLoader';
}