Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions newspack-theme/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$show_slideout_sidebar = get_theme_mod( 'header_show_slideout', false );
$slideout_sidebar_side = get_theme_mod( 'slideout_sidebar_side', 'left' );
$header_sub_simplified = get_theme_mod( 'header_sub_simplified', false );
$subpage_toggle_side = get_theme_mod( 'subpage_toggle_side', 'left' );
$header_sticky = get_theme_mod( 'header_sticky', false );

// Even if 'Show Slideout Sidebar' is checked, don't show it if no widgets are assigned.
Expand Down Expand Up @@ -60,7 +61,7 @@
<?php if ( true === $header_sub_simplified && ! is_front_page() ) : ?>
<div class="middle-header-contain">
<div class="wrapper">
<?php if ( newspack_has_menus() || true === $show_slideout_sidebar ) : ?>
<?php if ( ( newspack_has_menus() || true === $show_slideout_sidebar ) && 'left' === $subpage_toggle_side ) : ?>
<div class="subpage-toggle-contain">
<button class="subpage-toggle" on="tap:subpage-sidebar.toggle">
<?php echo wp_kses( newspack_get_icon_svg( 'menu', 20 ), newspack_sanitize_svgs() ); ?>
Expand All @@ -69,18 +70,33 @@
</div>
<?php endif; ?>

<?php if ( ( newspack_has_menus() || true === $show_slideout_sidebar ) && 'right' === $subpage_toggle_side && true === $header_center_logo ) : ?>
<div class="subpage-toggle-contain subpage-toggle-spacer" aria-hidden="true"></div>
<?php endif; ?>

<?php get_template_part( 'template-parts/header/site', 'branding' ); ?>

<?php newspack_mobile_cta(); ?>
<div class="subpage-right-wrapper">
<?php newspack_mobile_cta(); ?>

<?php if ( newspack_has_menus() ) : ?>
<button class="mobile-menu-toggle" on="tap:mobile-sidebar.toggle">
<?php echo wp_kses( newspack_get_icon_svg( 'menu', 20 ), newspack_sanitize_svgs() ); ?>
<span><?php esc_html_e( 'Menu', 'newspack-theme' ); ?></span>
</button>
<?php endif; ?>
<?php if ( newspack_has_menus() ) : ?>
<button class="mobile-menu-toggle" on="tap:mobile-sidebar.toggle">
<?php echo wp_kses( newspack_get_icon_svg( 'menu', 20 ), newspack_sanitize_svgs() ); ?>
<span><?php esc_html_e( 'Menu', 'newspack-theme' ); ?></span>
</button>
<?php endif; ?>

<?php get_template_part( 'template-parts/header/header', 'search' ); ?>
<?php get_template_part( 'template-parts/header/header', 'search' ); ?>

<?php if ( ( newspack_has_menus() || true === $show_slideout_sidebar ) && 'right' === $subpage_toggle_side ) : ?>
<div class="subpage-toggle-contain dir-right">
<button class="subpage-toggle" on="tap:subpage-sidebar.toggle">
<?php echo wp_kses( newspack_get_icon_svg( 'menu', 20 ), newspack_sanitize_svgs() ); ?>
<span class="screen-reader-text"><?php esc_html_e( 'Menu', 'newspack-theme' ); ?></span>
</button>
</div>
<?php endif; ?>
</div>
</div>
</div><!-- .wrapper -->
<?php else : ?>
Expand Down
21 changes: 21 additions & 0 deletions newspack-theme/inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,27 @@ function newspack_customize_register( $wp_customize ) {
)
);

// Subpage header - menu toggle position.
$wp_customize->add_setting(
'subpage_toggle_side',
array(
'default' => 'left',
'sanitize_callback' => 'newspack_sanitize_slideout_sidebar_side',
)
);
$wp_customize->add_control(
'subpage_toggle_side',
array(
'type' => 'radio',
'label' => esc_html__( 'Menu toggle position', 'newspack-theme' ),
'choices' => array(
'left' => _x( 'Left', 'menu toggle position', 'newspack-theme' ),
'right' => _x( 'Right', 'menu toggle position', 'newspack-theme' ),
),
'section' => 'header_section_subpages',
)
);

/**
* Header - Mobile Donate CTA
*/
Expand Down
13 changes: 12 additions & 1 deletion newspack-theme/js/src/customize-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
} );
} );

