Skip to content

Commit

Permalink
Eoxia#27[Blocks] add: Carousel block parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
eoxia-amandine committed Jan 24, 2025
1 parent 38e3f94 commit 3c35691
Show file tree
Hide file tree
Showing 16 changed files with 286 additions and 43 deletions.
20 changes: 20 additions & 0 deletions blocks/build/eo-carousel/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@
"navigation": {
"type": "boolean",
"default": true
},
"effect": {
"type": "string",
"default": "default"
},
"spaceBetween": {
"type": "number",
"default": 0
},
"mobileBreakpoint": {
"type": "number",
"default": 599
},
"mobileSlidesPerView": {
"type": "number",
"default": 1
},
"mainColor": {
"type": "string",
"default": "#007aff"
}
},
"supports": {},
Expand Down
2 changes: 1 addition & 1 deletion blocks/build/eo-carousel/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '53218907a6063a7bb7b1');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'a126b8ec4092d99c8937');
96 changes: 95 additions & 1 deletion blocks/build/eo-carousel/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/build/eo-carousel/index.js.map

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions blocks/build/eo-carousel/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@
}

$carousel_attr = array(
'slidesPerView' => esc_attr( $attributes['slidesPerView'] ),
'loop' => esc_attr( $attributes['loop'] ),
'speed' => esc_attr( $attributes['speed'] )
'loop' => esc_attr( $attributes['loop'] ),
'speed' => esc_attr( $attributes['speed'] ),
'effect' => esc_attr( $attributes['effect'] ),
'spaceBetween' => esc_attr( $attributes['spaceBetween'] ),
'slidesPerView' => esc_attr( $attributes['mobileSlidesPerView'] ),
'breakpoints' => array(
esc_attr( $attributes['mobileBreakpoint'] ) => array(
'slidesPerView' => esc_attr( $attributes['slidesPerView'] )
),
)
);

if ( $attributes['autoplay'] ) {
Expand All @@ -28,6 +35,11 @@
$carousel_attr['navigation'] = false;
}
?>
<style>
:root {
--swiper-theme-color: <?php echo esc_attr( $attributes['mainColor'] ); ?>;
}
</style>

<div <?php echo wp_kses_data( get_block_wrapper_attributes( [ 'class' => 'swiper' ] ) ); ?> data-carousel=<?php echo wp_json_encode( $carousel_attr ); ?>>
<!-- Additional required wrapper -->
Expand Down
3 changes: 0 additions & 3 deletions blocks/build/eo-carousel/style-index-rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@
*
* Replace them with your own styles or remove the file completely.
*/
.wp-block-eo-carousel {
width: 600px;
}
3 changes: 0 additions & 3 deletions blocks/build/eo-carousel/style-index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/build/eo-carousel/style-index.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/build/eo-carousel/view.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '79aa1181d165cc92c347');
<?php return array('dependencies' => array(), 'version' => '13a640d1e0a20d004566');
10 changes: 9 additions & 1 deletion blocks/build/eo-carousel/view.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/build/eo-carousel/view.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions blocks/src/eo-carousel/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@
"navigation": {
"type": "boolean",
"default": true
},
"effect": {
"type": "string",
"default": "default"
},
"spaceBetween": {
"type": "number",
"default": 0
},
"mobileBreakpoint": {
"type": "number",
"default": 599
},
"mobileSlidesPerView": {
"type": "number",
"default": 1
},
"mainColor": {
"type": "string",
"default": "#007aff"
}
},
"supports": {},
Expand Down
Loading

0 comments on commit 3c35691

Please sign in to comment.