From 6f457ee46ec7c32c19ed158973454b4ff45ca42a Mon Sep 17 00:00:00 2001 From: DiegoAndresCortes Date: Sat, 10 Aug 2024 20:51:31 +0000 Subject: [PATCH] Update Theme-Customs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Diego Andrés --- languages/ThemeCustoms/main.english.php | 5 ++--- scripts/custom/variants.js | 2 +- themecustoms/Color/DarkMode.php | 7 +++---- themecustoms/Color/Variants.php | 16 +++++++++------- themecustoms/Theme/Integration.php | 6 +++--- themecustoms/Theme/Load.php | 6 +++--- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/languages/ThemeCustoms/main.english.php b/languages/ThemeCustoms/main.english.php index a17ca7c..d380fc7 100644 --- a/languages/ThemeCustoms/main.english.php +++ b/languages/ThemeCustoms/main.english.php @@ -235,10 +235,9 @@ $txt['st_site_color_desc'] = 'Indicates a suggested color that user agents (browser) should use to customize the display of the page or of the surrounding user interface. Default is #567c8f'; // Color Variants +$txt['st_default_variant_desc'] = 'If the user selection is disabled, this will be the default and locked mode. Admins can still change their preference.
This does not affect the default values for the users, for that you can use the Member Options section.'; $txt['st_color'] = 'Color Settings'; $txt['st_color_variants'] = 'Theme Color Variants'; -$txt['st_color_variants_javascript'] = 'Use JavaScript to change the color'; -$txt['st_color_variants_javascript_desc'] = 'This will change the variant of the theme using JavaScript and auto-update for the profile.'; $txt['variant_pick'] = 'Select Color Variant'; $txt['variant_default'] = 'Default'; $txt['variant_red'] = 'Red'; @@ -257,7 +256,7 @@ $txt['st_theme_mode'] = 'Theme Mode'; $txt['st_theme_mode_select'] = 'Select Theme Mode'; $txt['st_theme_mode_default'] = 'Default Theme Mode'; -$txt['st_theme_mode_default_desc'] = 'If user selection is disabled, this will be the default and locked mode. Admins can still change their preference.'; +$txt['st_theme_mode_default_desc'] = 'If user selection is disabled, this will be the default and locked mode. Admins can still change their preference.
This does not affect the default values for the users, for that you can use the Member Options section.'; $txt['st_enable_mode_selection'] = 'Enable user mode selection'; $txt['st_dark_mode'] = 'Dark Mode'; $txt['st_light_mode'] = 'Light Mode'; diff --git a/scripts/custom/variants.js b/scripts/custom/variants.js index 5b95942..cb630a6 100644 --- a/scripts/custom/variants.js +++ b/scripts/custom/variants.js @@ -9,7 +9,7 @@ let localVariant = localStorage.getItem('st_theme_variant'); let toggleVariant = document.querySelectorAll('.theme-variant-toggle'); if (!smf_member_id && localVariant !== null) { - document.documentElement.dataset.mode = localVariant; + document.documentElement.dataset.variant = localVariant; } function switchVariant(variant) { diff --git a/themecustoms/Color/DarkMode.php b/themecustoms/Color/DarkMode.php index 4e32770..3a94ab3 100644 --- a/themecustoms/Color/DarkMode.php +++ b/themecustoms/Color/DarkMode.php @@ -47,7 +47,7 @@ private function init() : void $this->selection(); // No need to load if the setting is disabled and default mode is light - if (!empty($context['theme_can_change_mode']) || $settings['st_theme_mode_default'] !== 'light') { + if (!empty($context['theme_can_change_mode']) || (!empty($settings['st_theme_mode_default']) && $settings['st_theme_mode_default'] !== 'light')) { // Load the css $this->css(); @@ -115,7 +115,7 @@ private function css() global $settings, $context; // Add the HTML data attribute for color mode - $settings['themecustoms_html_attributes']['data']['mode'] = 'data-mode="' . $context['theme_colormode'] . '"'; + $settings['themecustoms_html']['attributes'][] = 'data-mode="' . $context['theme_colormode'] . '"'; // Load the dark CSS loadCSSFile('custom/dark.css', ['order_pos' => $this->order, 'attributes' => (isset($context['theme_colormode']) && $context['theme_colormode'] == 'system' ? ['media' => '(prefers-color-scheme: dark)'] : [])], 'smf_darkmode'); @@ -143,7 +143,7 @@ public function sceditor(array &$sce_options) : void { global $context, $settings; - $sce_options['style'] = $sce_options['style'] . '"/> $this->order], 'smf_variants'); @@ -159,9 +159,9 @@ public function sceditor(array &$sce_options) : void global $context, $settings; // Check if the file exists - $variantStyle = file_exists($settings['theme_dir'] . '/css/custom/index_' . $context['theme_variant'] . '.css') ? '' : ''; + $variantStyle = file_exists($settings['theme_dir'] . '/css/custom/index_' . $context['theme_variant'] . '.css') ? '' : ''; - $sce_options['style'] = $sce_options['style'] . '"/>' . $variantStyle . '' . $variantStyle . '', + 'description' => $txt['st_default_variant_desc'] . '

