Skip to content

Commit 849320d

Browse files
refactor: adjust widget registration and styles
- register and add widget areas to context in same file - rename widgets/widget areas - remove widget area titles - adjust css for sidebar widget area
1 parent 582e625 commit 849320d

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/php/functions.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@
7474
*/
7575
function add_to_context( $context ) {
7676
$context['menu'] = new \Timber\Menu( 'primary-menu' );
77-
$context['primary_sidebar'] = Timber\Timber::get_widgets( 'primary-widget-area' );
78-
$context['footer_sidebar'] = Timber\Timber::get_widgets( 'footer-area' );
7977
return $context;
8078
}
8179
add_filter( 'timber/context', 'add_to_context' );

src/php/inc/theme-widgets.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,29 @@
1111
function sparkpress_theme_widgets_init() {
1212
register_sidebar(
1313
array(
14-
'name' => 'Primary Widget Area',
15-
'id' => 'primary-widget-area',
16-
'description' => 'Primary sidebar area on the side of the page.',
14+
'name' => 'Primary Sidebar',
15+
'id' => 'primary-sidebar',
16+
'description' => 'Widget for the sidebar area.',
1717
'before_widget' => '<div>',
1818
'after_widget' => '</div>',
19-
'before_title' => '<h3>',
20-
'after_title' => '</h3>',
2119
)
2220
);
2321

2422
register_sidebar(
2523
array(
2624
'name' => 'Footer',
2725
'id' => 'footer-area',
28-
'description' => 'Sidebar for the footer area.',
26+
'description' => 'Widget for the footer area.',
2927
'before_widget' => '<div>',
3028
'after_widget' => '</div>',
31-
'before_title' => '<h3>',
32-
'after_title' => '</h3>',
3329
)
3430
);
3531
}
3632
add_action( 'widgets_init', 'sparkpress_theme_widgets_init' );
33+
34+
function sparkpress_add_widgets_to_context( $context ) {
35+
$context['sidebar_widget'] = Timber\Timber::get_widgets( 'primary-sidebar' );
36+
$context['footer_widget'] = Timber\Timber::get_widgets( 'footer-area' );
37+
return $context;
38+
}
39+
add_filter( 'timber/context', 'sparkpress_add_widgets_to_context' );

src/php/views/base.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
Sorry, no content
1616
</div>
1717
{% endblock %}
18-
{% if primary_sidebar %}
18+
{% if sidebar_widget %}
1919
<aside class="obj-width-limiter cmp-primary-sidebar">
20-
{{ primary_sidebar }}
20+
{{ sidebar_widget }}
2121
</aside>
2222
{% endif %}
2323
</div>

src/php/views/footer.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Privacy Policy
1313
</a>
1414
</p>
15-
{{ footer_sidebar }}
15+
{{ footer_widget }}
1616
</div>
1717
</footer>
1818

src/scss/components/_post-body.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.cmp-post-body {
22
display: flex;
33
flex-direction: column;
4+
gap: 1.5rem 3.75rem;
45

56
@media (min-width: 50rem) {
67
flex-direction: row;
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
.cmp-primary-sidebar {
22
background-color: var(--gray-background-color);
33
padding: 1rem;
4-
margin-top: 1.5rem;
54

65
@media (min-width: 50rem) {
7-
margin: 0 0 0 3.75rem;
8-
width: 18.75rem;
6+
flex-basis: 18.75rem;
97
}
108
}

0 commit comments

Comments
 (0)