-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathodd_admin.theme
More file actions
executable file
·63 lines (53 loc) · 1.68 KB
/
odd_admin.theme
File metadata and controls
executable file
·63 lines (53 loc) · 1.68 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @file
* Main theme file for the Odd Admin theme.
*/
require_once __DIR__ . '/includes/preprocess.inc';
require_once __DIR__ . '/includes/suggestions.inc';
/**
* Implements THEME_page_attachments_alter()
*/
function odd_admin_page_attachments_alter(&$page) {
// Get theme name
$theme_name = \Drupal::theme()->getActiveTheme()->getName();
// Get breakpoints from the theme
$breakpointManager = \Drupal::service('breakpoint.manager');
$breakpoints = $breakpointManager->getBreakpointsByGroup($theme_name);
// Attach the breakpoints to drupalSettings
$media_queries = array();
foreach ($breakpoints as $id => $breakpoint) {
$key = explode('.', $id)[1];
$media_queries[$key] = $breakpoint->getMediaQuery();
}
$page['#attached']['drupalSettings'][$theme_name]['breakpoints'] = $media_queries;
}
/**
* Implements THEME_library_info_alter()
*/
function odd_admin_library_info_alter(&$libraries, $extension) {
if ($extension === 'odd_admin') {
// Get performance configs
$performance = \Drupal::config('system.performance');
// Our replacement paths
$replacements = [
'js' => ['dist/bundle.js' => []],
'css' => [
'theme' => [
'dist/main.css' => [],
'dist/print.css' => ['media' => 'print'],
'node_modules/semantic-ui-css/semantic.css' => [],
],
],
];
// Replace minified files with normal when aggregation is false.
foreach ($replacements as $key => $replacement) {
if ($performance->get($key)['preprocess']) continue;
$libraries['global'][$key] = $replacement;
}
}
}
function odd_admin_element_info_alter(array &$types) {
// var_dump($types);
// die;
}