-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme-settings.php
More file actions
executable file
·67 lines (62 loc) · 3 KB
/
theme-settings.php
File metadata and controls
executable file
·67 lines (62 loc) · 3 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
64
65
66
67
<?php
/**
* @file
* Functions to support Webtheme theme settings.
*/
use Drupal\Core\Extension\ThemeSettingsProvider;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_FORM_ID_alter() for system_theme_settings.
*/
function webtheme_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) {
// ThemeSettingsProvider replaced the deprecated theme_get_setting() in
// Drupal 11.3. This file is loaded by the theme settings form independently
// of webtheme.theme, so call the service directly here.
$settings = \Drupal::service(ThemeSettingsProvider::class);
$form['webtheme_settings']['webtheme_utilities'] = [
'#type' => 'fieldset',
'#title' => t('Webtheme Utilities'),
];
$form['webtheme_settings']['webtheme_utilities']['mobile_menu_all_widths'] = [
'#type' => 'checkbox',
'#title' => t('Enable mobile menu at all widths'),
'#default_value' => $settings->getSetting('mobile_menu_all_widths'),
'#description' => t('Enables the mobile menu toggle at all widths.'),
];
$form['webtheme_settings']['webtheme_utilities']['site_branding_bg_color'] = [
'#type' => 'select',
'#title' => t('Header site branding background color'),
'#options' => [
'default' => t('Primary Branding Color'),
'gray' => t('Gray'),
'white' => t('White'),
],
'#default_value' => $settings->getSetting('site_branding_bg_color'),
];
$form['webtheme_settings']['webtheme_utilities']['debug'] = [
'#type' => 'checkbox',
'#title' => t('Enable Debug Options'),
'#default_value' => $settings->getSetting('debug', 'webtheme'),
'#description' => t('Enables a fixed debug block in the bottom corner of your screen.'),
];
$form['webtheme_settings']['webtheme_progressive'] = [
'#type' => 'fieldset',
'#title' => t('Progressive enhancement'),
'#description' => t('Webtheme ships zero jQuery and uses vanilla JavaScript. Enable HTMX below to get boosted navigation and partial-page swaps without writing extra JavaScript.'),
];
$form['webtheme_settings']['webtheme_progressive']['htmx_enabled'] = [
'#type' => 'checkbox',
'#title' => t('Enable HTMX'),
'#default_value' => $settings->getSetting('htmx_enabled') ?? 0,
'#description' => t('Attaches the <code>webtheme/htmx</code> library on every request. Drupal behaviors are automatically re-attached after each HTMX swap. See <a href="https://htmx.org" target="_blank" rel="noopener">htmx.org</a>.'),
];
$form['webtheme_settings']['webtheme_progressive']['htmx_boost'] = [
'#type' => 'checkbox',
'#title' => t('Boost all internal links and forms'),
'#default_value' => $settings->getSetting('htmx_boost') ?? 0,
'#description' => t('Adds <code>hx-boost="true"</code> to the <code><body></code> element so every internal link and form submits via HTMX, replacing only the page content instead of doing a full reload. Requires <em>Enable HTMX</em>.'),
'#states' => [
'visible' => [':input[name="htmx_enabled"]' => ['checked' => TRUE]],
],
];
}