Skip to content

Commit

Permalink
bg media config
Browse files Browse the repository at this point in the history
  • Loading branch information
powerbuoy committed Apr 26, 2024
1 parent c1b4beb commit 00be857
Showing 1 changed file with 80 additions and 42 deletions.
122 changes: 80 additions & 42 deletions components/color-scheme/styles.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,90 @@
<?php return function ($moduleName, $args = []) {
$config = array_merge([
'bg_colors' => true,
'bg_media' => true
], $args);

$bgMediaGroup = [];

# Background Media
if ($config['bg_media']) {
$bgMediaConfig = [
'required' => false,
'ratio' => false
];

if (is_array($config['bg_media'])) {
$bgMediaConfig = array_merge($bgMediaConfig, $config['bg_media']);
}

$bgMediaGroup = [
...(include get_stylesheet_directory() . '/components/media/fields.php')($moduleName . '_styles_color_scheme', [
'label' => __('Background Media', 'sleek_admin'),
'required' => $bgMediaConfig['required'],
'ratio' => $bgMediaConfig['ratio'],
'additional_fields' => [
[
'name' => 'light_media',
'label' => __('Light media', 'sleek_admin'),
'instructions' => __('Check this if the media is light. Dark text will then be used.', 'sleek_admin'),
'message' => __('Light media', 'sleek_admin'),
'type' => 'true_false',
'conditional_logic' => [[[
'field' => '{acf_key}_' . $moduleName . '_styles_color_scheme_media_media',
'operator' => '!=empty'
]]]
],
[
'name' => 'media_overlay',
'label' => __('Media overlay', 'sleek_admin'),
'instructions' => __('Check this to add an overlay to the media (if the media is light, the overlay will be light too).'),
'message' => __('Enable media overlay', 'sleek_admin'),
'type' => 'true_false',
'default_value' => true,
'conditional_logic' => [[[
'field' => '{acf_key}_' . $moduleName . '_styles_color_scheme_media_media',
'operator' => '!=empty'
]]]
]
]
])
];
}

# Background Colors
$bgColorsGroup = [];

if ($config['bg_colors']) {
$choices = is_array($config['bg_media']) ? $config['bg_media'] : [
'transparent' => __('Transparent', 'sleek_admin'),
'dark' => __('Dark', 'sleek_admin')
];

$bgColorsGroup = [
[
'name' => 'bg_color',
'label' => __('Background Color', 'sleek_admin'),
'type' => 'select',
'choices' => $choices,
'default_value' => 'transparent',
'conditional_logic' => [[[
'field' => '{acf_key}_' . $moduleName . '_styles_color_scheme_media_media',
'operator' => '==empty'
]]]
]
];

}

# Return group
return [
[
'name' => 'color_scheme',
'label' => __('Color scheme', 'sleek_admin'),
'type' => 'group',
'sub_fields' => [
...(include get_stylesheet_directory() . '/components/media/fields.php')($moduleName . '_styles_color_scheme', [
'ratio' => false,
'additional_fields' => [
[
'name' => 'light_media',
'label' => __('Light media', 'sleek_admin'),
'instructions' => __('Check this if the media is light. Dark text will then be used.', 'sleek_admin'),
'message' => __('Light media', 'sleek_admin'),
'type' => 'true_false',
'conditional_logic' => [[[
'field' => '{acf_key}_' . $moduleName . '_styles_color_scheme_media_media',
'operator' => '!=empty'
]]]
],
[
'name' => 'media_overlay',
'label' => __('Media overlay', 'sleek_admin'),
'instructions' => __('Check this to add an overlay to the media (if the media is light, the overlay will be light too).'),
'message' => __('Enable media overlay', 'sleek_admin'),
'type' => 'true_false',
'default_value' => true,
'conditional_logic' => [[[
'field' => '{acf_key}_' . $moduleName . '_styles_color_scheme_media_media',
'operator' => '!=empty'
]]]
]
]
]),
[
'name' => 'bg_color',
'label' => __('Background color'),
'type' => 'select',
'choices' => [
'transparent' => __('Transparent', 'sleek_admin'),
'dark' => __('Dark', 'sleek_admin')
],
'default_value' => 'transparent',
'conditional_logic' => [[[
'field' => '{acf_key}_' . $moduleName . '_styles_color_scheme_media_media',
'operator' => '==empty'
]]]
]
...$bgMediaGroup,
...$bgColorsGroup
]
]
];
Expand Down

0 comments on commit 00be857

Please sign in to comment.