Skip to content

Commit

Permalink
fix issue with aside borders set to none
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitlinbolling committed Jun 21, 2024
1 parent 6b0b159 commit 41fef68
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 20 deletions.
8 changes: 8 additions & 0 deletions assets/js/theme-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
$( '#pullquote_border_color, #pullquote_border_width' ).parent().show().next( 'br' ).show();
}
} ).change();

$( '#aside_border_style' ).on( 'change', function () {
if ( 'none' === $( this ).val() ) {
$( '#aside_border_color, #aside_border_width' ).parent().hide().next( 'br' ).hide();
} else {
$( '#aside_border_color, #aside_border_width' ).parent().show().next( 'br' ).show();
}
} ).change();
}

function appleNewsThemeEditSortInit( activeSelector, activeKey, inactiveSelector, inactiveKey, connectWith ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/apple-exporter/class-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -2524,8 +2524,8 @@ private function initialize_groups() {
'settings' => [
'aside_alignment',
'aside_background_color',
'aside_border_color',
'aside_border_style',
'aside_border_color',
'aside_border_width',
'aside_padding',
'dark_mode_colors_heading',
Expand Down
83 changes: 64 additions & 19 deletions includes/apple-exporter/components/class-aside.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,59 @@ public function register_specs() {
],
);

$aside_conditional_style = [];
if ( ! empty( $theme->get_value( 'aside_background_color_dark' ) ) || ! empty( $theme->get_value( 'aside_border_color_dark' ) ) ) {
$aside_conditional_style = [
'conditional' => [
'backgroundColor' => '#aside_background_color_dark#',
'border' => [
'all' => [
'width' => '#blockquote_border_width#',
'style' => '#blockquote_border_style#',
'color' => '#aside_border_color_dark#',
],
],
'conditions' => [
'minSpecVersion' => '1.14',
'preferredColorScheme' => 'dark',
$aside_conditional_background_style = [];
if ( ! empty( $theme->get_value( 'aside_background_color_dark' ) ) ) {
$aside_conditional_background_style = [
'backgroundColor' => '#aside_background_color_dark#',
];
}

$aside_conditional_border_style = [];
if ( ! empty( $theme->get_value( 'aside_border_color_dark' ) ) ) {
$aside_conditional_border_style = [
'border' => [
'all' => [
'width' => '#aside_border_width#',
'style' => '#aside_border_style#',
'color' => '#aside_border_color_dark#',
],
],
];
}

$aside_conditional_conditions = [
'conditions' => [
'minSpecVersion' => '1.14',
'preferredColorScheme' => 'dark',
],
];

$aside_conditional_style_with_borders = ( ! empty( $aside_conditional_background_style ) || ! empty( $aside_conditional_border_style ) )
? [
'conditional' => [
array_merge(
$aside_conditional_background_style,
$aside_conditional_border_style,
$aside_conditional_conditions,
),
]
]
: [];

$aside_conditional_style_without_borders = ( ! empty( $aside_conditional_background_style ) || ! empty( $aside_conditional_border_style ) )
? [
'conditional' => [
array_merge(
$aside_conditional_background_style,
$aside_conditional_conditions,
),
]
]
: [];

$this->register_spec(
'default-aside',
__( 'Aside Style', 'apple-news' ),
'aside-with-border-json',
__( 'Aside With Border JSON', 'apple-news' ),
array_merge(
[
'backgroundColor' => '#aside_background_color#',
Expand All @@ -118,7 +148,18 @@ public function register_specs() {
],
],
],
$aside_conditional_style
$aside_conditional_style_with_borders
)
);

$this->register_spec(
'aside-without-border-json',
__( 'Aside Without Border JSON', 'apple-news' ),
array_merge(
[
'backgroundColor' => '#aside_background_color#',
],
$aside_conditional_style_without_borders
)
);

Expand Down Expand Up @@ -178,9 +219,13 @@ protected function build( $html ) {
],
);

$component_style = ( 'none' !== $theme->get_value( 'aside_border_style' ) )
? 'aside-with-border-json'
: 'aside-without-border-json';

$this->register_component_style(
'default-aside',
'default-aside',
$component_style,
);

$alignment = $theme->get_value( 'aside_alignment' );
Expand Down

0 comments on commit 41fef68

Please sign in to comment.