first commit
This commit is contained in:
10
wp-content/themes/aac/blocks/alert-info/block.json
Normal file
10
wp-content/themes/aac/blocks/alert-info/block.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"apiVersion": 2,
|
||||
"name": "aac/alert-info",
|
||||
"title": "Alert info",
|
||||
"category": "widgets",
|
||||
"icon": "info",
|
||||
"editorScript": "file:./index.js",
|
||||
"style": "file:./style.css",
|
||||
"description": "Blok z tytułem i treścią HTML (server-rendered)."
|
||||
}
|
||||
68
wp-content/themes/aac/blocks/alert-info/index.js
Normal file
68
wp-content/themes/aac/blocks/alert-info/index.js
Normal file
@@ -0,0 +1,68 @@
|
||||
;(function (blocks, element, blockEditor) {
|
||||
const { registerBlockType } = blocks
|
||||
const { createElement: el } = element
|
||||
const { RichText, useBlockProps } = blockEditor
|
||||
|
||||
registerBlockType('aac/alert-info', {
|
||||
title: 'Alert info',
|
||||
icon: 'info',
|
||||
category: 'widgets',
|
||||
attributes: {
|
||||
title: { type: 'string', source: 'html', selector: 'strong' },
|
||||
content: { type: 'string', source: 'html', selector: 'p' },
|
||||
},
|
||||
|
||||
edit: function (props) {
|
||||
const { attributes, setAttributes } = props
|
||||
const { title, content } = attributes
|
||||
const blockProps = useBlockProps({ className: 'alert-info' })
|
||||
|
||||
return el('div', blockProps, [
|
||||
el('div', { className: 'alert-header' }, [
|
||||
el('img', {
|
||||
src: '/wp-content/uploads/2025/10/WarningCircle.svg',
|
||||
alt: 'Alert icon',
|
||||
className: 'alert-icon',
|
||||
}),
|
||||
el(
|
||||
'span',
|
||||
null,
|
||||
el(RichText, {
|
||||
tagName: 'strong',
|
||||
placeholder: 'Ważna informacja',
|
||||
value: title,
|
||||
onChange: (val) => setAttributes({ title: val }),
|
||||
})
|
||||
),
|
||||
]),
|
||||
el(RichText, {
|
||||
tagName: 'p',
|
||||
placeholder: 'Treść alertu...',
|
||||
value: content,
|
||||
onChange: (val) => setAttributes({ content: val }),
|
||||
}),
|
||||
])
|
||||
},
|
||||
|
||||
save: function (props) {
|
||||
const { attributes } = props
|
||||
const { title, content } = attributes
|
||||
|
||||
return el('div', { className: 'alert-info' }, [
|
||||
el('div', { className: 'alert-header' }, [
|
||||
el('img', {
|
||||
src: '/wp-content/uploads/2025/10/WarningCircle.svg',
|
||||
alt: 'Alert icon',
|
||||
className: 'alert-icon',
|
||||
}),
|
||||
el(
|
||||
'span',
|
||||
null,
|
||||
el(RichText.Content, { tagName: 'strong', value: title })
|
||||
),
|
||||
]),
|
||||
el(RichText.Content, { tagName: 'p', value: content }),
|
||||
])
|
||||
},
|
||||
})
|
||||
})(window.wp.blocks, window.wp.element, window.wp.blockEditor)
|
||||
0
wp-content/themes/aac/blocks/alert-info/style.css
Normal file
0
wp-content/themes/aac/blocks/alert-info/style.css
Normal file
Reference in New Issue
Block a user