// Only show Alternative Logo option if 'simple subpage header' is picked
// Only show Alternative Logo and toggle side options if 'simple subpage header' is picked
wp.customize( 'header_sub_simplified', function ( setting ) {
wp.customize.control( 'newspack_alternative_logo', function ( control ) {
const visibility = function () {
Expand All @@ -350,6 +350,17 @@
visibility();
setting.bind( visibility );
} );
wp.customize.control( 'subpage_toggle_side', function ( control ) {
const visibility = function () {
if ( true === setting.get() ) {
control.container.slideDown( 180 );
} else {
control.container.slideUp( 180 );
}
};
visibility();
setting.bind( visibility );
} );
} );

// Only show Author Bio truncate options when enabled.
Expand Down
40 changes: 12 additions & 28 deletions newspack-theme/sass/navigation/_menu-mobile-navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@
margin: 0 #{1.25 * structure.$size__spacing-unit} 0 0;
}

.subpage-toggle-contain.dir-right {
margin: 0 0 0 #{0.75 * structure.$size__spacing-unit};
}

.subpage-toggle-contain.subpage-toggle-spacer {
visibility: hidden;
pointer-events: none;
}

.site-header .desktop-menu-toggle.dir-right {
margin: 0 0 0 #{1.25 * structure.$size__spacing-unit};
}
Expand Down Expand Up @@ -163,33 +172,6 @@
.site-branding {
margin-right: 0;
}

.mb-cta {
margin-left: auto;
}

.middle-header-contain .header-search-contain {
margin-left: 1.25rem;
}
}

&.h-cl {
@include utilities.media( tablet ) {
.wrapper {
position: relative;
}
.mb-cta {
right: 2.25rem;
position: absolute;
z-index: 1;
}

&:not(.h-stk).single-featured-image-beside {
.mb-cta {
right: 2.25rem;
}
}
}
}
}

Expand Down Expand Up @@ -418,13 +400,15 @@

// Fallback - open from the right
#mobile-sidebar-fallback,
#desktop-sidebar-fallback.dir-right {
#desktop-sidebar-fallback.dir-right,
#subpage-sidebar-fallback.dir-right {
left: auto;
right: -100%;
transition: right 0.2s;
}

.desktop-menu-opened #desktop-sidebar-fallback.dir-right,
.subpage-menu-opened #subpage-sidebar-fallback.dir-right,
.mobile-menu-opened #mobile-sidebar-fallback {
right: 0;
}
Expand Down
29 changes: 28 additions & 1 deletion newspack-theme/sass/site/header/_site-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,24 @@
}
}

.header-search-contain {
.subpage-right-wrapper {
align-items: center;
display: flex;
gap: #{0.75 * structure.$size__spacing-unit};
margin-left: auto;

.mb-cta,
.mobile-menu-toggle {
margin-left: 0;
}

.header-search-contain {
margin-left: 0;
}

> * {
flex: none;
}
}
}

Expand All @@ -474,6 +490,17 @@
text-align: right;
}
}

// Fix clumping when beside featured image constrains the wrapper to 50%.
&.single-featured-image-beside {
.site-header .middle-header-contain .wrapper {
justify-content: space-between;

> div {
flex: none;
}
}
}
}

&.h-ll {
Expand Down
6 changes: 4 additions & 2 deletions newspack-theme/template-parts/header/subpage-sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* @package Newspack
*/

$subpage_toggle_side = get_theme_mod( 'subpage_toggle_side', 'left' );

if ( newspack_is_amp() ) : ?>
<amp-sidebar id="subpage-sidebar" layout="nodisplay" side="left" class="subpage-sidebar">
<amp-sidebar id="subpage-sidebar" layout="nodisplay" side="<?php echo esc_attr( $subpage_toggle_side ); ?>" class="subpage-sidebar">
<button class="subpage-toggle" on='tap:subpage-sidebar.toggle'>
<?php echo wp_kses( newspack_get_icon_svg( 'close', 20 ), newspack_sanitize_svgs() ); ?>
<?php esc_html_e( 'Close', 'newspack-theme' ); ?>
</button>
<?php else : ?>
<aside id="subpage-sidebar-fallback" class="subpage-sidebar">
<aside id="subpage-sidebar-fallback" class="subpage-sidebar dir-<?php echo esc_attr( $subpage_toggle_side ); ?>">
<button class="subpage-toggle">
<?php echo wp_kses( newspack_get_icon_svg( 'close', 20 ), newspack_sanitize_svgs() ); ?>
<?php esc_html_e( 'Close', 'newspack-theme' ); ?>
Expand Down
Loading