diff --git a/src/php/functions.php b/src/php/functions.php index 5c244c6..44c4d7d 100644 --- a/src/php/functions.php +++ b/src/php/functions.php @@ -74,7 +74,6 @@ */ function add_to_context( $context ) { $context['menu'] = new \Timber\Menu( 'primary' ); - $context['footer_sidebar'] = Timber\Timber::get_widgets( 'footer-area' ); return $context; } add_filter( 'timber/context', 'add_to_context' ); diff --git a/src/php/inc/theme-widgets.php b/src/php/inc/theme-widgets.php index 64fc833..fac5b6f 100644 --- a/src/php/inc/theme-widgets.php +++ b/src/php/inc/theme-widgets.php @@ -6,19 +6,40 @@ */ /** - * Register widget area. + * Register widgetized areas. */ function sparkpress_theme_widgets_init() { + register_sidebar( + array( + 'name' => 'Primary Sidebar', + 'id' => 'primary-sidebar', + 'description' => 'Widget for the sidebar area.', + 'before_widget' => '
', + 'after_widget' => '
', + ) + ); + register_sidebar( array( 'name' => 'Footer', 'id' => 'footer-area', - 'description' => 'Sidebar for a the footer area.', + 'description' => 'Widget for the footer area.', 'before_widget' => '
', 'after_widget' => '
', - 'before_title' => '

', - 'after_title' => '

', ) ); } add_action( 'widgets_init', 'sparkpress_theme_widgets_init' ); + +/** + * Adds sidebar and footer widgets to the Timber context. + * + * @param array $context The Timber context array. + * @return array The updated Timber context array with sidebar and footer widgets. + */ +function sparkpress_add_widgets_to_context( $context ) { + $context['sidebar_widget'] = Timber\Timber::get_widgets( 'primary-sidebar' ); + $context['footer_widget'] = Timber\Timber::get_widgets( 'footer-area' ); + return $context; +} +add_filter( 'timber/context', 'sparkpress_add_widgets_to_context' ); diff --git a/src/php/views/base.twig b/src/php/views/base.twig index f019b25..f2cb077 100644 --- a/src/php/views/base.twig +++ b/src/php/views/base.twig @@ -8,18 +8,19 @@ {% endif %} - {# content block from child templates #} - {% block content %} -
- Sorry, no content -
- {% endblock %} - - {% if sidebar %} - - {% endif %} +
+ {# content block from child templates #} + {% block content %} +
+ Sorry, no content +
+ {% endblock %} + {% if sidebar_widget %} + + {% endif %} +
{% include 'footer.twig' %} diff --git a/src/php/views/footer.twig b/src/php/views/footer.twig index 7ec9777..bf6b704 100644 --- a/src/php/views/footer.twig +++ b/src/php/views/footer.twig @@ -12,7 +12,7 @@ Privacy Policy

- {{ footer_sidebar }} + {{ footer_widget }} diff --git a/src/scss/base.scss b/src/scss/base.scss index 0e1600f..9a16cf0 100644 --- a/src/scss/base.scss +++ b/src/scss/base.scss @@ -63,6 +63,8 @@ // Specific UI components. This is where majority of our work takes place // and our UI components are often composed of Objects and Components @import 'components/main-nav'; +@import 'components/primary-sidebar'; +@import 'components/post-body'; @import 'components/skip-to-content'; @import 'components/sticky-footer'; diff --git a/src/scss/components/_post-body.scss b/src/scss/components/_post-body.scss new file mode 100644 index 0000000..dfca99a --- /dev/null +++ b/src/scss/components/_post-body.scss @@ -0,0 +1,9 @@ +.cmp-post-body { + display: flex; + flex-direction: column; + gap: 1.5rem 3.75rem; + + @media (min-width: 50rem) { + flex-direction: row; + } +} diff --git a/src/scss/components/_primary-sidebar.scss b/src/scss/components/_primary-sidebar.scss new file mode 100644 index 0000000..8b9181b --- /dev/null +++ b/src/scss/components/_primary-sidebar.scss @@ -0,0 +1,8 @@ +.cmp-primary-sidebar { + background-color: var(--gray-background-color); + padding: 1rem; + + @media (min-width: 50rem) { + flex-basis: 18.75rem; + } +} diff --git a/src/scss/elements/_root.scss b/src/scss/elements/_root.scss index 2ad8dbb..807fc7e 100644 --- a/src/scss/elements/_root.scss +++ b/src/scss/elements/_root.scss @@ -8,6 +8,9 @@ --black: hsl(0deg 0% 0%); --white: hsl(0deg 0% 100%); + // Gray + --gray: hsl(0deg 0% 97%); + // Link colors --link-color: var(--primary-color); --link-color-hover: var(--secondary-color); @@ -16,6 +19,7 @@ // Foreground/background colors --text-color: var(--black); --background-color: var(--white); + --gray-background-color: var(--gray); color: var(--text-color); background-color: var(--background-color);