Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Prepare better Customizer Color support & many adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ouun committed May 28, 2020
1 parent cc2db4c commit e7f3851
Show file tree
Hide file tree
Showing 53 changed files with 414 additions and 779 deletions.
4 changes: 2 additions & 2 deletions app/Customizer/Customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ function () {
new WebsitePanel(); // HIDES AND MOVES CONTROLS!
new SettingsPanel();
new WebsiteFeatures();
new ColorsPanel();
new GlobalPanel();
new HeaderPanel();
new ArchivesPanel();
// new FooterPanel();
new FooterPanel();
new ColorsPanel();
},
100
);
Expand Down
7 changes: 4 additions & 3 deletions app/Customizer/Panels/ColorsPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ public function registerColors($section, $args)
*/
foreach (Settings::getDefault('global.colors.palettes') as $palette => $shades) {
foreach ($shades as $shade => $color) {
$key = $palette . '-' . $shade;
$key = $palette;
$key .= $shade !== 'default' ? '-' . $shade : '';

new ReactColor(
[
Expand All @@ -252,9 +253,9 @@ public function registerColors($section, $args)
'settings' => $section . '_colors_' . $palette . '[' . $shade . ']',
'section' => $section . '_colors',
'choices' => array(
'formComponent' => 'TwitterPicker',
'formComponent' => 'ChromePicker',
),
'default' => $color,
'default' => stage_get_default("global.colors.palettes.$palette.$shade"),
'input_attrs' => $section != 'global' ? [
'data-sync-master' => 'global_colors_' . $palette . '[' . $shade . ']',
] : [],
Expand Down
88 changes: 11 additions & 77 deletions app/Customizer/Panels/FooterPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Kirki\Compatibility\Kirki;
use Kirki\Panel;
use Kirki\Section;
use Stage\Customizer\Customizer;

use function Stage\stage_get_default;
use function Stage\stage_get_fallback;
Expand Down Expand Up @@ -53,86 +54,19 @@ public function __construct()
public function colors()
{
// Set section & settings ID
$section = self::$panel . '_colors';
$section = self::$panel . '_colors';

/**
* Add Section and fields for Header Style
* Add Section and fields for Colors
*/
new Section(
$section,
array(
'title' => esc_attr__('Colors', 'stage'),
'panel' => self::$panel,
'priority' => 20,
)
);
Customizer::addSection($section, array(
'title' => esc_html__('Colors', 'stage'),
'description' => esc_html__('Set color settings for your website', 'stage'),
'priority' => 60,
'panel' => self::$panel,
));

Kirki::add_field(
self::$config,
array(
'type' => 'multicolor',
'settings' => $section,
'label' => esc_attr__('Footer Colors', 'stage'),
'section' => $section,
'transport' => 'auto',
'choices' => array(
'footer_bg' => esc_attr__('Background Color', 'stage'),
'footer_item' => esc_attr__('Text Color', 'stage'),
'footer_item_hover' => esc_attr__('Item Hover & Active', 'stage'),
),
'default' => array(
'footer_bg' => '',
'footer_item' => '',
'footer_item_hover' => '',
),
'alpha' => true,
'input_attrs' => array(
'footer_bg' => array(
'data-sync-master' => 'global_colors_main[body]',
),
'footer_item' => array(
'data-sync-master' => 'global_colors_main[copy]',
),
'footer_item_hover' => array(
'data-sync-master' => 'global_colors_main[primary]',
),
),
'output' => array(
array(
'choice' => 'footer_bg',
'element' => 'footer.footer-wrap',
'property' => '--color-body',
'context' => array(
'front',
),
),
array(
'choice' => 'footer_copy',
'element' => 'footer.footer-wrap',
'property' => '--color-copy',
'context' => array(
'front',
),
),
array(
'choice' => 'footer_copy',
'element' => 'footer.footer-wrap',
'property' => '--color-link',
'context' => array(
'front',
),
),
array(
'choice' => 'footer_item_hover',
'element' => 'header.main-header',
'property' => '--color-hover',
'context' => array(
'front',
),
),
),
)
);
// Fields are calculated from ColorsPanel.php
}

public function settings()
Expand All @@ -154,7 +88,7 @@ public function settings()
)
);

Kirki::add_field(
Customizer::addField(
self::$config,
array(
'type' => 'text',
Expand Down
126 changes: 1 addition & 125 deletions app/Customizer/Panels/GlobalPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ public function colors()
{
// Set section & settings ID
$section = self::$panel . '_colors';
$default_key = 'global.colors.';

/**
* Add Section and fields for Colors
Expand All @@ -254,129 +253,6 @@ public function colors()
'panel' => self::$panel,
));

/**
* Main colors
*/
Customizer::addField(
array(
'type' => 'multicolor',
'label' => esc_html__('Main Colors', 'stage'),
'settings' => $section . '_main',
'section' => $section,
'priority' => 10,
'choices' => array(
'copy' => esc_html__('Default Text Color', 'stage'),
'heading' => esc_html__('Default Heading Color', 'stage'),
'primary' => esc_html__('Primary Color', 'stage'),
'secondary' => esc_html__('Secondary Color', 'stage'),
'body' => esc_html__('Default Background Color', 'stage'),
),
'default' => array(
'copy' => stage_get_default($default_key . 'main.copy'),
'heading' => stage_get_default($default_key . 'main.copy'),
'primary' => stage_get_default($default_key . 'main.primary'),
'secondary' => stage_get_default($default_key . 'main.secondary'),
'body' => stage_get_default($default_key . 'main.body'),
),
'transport' => 'auto',
'output' => array(
array(
'choice' => 'copy',
'element' => ':root',
'property' => '--color-copy',
'context' => array(
'editor',
'front',
),
),
array(
'choice' => 'heading',
'element' => ':root',
'property' => '--color-heading',
'context' => array(
'editor',
'front',
),
),
array(
'choice' => 'primary',
'element' => ':root',
'property' => '--color-primary',
'context' => array(
'editor',
'front',
),
),
array(
'choice' => 'secondary',
'element' => ':root',
'property' => '--color-secondary',
'context' => array(
'editor',
'front',
),
),
array(
'choice' => 'body',
'element' => ':root',
'property' => '--color-body',
'context' => array(
'editor',
'front',
),
),
),
)
);

/**
* Link Colors
*/
Customizer::addField(
array(
'type' => 'multicolor',
'label' => esc_html__('Link Colors', 'stage'),
'settings' => $section . '_links',
'section' => $section,
'priority' => 20,
'choices' => array(
'link' => esc_html__('Link Color', 'stage'),
'hover' => esc_html__('Hover & Focus Color', 'stage'),
),
'default' => array(
'link' => '',
'hover' => '',
),
'input_attrs' => array(
'link' => array(
'data-sync-master' => 'global_colors_main[copy]',
),
'hover' => array(
'data-sync-master' => 'global_colors_main[primary]',
),
),
'transport' => 'auto',
'output' => array(
array(
'choice' => 'link',
'element' => ':root',
'property' => '--color-link',
'context' => array(
'editor',
'front',
),
),
array(
'choice' => 'hover',
'element' => ':root',
'property' => '--color-hover',
'context' => array(
'editor',
'front',
),
),
),
)
);
// Fields are calculated from ColorsPanel.php
}
}
59 changes: 0 additions & 59 deletions app/Customizer/Panels/HeaderPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,64 +426,5 @@ public function colors()
'priority' => 20,
)
);

Kirki::add_field(
self::$config,
array(
'type' => 'multicolor',
'settings' => $section,
'label' => esc_attr__('Main Menu', 'stage'),
'section' => $section,
'transport' => 'auto',
'choices' => array(
'menu_bg' => esc_attr__('Background Color', 'stage'),
'menu_item' => esc_attr__('Menu Item Color', 'stage'),
'menu_item_hover' => esc_attr__('Item Hover & Active', 'stage'),
),
'default' => array(
'menu_bg' => '',
'menu_item' => '',
'menu_item_hover' => '',
),
'alpha' => true,
'input_attrs' => array(
'menu_bg' => array(
'data-sync-master' => 'global_colors_main[body]',
),
'menu_item' => array(
'data-sync-master' => 'global_colors_main[copy]',
),
'menu_item_hover' => array(
'data-sync-master' => 'global_colors_main[primary]',
),
),
'output' => array(
array(
'choice' => 'menu_bg',
'element' => 'header.main-header',
'property' => '--color-body',
'context' => array(
'front',
),
),
array(
'choice' => 'menu_item',
'element' => 'header.main-header',
'property' => '--color-copy',
'context' => array(
'front',
),
),
array(
'choice' => 'menu_item_hover',
'element' => 'header.main-header',
'property' => '--color-hover',
'context' => array(
'front',
),
),
),
)
);
}
}
2 changes: 1 addition & 1 deletion app/Providers/ShopFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function ($link_text, $product_data) {
'',
$link_text
);
$link_text .= '<span class="flex text-xs uppercase text-gray-500">' .
$link_text .= '<span class="flex text-xs uppercase text-gray">' .
wc_get_formatted_variation($product_data['variation'], false) .
'</span>';
}
Expand Down
Loading

0 comments on commit e7f3851

Please sign in to comment.