import classnames from "classnames";
import { __ } from "@wordpress/i18n";
import { registerBlockType } from "@wordpress/blocks";
import { RichText, InnerBlocks } from "@wordpress/block-editor";
const IconFAQs = (
);
const IconFAQ = (
);
registerBlockType("custom-block/faqs", {
title: __("FAQs"),
description: __("Write Frequently Asked Questions in it."),
keywords: [__("faqs"), __("Frequently Asked Questions")],
category: "common",
icon: IconFAQs,
example: {},
attributes: {
title: {
type: "array",
source: "children",
selector: "h2",
default: "Frequently Asked Questions",
},
},
edit: (props) => {
const {
className,
attributes: { title },
setAttributes,
} = props;
const onChangeTitle = (value) => setAttributes({ title: value });
const newClass = classnames(className, "wp-block-group faqs");
return (
);
},
save: (props) => {
const {
className,
attributes: { title },
} = props;
const newClass = classnames(className, "wp-block-group faqs");
return (
);
},
});
registerBlockType("custom-block/faq", {
title: __("Single FAQ"),
description: __("Write Frequently Asked Question in it."),
keywords: [__("faq"), __("Frequently Asked Question")],
category: "common",
icon: IconFAQ,
parent: ["custom-block/faq"],
example: {},
attributes: {
question: {
type: "array",
source: "children",
selector: ".faq__question",
},
answer: {
type: "array",
source: "children",
selector: ".faq__answer",
},
},
edit: (props) => {
const {
className,
attributes: { question, answer },
setAttributes,
} = props;
const onChangeQuestion = (value) => setAttributes({ question: value });
const onChangeAnswer = (value) => setAttributes({ answer: value });
const newClass = classnames(className, "faq");
return (
);
},
save: (props) => {
const {
className,
attributes: { question, answer },
} = props;
const newClass = classnames(className, "faq");
return (
);
},
});