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

Poetry: add alternative header part #179

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
59 changes: 59 additions & 0 deletions poetry/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Poetry functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WordPress
* @subpackage Poetry
* @since Poetry 1.0
*/


if ( ! function_exists( 'poetry_support' ) ) :

/**
* Sets up theme defaults and registers support for various WordPress features.
*
* @since Poetry 1.0
*
* @return void
*/
function poetry_support() {

// Enqueue editor styles.
add_editor_style( 'style.css' );
}

endif;

add_action( 'after_setup_theme', 'poetry_support' );

if ( ! function_exists( 'poetry_styles' ) ) :

/**
* Enqueue styles.
*
* @since Poetry 1.0
*
* @return void
*/
function poetry_styles() {
// Register theme stylesheet.
$theme_version = wp_get_theme()->get( 'Version' );

$version_string = is_string( $theme_version ) ? $theme_version : false;
wp_register_style(
'poetry-style',
get_template_directory_uri() . '/style.css',
array(),
$version_string
);

// Enqueue theme stylesheet.
wp_enqueue_style( 'poetry-style' );
}

endif;

add_action( 'wp_enqueue_scripts', 'poetry_styles' );
25 changes: 25 additions & 0 deletions poetry/parts/header-small.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- wp:group {"style":{"spacing":{"padding":{"top":"32px","bottom":"64px"}}},"className":"header-small","layout":{"type":"constrained"}} -->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of pixel values, can we use any of the presets (small, medium, large...)? If none work, let's use rem values instead

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just checked and the old header has the same problem, we should do the change on both to keep it consistent

<div class="wp-block-group header-small" style="padding-top:32px;padding-bottom:64px"><!-- wp:group {"style":{"spacing":{"blockGap":"3rem"}},"className":"header-small__container","layout":{"type":"flex","flexWrap":"wrap","verticalAlignment":"top","justifyContent":"space-between"}} -->
<div class="wp-block-group header-small__container"><!-- wp:site-title {"level":0,"isLink":false,"style":{"typography":{"fontStyle":"normal","fontWeight":"600"}},"fontSize":"medium"} /-->

<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:group {"style":{"spacing":{"blockGap":"0.25rem"}},"layout":{"type":"flex","orientation":"vertical"}} -->
<div class="wp-block-group"><!-- wp:paragraph {"style":{"typography":{"lineHeight":"0.8","fontSize":"2rem"}},"fontFamily":"rozha-one"} -->
<p class="has-rozha-one-font-family" style="font-size:2rem;line-height:0.8">Food for thoughts</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"style":{"typography":{"lineHeight":"1.5"}},"fontSize":"small"} -->
<p class="has-small-font-size" style="line-height:1.5">A collection of valuable thoughts by a very egocentric person.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:image {"width":"auto","height":"64px","sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large is-resized"><img src="http://wp-community-day.local/wp-content/themes/poetry/assets/images/feather.png" alt="" style="width:auto;height:64px"/></figure>
Copy link
Collaborator

Choose a reason for hiding this comment

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

this url won't work on other people's sites, let's do something like this

<!-- /wp:image --></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->

<!-- wp:spacer {"height":"50px"} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
7 changes: 6 additions & 1 deletion poetry/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
Template:
Text Domain: poetry
Tags: one-column, custom-colors, custom-menu, custom-logo, editor-style, featured-images, full-site-editing, rtl-language-support, theme-options, threaded-comments, translation-ready, wide-blocks
*/
*/

.header-small .header-small__container.wp-block-group {
align-items: baseline;
row-gap: 1rem;
}
2 changes: 1 addition & 1 deletion poetry/templates/404.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:template-part {"slug":"header-small","tagName":"header"} /-->

<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|80","bottom":"var:preset|spacing|80"},"margin":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|50"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50);padding-top:var(--wp--preset--spacing--80);padding-bottom:var(--wp--preset--spacing--80)"><!-- wp:heading {"textAlign":"center"} -->
Expand Down
2 changes: 1 addition & 1 deletion poetry/templates/search.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:template-part {"slug":"header-small","tagName":"header"} /-->

<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|80","bottom":"var:preset|spacing|80"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--80);padding-bottom:var(--wp--preset--spacing--80)"><!-- wp:query-title {"type":"search","style":{"spacing":{"padding":{"top":"0","bottom":"0"},"margin":{"top":"0","bottom":"0"}}}} /-->
Expand Down
22 changes: 17 additions & 5 deletions poetry/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
},
"styles": {
"color": {
"background": "var:preset|color|white"
"background": "var(--wp--preset--color--white)"
},
"elements": {
"h1": {
Expand All @@ -131,7 +131,7 @@
"fontSize": "var(--wp--preset--font-size--xx-large)",
"fontStyle": "normal",
"fontWeight": "400",
"lineHeight": 0.8
"lineHeight": "0.8"
}
},
"h2": {
Expand All @@ -147,21 +147,33 @@
}
}
},
"spacing": {
"padding": {
"bottom": "0px",
"left": "2rem",
"right": "2rem",
"top": "0px"
}
},
"typography": {
"fontFamily": "var:preset|font-family|inter",
"lineHeight": 2
"fontFamily": "var(--wp--preset--font-family--inter)",
"lineHeight": "2"
}
},
"templateParts": [
{
"area": "header",
"name": "header"
},
{
"area": "header",
"name": "header-small"
},
{
"area": "footer",
"name": "footer"
}
],
"version": 2,
"$schema": "https://schemas.wp.org/wp/6.1/theme.json"
"$schema": "https://schemas.wp.org/wp/6.5/theme.json"
}
Loading