Skip to content

Commit

Permalink
feat(carousel): move name, attributes, and category to json file
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasguillot committed Feb 7, 2025
1 parent 3eade76 commit 65a1b0d
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 100 deletions.
108 changes: 108 additions & 0 deletions src/blocks/carousel/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"name": "carousel",
"category": "newspack",
"apiVersion": 3,
"attributes": {
"className": {
"type": "string",
"default": ""
},
"imageFit": {
"type": "string",
"default": "cover"
},
"autoplay": {
"type": "boolean",
"default": false
},
"delay": {
"type": "number",
"default": 5
},
"postsToShow": {
"type": "integer",
"default": 3
},
"authors": {
"type": "array"
},
"categories": {
"type": "array"
},
"includeSubcategories": {
"type": "boolean",
"default": true
},
"tags": {
"type": "array"
},
"customTaxonomies": {
"type": "array"
},
"showDate": {
"type": "boolean",
"default": true
},
"showAuthor": {
"type": "boolean",
"default": true
},
"showAvatar": {
"type": "boolean",
"default": true
},
"showCaption": {
"type": "boolean",
"default": false
},
"showCredit": {
"type": "boolean",
"default": false
},
"showCategory": {
"type": "boolean",
"default": false
},
"showTitle": {
"type": "boolean",
"default": true
},
"postType": {
"type": "array",
"default": [ "post" ],
"items": {
"type": "string"
}
},
"specificMode": {
"type": "boolean",
"default": false
},
"specificPosts": {
"type": "array",
"default": [],
"items": {
"type": "integer"
}
},
"slidesPerView": {
"type": "number",
"default": 1
},
"hideControls": {
"type": "boolean",
"default": false
},
"aspectRatio": {
"type": "number",
"default": 0.75
},
"includedPostStatuses": {
"type": "array",
"default": [ "publish" ],
"items": {
"type": "string"
}
}
}
}
107 changes: 7 additions & 100 deletions src/blocks/carousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ import edit from './edit';
*/
import './view.scss';
import './editor.scss';
import metadata from './block.json';
const { name, attributes, category } = metadata;

// Name must be exported separately.
export { name };

export const name = 'carousel';
export const title = __( 'Content Carousel', 'newspack-blocks' );

export const icon = (
Expand All @@ -35,7 +39,8 @@ export const settings = {
src: icon,
foreground: '#36f',
},
category: 'newspack',
attributes,
category,
keywords: [
__( 'posts', 'newspack-blocks' ),
__( 'articles', 'newspack-blocks' ),
Expand All @@ -46,104 +51,6 @@ export const settings = {
'An advanced block that displays content in a carousel format with customizable parameters and visual configurations.',
'newspack-blocks'
),
attributes: {
className: {
type: 'string',
},
imageFit: {
type: 'string',
default: 'cover',
},
autoplay: {
type: 'boolean',
default: false,
},
delay: {
type: 'number',
default: 5,
},
postsToShow: {
type: 'integer',
default: 3,
},
authors: {
type: 'array',
},
categories: {
type: 'array',
},
includeSubcategories: {
type: 'boolean',
default: true,
},
tags: {
type: 'array',
},
customTaxonomies: {
type: 'array',
},
showDate: {
type: 'boolean',
default: true,
},
showAuthor: {
type: 'boolean',
default: true,
},
showAvatar: {
type: 'boolean',
default: true,
},
showCaption: {
type: 'boolean',
default: false,
},
showCredit: {
type: 'boolean',
default: false,
},
showCategory: {
type: 'boolean',
default: false,
},
showTitle: {
type: 'boolean',
default: true,
},
postType: {
type: 'array',
default: [ 'post' ],
items: {
type: 'string',
},
},
specificMode: {
type: 'boolean',
default: false,
},
specificPosts: {
type: 'array',
default: [],
items: { type: 'integer' },
},
slidesPerView: {
type: 'number',
default: 1,
},
hideControls: {
type: 'boolean',
default: false,
},
aspectRatio: {
type: 'number',
default: 0.75,
},
includedPostStatuses: {
type: 'array',
default: [ 'publish' ],
items: { type: 'string' },
},
},
supports: {
html: false,
align: [ 'center', 'wide', 'full' ],
Expand Down

0 comments on commit 65a1b0d

Please sign in to comment.