plugin upload

This commit is contained in:
Rodolfo Martinez 2025-12-12 23:29:08 -05:00
parent 00e60ec1b7
commit c4905e952e
17 changed files with 1426 additions and 0 deletions

View file

@ -0,0 +1,106 @@
(function (blocks, element, blockEditor, components) {
var el = element.createElement;
var useBlockProps = blockEditor.useBlockProps;
var BlockControls = blockEditor.BlockControls;
var AlignmentToolbar = blockEditor.AlignmentToolbar;
var TextControl = components.TextControl;
blocks.registerBlockType("maple/mortgage-calculator", {
title: "Mortgage Calculator",
icon: "calculator",
category: "common",
attributes: {
align: {
type: "string",
},
},
supports: {
align: true,
},
edit: function (props) {
const blockProps = useBlockProps({
className: props.attributes.align
? "align" + props.attributes.align
: "",
});
return [
el(
BlockControls,
{ key: "controls" },
el(AlignmentToolbar, {
value: props.attributes.align,
onChange: (newAlign) => {
props.setAttributes({ align: newAlign });
},
}),
),
el(
"div",
blockProps,
el("h2", {}, "Mortgage Calculator"),
el(
"form",
{ className: "maple-calc-form" },
el(
"div",
{ className: "form-group" },
el(TextControl, {
label: "Loan Amount ($)",
type: "number",
value: "",
onChange: () => {},
}),
),
el(
"div",
{ className: "form-group" },
el(TextControl, {
label: "Interest Rate (%)",
type: "number",
value: "",
onChange: () => {},
}),
),
el(
"div",
{ className: "form-group" },
el(TextControl, {
label: "Loan Term (Years)",
type: "number",
value: "",
onChange: () => {},
}),
),
el(
"button",
{ type: "button", className: "calculate-button" },
"Calculate",
),
),
el(
"div",
{ className: "results" },
el("h3", {}, "Results"),
el("p", {}, el("strong", {}, "Monthly Payment: "), "$---"),
el("p", {}, el("strong", {}, "Total Payment: "), "$---"),
el("p", {}, el("strong", {}, "Total Interest: "), "$---"),
el(
"div",
{ className: "chart-container" },
el("canvas", { className: "mortgage-chart" }),
),
),
),
];
},
save: function () {
return null;
},
});
})(
window.wp.blocks,
window.wp.element,
window.wp.blockEditor,
window.wp.components,
);