Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header template #74

Merged
merged 3 commits into from
Dec 18, 2023
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions client-mu-plugins/goodbids/src/classes/Network/Sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function __construct() {

// New Site Actions
$this->activate_child_theme_on_new_site();
$this->default_child_theme_logo();
}

/**
Expand Down Expand Up @@ -393,4 +394,30 @@ private function init_site_defaults( int $site_id ): void {

restore_current_blog();
}

/**
* Set the GoodBids logo on the child theme.
*
* @since 1.0.0
*
* @return void
*/
private function default_child_theme_logo(): void {
add_filter(
'get_custom_logo',
function ( string $html, int $blog_id ) {
if ( $html ) {
return $html;
}

return sprintf(
'<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url"><img src="%2$s" class="custom-logo" itemprop="logo" alt="GoodBids"></a>',
esc_url( home_url( '/' ) ),
esc_attr( GOODBIDS_PLUGIN_URL . 'assets/images/goodbids-logo.png' ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is totally fine, however, what are your thoughts about retrieving the URL (or Markup) of the Main site custom_logo and rendering that here? So if they upload a new logo to the Main site, this will inherit that new logo without requiring a change to the plugin or repo. If you look into it, be sure to do an is_main_site() check otherwise you could end up in an infinite loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a great idea. I am going to keep it as is for now, but will make a note of it.

);
},
10,
2
);
}
}
32 changes: 32 additions & 0 deletions themes/goodbids-nonprofit/assets/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,35 @@
background-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--contrast-4);
}

/*TODO move this all to Tailwind once we set that up*/
.wp-button-custom > a {
background-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--base-2);
font-size: var(--wp--preset--font-size--x-small);
font-weight: 500;
text-decoration: none;
border-color: var(--wp--preset--color--contrast);
border-radius: 100px;
border-width: 0;
padding-top: 0.8rem;
padding-right: 1.5rem;
padding-left: 1.5rem;
padding-bottom: 0.8rem;

&:hover {
background-color: var(--wp--preset--color--contrast-4);
border-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--contrast);
}

&:focus {
background-color: var(--wp--preset--color--contrast-4);
border-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--contrast);
outline-color: var(--wp--preset--color--contrast);
outline-offset: 2px;
outline-style: dotted;
outline-width: 1px;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Planning on moving this all to tailwind.

10 changes: 9 additions & 1 deletion themes/goodbids-nonprofit/inc/patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ function () {
'init',
function () {
$patterns = [
[
'name' => 'header-nonprofit',
'file' => 'patterns/header-nonprofit.php',
'title' => __( 'GoodBids Header', 'goodbids-nonprofit' ),
'categories' => [ 'header', 'goodbids-np' ],
'keywords' => [ 'header', 'non-profit', 'template' ],
'blockTypes' => [ 'core/template-part/header' ],
'source' => 'theme',
],
[
'name' => 'footer-nonprofit',
'file' => 'patterns/footer-nonprofit.php',
'title' => __( 'GoodBids Footer', 'goodbids-nonprofit' ),
'categories' => [ 'footer', 'goodbids-np' ],
'blockTypes' => [ 'core/template-part/footer' ],
'source' => 'theme',
],
[
'name' => 'template-home-nonprofit',
Expand Down
24 changes: 1 addition & 23 deletions themes/goodbids-nonprofit/parts/header.html
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
<!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"top":"20px","bottom":"20px"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group alignwide has-background"
style="padding-top:20px;padding-bottom:20px">
<!-- wp:group {"align":"wide","layout":{"type":"flex","justifyContent":"space-between","flexWrap":"wrap"}} -->
<div class="wp-block-group alignwide">
<!-- wp:group {"style":{"spacing":{"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}},"layout":{"type":"flex"}} -->
<div class="wp-block-group">
<!-- wp:site-logo {"width":60 } /-->

<!-- wp:group {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-group">
<!-- wp:site-title {"level":0} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->

<!-- wp:navigation {"layout":{"type":"flex","justifyContent":"right","orientation":"horizontal"},"style":{"spacing":{"margin":{"top":"0"},"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}}} /-->

<!-- wp:loginout /--></div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
<!-- wp:pattern {"slug":"goodbids-np/header-nonprofit"} /-->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to a pattern, so if we need to use PHP we can.

37 changes: 37 additions & 0 deletions themes/goodbids-nonprofit/patterns/header-nonprofit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"top":"20px","bottom":"20px"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group alignwide has-background"
style="padding-top:20px;padding-bottom:20px">
<!-- wp:group {"align":"wide","layout":{"type":"flex","justifyContent":"space-between","flexWrap":"wrap"}} -->
<div class="wp-block-group alignwide">
<!-- wp:group {"style":{"spacing":{"blockGap":"0.2rem"},"layout":{"selfStretch":"fit","flexSize":null}},"layout":{"type":"flex"}} -->
<div class="wp-block-group">

<!-- wp:site-logo {"width":160,"shouldSyncIcon":true,"style":{"spacing":{"margin":{"top":"0","bottom":"0","left":"0","right":"0.5rem"}}}} /-->

<!-- wp:group {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-group">
<!-- wp:paragraph {"style":{"layout":{"selfStretch":"fixed","flexSize":"25px"}},"fontSize":"x-small"} -->
<p class="has-x-small-font-size"><?php esc_html_e( 'for', 'goodbids-nonprofit' ); ?></p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->

<!-- wp:group {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-group">
<!-- wp:site-title {"level":0,"fontSize":"x-small"} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->

<!-- wp:group {"style":{"spacing":{"blockGap":"var:preset|spacing|20"}},"layout":{"type":"flex","flexWrap":"wrap"}} -->
<div class="wp-block-group">
<!-- wp:navigation {"layout":{"type":"flex","justifyContent":"right","orientation":"horizontal"},"style":{"spacing":{"margin":{"top":"0"},"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}},"fontSize":"x-small"} /-->
<!-- wp:loginout {"className":"wp-button-custom","style":{"spacing":{"margin":{"top":"0"},"blockGap":"var:preset|spacing|20"},"layout":{"selfStretch":"fit","flexSize":null}},"textColor":"base-2","fontSize":"x-small"} /-->
</div>
<!-- /wp:group -->
</div>

<!-- /wp:group -->
</div>
<!-- /wp:group -->
2 changes: 1 addition & 1 deletion themes/goodbids-nonprofit/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Theme URI: https://goodbids.org
Author: Viget
Author URI: https://viget.com
Description: Twenty Twenty-Four child theme for GoodBids Nonprofit sites.
Version: 1.0
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: goodbids-nonprofit
Expand Down
2 changes: 1 addition & 1 deletion themes/goodbids-nonprofit/templates/front-page.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:template-part {"slug":"header","area":"header","tagName":"header"} /-->
<!-- wp:pattern {"slug":"goodbids-nonprofit/template-home-nonprofit"} /-->
<!-- wp:pattern {"slug":"goodbids-np/template-home-nonprofit"} /-->
<!-- wp:template-part {"slug":"footer","area":"footer","tagName":"footer"} /-->
6 changes: 6 additions & 0 deletions themes/goodbids-nonprofit/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
"typography": {
"lineHeight": false,
"fontSizes": [
{
"fluid": false,
"name": "X Small",
"size": "0.9rem",
"slug": "x-small"
},
{
"fluid": false,
"name": "Small",
Expand Down