Skip to content

Commit cc81708

Browse files
authored
HappyBlocks: add 404 customizations (#107527)
* HappyBlocks: add 404 customizations * Improve translation strings
1 parent 73c7011 commit cc81708

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

apps/happy-blocks/block-library/search-card/index.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
$args = array();
1212
}
1313

14-
$is_front_page = isset( $args['is_front_page'] ) && ( true === $args['is_front_page'] );
15-
$active_page = isset( $args['active_page'] ) ? $args['active_page'] : '';
16-
17-
14+
$is_front_page = isset( $args['is_front_page'] ) && ( true === $args['is_front_page'] );
15+
$is_404_page = isset( $args['is_404_page'] ) && ( true === $args['is_404_page'] );
16+
$active_page = isset( $args['active_page'] ) ? $args['active_page'] : '';
17+
$should_show_search_card = ( $is_front_page || $is_404_page ) && 'forums' !== $active_page;
18+
$should_show_search_navigation = ! $is_front_page && ! $is_404_page;
1819

1920
if ( ! function_exists( 'get_support_search_link_for_query' ) ) {
2021
function get_support_search_link_for_query( $query ) {
@@ -30,7 +31,7 @@ function get_support_search_link_for_query( $query ) {
3031
}
3132

3233
?>
33-
<div class="happy-blocks-search-card<?php echo $is_front_page && 'forums' !== $active_page ? '' : ' navigation-only'; ?>">
34+
<div class="happy-blocks-search-card<?php echo $should_show_search_card ? '' : ' navigation-only'; ?>">
3435
<nav class="navigation-header">
3536
<!-- Desktop navigation -->
3637
<div class="desktop-nav-container">
@@ -44,7 +45,7 @@ function get_support_search_link_for_query( $query ) {
4445
</ul>
4546

4647
<!-- Search button -->
47-
<?php if ( ! $is_front_page ) : ?>
48+
<?php if ( $should_show_search_navigation ) : ?>
4849
<div class="happy-blocks_navigation_search">
4950
<a class="jetpack-search-filter__link" href="#">
5051
<svg xmlns="http://www.w3.org/2000/svg" class="search-icon" width="24" height="24" viewBox="0 0 24 24" fill="#1E1E1E">
@@ -98,7 +99,7 @@ function get_support_search_link_for_query( $query ) {
9899
</div>
99100

100101
<!-- Search button -->
101-
<?php if ( ! $is_front_page ) : ?>
102+
<?php if ( ! $should_show_search_navigation ) : ?>
102103
<div class="happy-blocks_navigation_search">
103104
<a class="jetpack-search-filter__link" href="#">
104105
<svg xmlns="http://www.w3.org/2000/svg" class="search-icon" width="24" height="24" viewBox="0 0 24 24" fill="#1E1E1E">
@@ -109,9 +110,19 @@ function get_support_search_link_for_query( $query ) {
109110
<?php endif; ?>
110111
</div>
111112
</nav>
112-
<?php if ( $is_front_page && 'forums' !== $active_page ) : ?>
113-
<div class="support-search-content">
114-
<h2><?php echo esc_html( __( 'How can we help you?', 'happy-blocks' ) ); ?></h2>
113+
<?php if ( $should_show_search_card ) : ?>
114+
<?php
115+
$content_classes = array_filter(
116+
array(
117+
'support-search-content',
118+
$is_front_page ? 'is-front-page' : '',
119+
$is_404_page ? 'is-404-page' : '',
120+
)
121+
);
122+
?>
123+
<div class="<?php echo esc_attr( implode( ' ', $content_classes ) ); ?>">
124+
<h2><?php echo esc_html( $is_404_page ? __( "This page doesn't exist", 'happy-blocks' ) : __( 'How can we help you?', 'happy-blocks' ) ); ?></h2>
125+
<?php echo $is_404_page ? '<p class="subheading">' . esc_html( __( "Let's help you find what you're looking for.", 'happy-blocks' ) ) . '</p>' : ''; ?>
115126
<form id="support-search-form" class="" role="search" method="get" action="">
116127
<div class="input-wrapper" dir="auto">
117128
<input id="support-search-input" type="search" name="s" placeholder="<?php echo esc_html( __( 'Search questions, guides, courses', 'happy-blocks' ) ); ?>"/>

apps/happy-blocks/block-library/search-card/style.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,25 @@ $breakpoint-desktop: 1440px; //Desktop size.
241241

242242
}
243243

244+
&.is-404-page {
245+
padding-bottom: 120px;
246+
247+
@media ( max-width: $breakpoint-mobile ) {
248+
padding-bottom: 52px;
249+
}
250+
251+
h2 {
252+
margin-bottom: 4px;
253+
}
254+
255+
.subheading {
256+
margin-top: 0;
257+
margin-bottom: 24px;
258+
color: #646970;
259+
line-height: 20px;
260+
}
261+
}
262+
244263
.input-wrapper {
245264
width: 570px;
246265
position: relative;

0 commit comments

Comments
 (0)