humanmade / kalutara

WordPress pattern library for template parts
5 stars 2 forks source link

Remove header from pattern library #28

Closed mattheu closed 3 years ago

mattheu commented 3 years ago

Currently get_header is called at the top of the pattern library template file, which then loads the theme header. This isn't ideal as the theme header can be large. I think it's best if we control this ourselves, and just call wp_head to ensure all styles are loaded.

Also made some small adjustments to the style on mobile.

goldenapples commented 3 years ago

I was hesitant at first, thinking there might be container markup or additional assets in header and footer templates that could be required to render the page. But I've tested this out with a couple projects and it mostly works, so I think this should be good to go.

Another alternative I can think of is to pass in a name for context, so themes where the header and footer are especially large can create minimal templates for the pattern library. Like get_header( 'pattern-library' ) and so on...

mattheu commented 3 years ago

Yeah I have been thinking a bit about how to handle this, and actually added some padding when I added the styles to accomodate not having a container. Perhaps this is also a use case for a before_template and after_template action?

goldenapples commented 3 years ago

Perhaps this is also a use case for a before_template and after_template action?

Yeah, I guess that's a reasonable compromise. I was initially trying to think of ways to supply a template for the pattern library but allowing themes to override that. But I think I'm overcomplicating the problem.

Giving themes a hook to add markup before and after the pattern library output should be enough.

mattheu commented 3 years ago

Lets ship this and I'll see how it works out in practice. I'm happy to change this around if needed.