Skip to content

Commit

Permalink
Move searhc into site title.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Jun 7, 2022
1 parent 67ec93c commit e6094c5
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 278 deletions.
35 changes: 18 additions & 17 deletions source/wp-content/themes/wporg-developer/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
echo do_blocks( '<!-- wp:wporg/global-header /-->' );

$show_search = DevHub\should_show_search_bar();
$is_handbook = $GLOBALS['wp_query']->is_handbook;
$show_filters = ! ( $is_handbook || is_404() );
$show_full_search = is_front_page() || is_page('reference') || is_search();

?>

<header id="masthead" class="site-header<?php if ( is_front_page() ) { echo ' home'; } ?>" role="banner">
<header id="masthead" class="site-header<?php if ( $show_full_search ) { echo ' home'; } ?>" role="banner">
<?php if ( function_exists( 'wporg_is_handbook' ) && wporg_is_handbook() && ! is_search() ) : ?>
<a href="#" id="secondary-toggle" onclick="return false;"><strong><?php _e( 'Menu', 'wporg' ); ?></strong></a>
<?php endif; ?>
Expand All @@ -24,24 +27,22 @@
</h1>

<?php if ( is_front_page() ) : ?>
<p class="site-description"><?php _e( 'The freedom to build.', 'wporg' ); ?></p>
<p class="site-description"><?php _e( 'The freedom to build.', 'wporg' ); ?></p>
<?php else: ?>
<?php get_search_form( array( 'show_filters' => $show_full_search ) ); ?>
<?php endif; ?>

<?php if ( $show_search ) : ?>
<div class="site-breadcrumb">
<?php get_search_form( array( 'showFilters' => false ) ); ?>
</div>
<?php else: ?>
<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle dashicons dashicons-arrow-down-alt2" aria-controls="primary-menu" aria-expanded="false" aria-label="<?php esc_attr_e( 'Primary Menu', 'wporg' ); ?>"></button>
<?php
$active_menu = is_post_type_archive( 'command' ) || is_singular( 'command' ) ? 'devhub-cli-menu' : 'devhub-menu';
wp_nav_menu( array(
'theme_location' => $active_menu,
'container_class' => 'menu-container',
'container_id' => 'primary-menu',
) ); ?>
</nav>
<?php if( ! $show_search ): ?>
<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle dashicons dashicons-arrow-down-alt2" aria-controls="primary-menu" aria-expanded="false" aria-label="<?php esc_attr_e( 'Primary Menu', 'wporg' ); ?>"></button>
<?php
$active_menu = is_post_type_archive( 'command' ) || is_singular( 'command' ) ? 'devhub-cli-menu' : 'devhub-menu';
wp_nav_menu( array(
'theme_location' => $active_menu,
'container_class' => 'menu-container',
'container_id' => 'primary-menu',
) ); ?>
</nav>
<?php endif; ?>
</div>
</header><!-- #masthead -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@

<main id="main" class="site-main" role="main">
<div class="reference-landing">
<div class="search-guide section clear">
<h4 class="ref-intro"><?php _e( 'Want to know what&#39;s going on inside WordPress? Search the Code Reference for more information about WordPress&#39; functions, classes, methods, and hooks.', 'wporg' ); ?></h4>
<h3 class="search-intro"><?php _e( 'Try it out:', 'wporg' ); ?></h3>
<?php get_search_form(); ?>
</div><!-- /search-guide -->

<div class="topic-guide section">
<h4><?php _e( 'Or browse through topics:', 'wporg' ); ?></h4>
<h4><?php _e( 'Browse through topics:', 'wporg' ); ?></h4>
<ul class="unordered-list horizontal-list no-bullets">
<li><a href="<?php echo get_post_type_archive_link( 'wp-parser-function' ) ?>"><?php _e( 'Functions', 'wporg' ); ?></a></li>
<li><a href="<?php echo get_post_type_archive_link( 'wp-parser-hook' ) ?>"><?php _e( 'Hooks', 'wporg' ); ?></a></li>
Expand Down
190 changes: 91 additions & 99 deletions source/wp-content/themes/wporg-developer/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -785,95 +785,13 @@
}
}

