Skip to content

Commit

Permalink
MOar
Browse files Browse the repository at this point in the history
  • Loading branch information
powerbuoy committed Feb 27, 2024
1 parent d96b050 commit c3e965b
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 5 deletions.
44 changes: 42 additions & 2 deletions components/color-scheme/styles.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
<?php return function ($args = []) {
<?php return function ($moduleName, $args = []) {
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', [
'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'
]]]
]
]
]
];
Expand Down
7 changes: 7 additions & 0 deletions components/color-scheme/template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$args = array_merge([
'styles' => null
], $args);
?>

<pre><?php var_dump($args) ?></pre>
6 changes: 4 additions & 2 deletions components/media/fields.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php return function ($moduleName, $args = []) {
$config = array_merge([
'module_name' => null,
'ratio' => true
'ratio' => true,
'additional_fields' => []
], $args);

# Main media file
Expand Down Expand Up @@ -46,6 +46,8 @@
]));
}

$fields = array_merge($fields, $config['additional_fields']);

return [
[
'name' => 'media',
Expand Down
5 changes: 5 additions & 0 deletions inc/module-class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php function sleek_module_class ($styles) {
$classes[] = 'section';

return implode(' ', $classes);
}
1 change: 1 addition & 0 deletions modules/invise-example-module/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function content_fields () {

public function style_fields () {
return [
...(include get_stylesheet_directory() . '/components/color-scheme/styles.php')($this->snakeName),
...(include get_stylesheet_directory() . '/components/module-header/styles.php')(),
...(include get_stylesheet_directory() . '/components/links/styles.php')()
];
Expand Down
6 changes: 5 additions & 1 deletion modules/invise-example-module/template.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<section id="invise-example-module">
<section id="invise-example-module" class="<?php echo sleek_module_class($styles) ?>">

<?php get_template_part('components/color-scheme/template', null, [
'styles' => $styles['color_scheme']
]) ?>

<?php get_template_part('components/module-header/template', null, [
'module_header' => $module_header,
Expand Down

0 comments on commit c3e965b

Please sign in to comment.