Skip to content

Commit

Permalink
Load block assets as separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMayerhofer committed May 8, 2021
1 parent 39dd003 commit fe473f2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
6 changes: 4 additions & 2 deletions inc/blocks/block-accordion.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public static function register_block_type(): void {
'name' => self::get_name(),
'title' => __( 'Accordion', 'foundationpress' ),
'render_template' => 'template-parts/blocks/' . self::get_name() . '.php',
'enqueue_style' => get_template_directory_uri() . '/dist/assets/css/blocks/' . self::get_name() . '.css',
'enqueue_script' => get_template_directory_uri() . '/dist/assets/js/blocks/' . self::get_name() . '.js',
'category' => 'foundationpress',
'icon' => 'editor-help',
'keywords' => [ self::get_name(), 'faq', 'akkordion' ],
'supports' => [
'align' => false,
'anchor' => true,
'align' => false,
'anchor' => true,
'classNames' => true,
],
]
);
Expand Down
8 changes: 5 additions & 3 deletions inc/blocks/block-button.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ public static function register_block_type(): void {
[
'name' => self::get_name(),
'title' => __( 'FP Button', 'foundationpress' ),
'render_template' => 'template-parts/blocks/button.php',
'render_template' => 'template-parts/blocks/' . self::get_name() . '.php',
'enqueue_style' => get_template_directory_uri() . '/dist/assets/css/blocks/' . self::get_name() . '.css',
// 'enqueue_script' => get_template_directory_uri() . '/dist/assets/js/blocks/' . self::get_name() . '.js',
'category' => 'foundationpress',
'icon' => 'shield-alt',
'keywords' => [ 'button' ],
'keywords' => [ self::get_name() ],
'supports' => [
'align' => true,
'anchor' => true,
'classNames' => false,
'classNames' => true,
],
]
);
Expand Down
8 changes: 5 additions & 3 deletions src/assets/scss/blocks/_blocks.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// All styles regarding gutenberg blocks.
/*
* Files inside this folder without the _ prefix will be compiled as separate files.
* Files with the _ prefix are seen as partials and need to be imported in other files.
*/

@import 'block-accordion';
@import 'block-button';
// All styles regrding blocks outside of this theme.

// wordpress default block.
.wp-block-columns {
Expand Down
3 changes: 3 additions & 0 deletions src/assets/scss/blocks/_imports.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import '../settings';
@import '~foundation-sites/scss/foundation';
@import '../mixins/mixins';
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'imports';

.b-accordion {
&__inner {
@include xy-grid();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'imports';

.b-button {
&.aligncenter {
text-align: center;
Expand Down

0 comments on commit fe473f2

Please sign in to comment.