.searchform {
overflow: hidden;
height: auto;
position: relative;

input[type="text"] {
border-radius: 0;
margin: 0 auto;
padding: 0.5em;
width: 100%;
}

.button-search {
background: transparent;
border: none;
border-radius: 0;
box-shadow: none;
color: #32373c;
display: block;
height: 40px;
padding: 0.5rem 1rem;
position: absolute;
right: 0;
top: 0;
text-shadow: none;
}

label {
width: 56rem;
max-width: 100%;
margin-right: 15px;
display: inline-block;
float: left;

.search-field input[type="text"] {
width: 100%;
}
}

div {
overflow: auto;
}

.search-post-type {
margin-top: 1em;

label {
border-right: 1px solid #ccc;
float: none;
width: inherit;
margin-left: 1em;
margin-right: 0;
padding-left: 0;
padding-right: 1.3em;

input {
margin-bottom: 6px;
padding-left: 0.5em;
vertical-align: middle;
}
}

label:last-child {
border-right-width: 0;
}

@media ( max-width: 688px ) {
span {
display: block;
}

label {
margin-left: 0;
margin-right: 1em;
width: 130px;

&:last-child {
margin-right: 0;
padding-right: 0;
width: initial;
}
}
}
}
}

.search-results-summary {
font-style: italic;
margin-bottom: 1em;
padding: 2rem;
background: get-color(gray-2);
border-radius: 2px;
font-size: 14px;
}

.reference-landing .section,
Expand Down Expand Up @@ -2652,19 +2570,6 @@ body.responsive-show {
padding: 0 4rem;
}

.reference-landing .searchform {
text-align: center;
}

.reference-landing .searchform input[type="text"],
.reference-landing .searchform input[type="submit"] {
width: 100%;
margin-right: 0;
margin-bottom: 1em;
float: none;
clear: both;
}

.wp-parser-class,
.wp-parser-function,
.wp-parser-hook,
Expand Down Expand Up @@ -2954,3 +2859,90 @@ button.code-tab.is-active {
.code-tab-block.is-active {
display: block;
}

.search-wrap {
.searchform {
display: flex;
align-items: center;
flex-direction: column;
position: relative;
background: get-color(white);
border-radius: 2px;
margin: 3rem auto 0;


input[type="search"] {
flex-grow: 1;
margin: 0;
padding: 1rem 4rem 1rem 1rem;
border: 1px solid transparent;
border-radius: 2px;
box-shadow: none;
font-size: 13px;
width: 100%;
}

.search-field {
display: flex;
position: relative;
width: 100%;
max-width: 400px;
}

.button-search {
display: flex;
position: absolute;
right: 0;
background: transparent;
border: 1px solid transparent;
border-radius: 2px;
height: 40px;
align-items: center;

&:active {
background: get-color(gray-5);
}
}

.search-post-type {
margin-top: 1em;
color: $color-white;

label {
border-right: 1px solid #ccc;
float: none;
width: inherit;
margin-left: 1em;
margin-right: 0;
padding-left: 0;
padding-right: 1.3em;
}

label:last-child {
border-right-width: 0;
}

@media ( max-width: 688px ) {
span {
display: block;
}

label {
margin-left: 0;
margin-right: 1em;
width: 130px;

&:last-child {
margin-right: 0;
padding-right: 0;
width: initial;
}
}
}
}
}

&.search-wrap-inline .searchform {
margin-top: 0;
}
}
25 changes: 23 additions & 2 deletions source/wp-content/themes/wporg-developer/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,31 @@
<span class="trail-end"><?php echo esc_html( get_search_query() ); ?></span>
</div>

<?php get_search_form(); ?>

<main id="main" class="site-main" role="main">


<div class="search-results-summary"><?php
$count = (int) $GLOBALS['wp_query']->found_posts;

if ( $count ) {
if ( is_paged() ) {
$start = get_query_var( 'posts_per_page' ) * ( get_query_var( 'paged' ) - 1 );
} else {
$start = 0;
}
$end = min( $count, $start + get_query_var( 'posts_per_page' ) );
printf(
_n( '<strong>%d</strong> result found for "<strong>%s</strong>".', '<strong>%d</strong> results found for "<strong>%s</strong>". Showing results %d to %d.', $count, 'wporg' ),
$count,
esc_html( get_search_query() ),
$start + 1,
$end
);
} else {
printf( __( '<strong>%d</strong> results found for "<strong>%s</strong>".', 'wporg' ), $count, esc_html( get_search_query() ) );
}
?></div>

<?php if ( have_posts() ) : ?>

<?php /* Start the Loop */ ?>
Expand Down
Loading

0 comments on commit e6094c5

Please sign in to comment.