', 'options' => $this->selectVariants, 'type' => 'list', - 'default' => $settings['theme_colorvariants'][0], 'theme_type' => 'color', ], [ diff --git a/themecustoms/Theme/Integration.php b/themecustoms/Theme/Integration.php index 58c90f5..ea11790 100644 --- a/themecustoms/Theme/Integration.php +++ b/themecustoms/Theme/Integration.php @@ -254,14 +254,14 @@ public function buffer(string $buffer) : string } /** - * Add the global data attributes + * Add the global html attributes */ public function htmlAttributes() : void { global $settings, $context; - // Data attributes - $settings['themecustoms_html_attributes_data'] = (!empty($settings['themecustoms_html_attributes']['data']) && is_array($settings['themecustoms_html_attributes']['data']) ? ' ' . implode(' ', $settings['themecustoms_html_attributes']['data']) : ''); + // HTML Attributes + $settings['themecustoms_html_attributes'] = (!empty($settings['themecustoms_html']['attributes']) && is_array($settings['themecustoms_html']['attributes']) ? ' ' . implode(' ', $settings['themecustoms_html']['attributes']) : ''); // Disable the info center? if (isset($settings['st_disable_info_center']) && !empty($settings['st_disable_info_center']) && !empty($context['info_center'])) diff --git a/themecustoms/Theme/Load.php b/themecustoms/Theme/Load.php index f1d5484..a4ca9f8 100644 --- a/themecustoms/Theme/Load.php +++ b/themecustoms/Theme/Load.php @@ -223,7 +223,7 @@ private function css() : void [ 'attributes' => $options['css']['attributes'] ?? [], 'external' => $options['css']['external'] ?? false, - 'minimize' => $options['css']['minimize'] ?? false, + 'minimize' => $options['css']['minimize'] ?? true, 'order_pos' => $options['css']['order_pos'] ?? abs($this->order--), ], 'customtheme_' . $file @@ -241,7 +241,7 @@ private function css() : void (empty($options['default']) ? 'custom/' : '') . (!is_array($options) ? $options : $file) . '.css', [ 'attributes' => $options['attributes'] ?? [], - 'minimize' => $options['minimize'] ?? false, + 'minimize' => $options['minimize'] ?? true, 'order_pos' => $options['order_pos'] ?? abs($this->order--), ], 'customtheme_' . (!is_array($options) ? $options : $file) @@ -292,7 +292,7 @@ private function js() : void 'attributes' => $options['js']['attributes'] ?? [], 'defer' => $options['js']['defer'] ?? false, 'external' => $options['js']['external'] ?? false, - 'minimize' => $options['js']['minimize'] ?? false, + 'minimize' => $options['js']['minimize'] ?? true, ], 'customtheme_' . $file );