UPDATE Refactor audio player block to remove description handling and add placeholder for caption input
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2a4bbceeeb
commit
10b0624a29
|
|
@ -1 +1 @@
|
||||||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'f1e5510ad5a5a49f9c51');
|
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '05a0d66cc78a35b24dfe');
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,7 @@ function Edit({
|
||||||
children: "Audio"
|
children: "Audio"
|
||||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.RichText, {
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.RichText, {
|
||||||
className: "audio-player__details__caption",
|
className: "audio-player__details__caption",
|
||||||
|
placeholder: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)("Renseignez ici la légende de l'audio", "carhop-blocks"),
|
||||||
value: caption,
|
value: caption,
|
||||||
onChange: value => handleCaptionChange(value),
|
onChange: value => handleCaptionChange(value),
|
||||||
tagName: "span"
|
tagName: "span"
|
||||||
|
|
@ -294,7 +295,6 @@ function save({
|
||||||
const {
|
const {
|
||||||
audioUrl,
|
audioUrl,
|
||||||
title,
|
title,
|
||||||
description,
|
|
||||||
caption
|
caption
|
||||||
} = attributes;
|
} = attributes;
|
||||||
if (!audioUrl) {
|
if (!audioUrl) {
|
||||||
|
|
@ -313,17 +313,14 @@ function save({
|
||||||
src: audioUrl,
|
src: audioUrl,
|
||||||
preload: "metadata",
|
preload: "metadata",
|
||||||
children: "Votre navigateur ne supporte pas l'\xE9l\xE9ment audio."
|
children: "Votre navigateur ne supporte pas l'\xE9l\xE9ment audio."
|
||||||
}), (description || caption) && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("p", {
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("p", {
|
||||||
className: "audio-player__details",
|
className: "audio-player__details",
|
||||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
|
||||||
className: "audio-player__details__label",
|
className: "audio-player__details__label",
|
||||||
children: "Audio"
|
children: "Audio"
|
||||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
|
||||||
className: "audio-player__details__caption",
|
className: "audio-player__details__caption",
|
||||||
children: caption ? caption + " — " : ""
|
children: caption !== null && caption !== void 0 ? caption : ""
|
||||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
|
|
||||||
className: "audio-player__details__description",
|
|
||||||
children: description !== null && description !== void 0 ? description : ""
|
|
||||||
})]
|
})]
|
||||||
})]
|
})]
|
||||||
});
|
});
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -208,6 +208,10 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
<span className="audio-player__details__label">Audio</span>
|
<span className="audio-player__details__label">Audio</span>
|
||||||
<RichText
|
<RichText
|
||||||
className="audio-player__details__caption"
|
className="audio-player__details__caption"
|
||||||
|
placeholder={__(
|
||||||
|
"Renseignez ici la légende de l'audio",
|
||||||
|
"carhop-blocks"
|
||||||
|
)}
|
||||||
value={caption}
|
value={caption}
|
||||||
onChange={(value) => handleCaptionChange(value)}
|
onChange={(value) => handleCaptionChange(value)}
|
||||||
tagName="span"
|
tagName="span"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { useBlockProps } from "@wordpress/block-editor";
|
||||||
import { RichText } from "@wordpress/block-editor";
|
import { RichText } from "@wordpress/block-editor";
|
||||||
|
|
||||||
export default function save({ attributes }) {
|
export default function save({ attributes }) {
|
||||||
const { audioUrl, title, description, caption } = attributes;
|
const { audioUrl, title, caption } = attributes;
|
||||||
|
|
||||||
if (!audioUrl) {
|
if (!audioUrl) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -19,17 +19,10 @@ export default function save({ attributes }) {
|
||||||
Votre navigateur ne supporte pas l'élément audio.
|
Votre navigateur ne supporte pas l'élément audio.
|
||||||
</audio>
|
</audio>
|
||||||
|
|
||||||
{(description || caption) && (
|
<p className="audio-player__details">
|
||||||
<p className="audio-player__details">
|
<span className="audio-player__details__label">Audio</span>
|
||||||
<span className="audio-player__details__label">Audio</span>
|
<span className="audio-player__details__caption">{caption ?? ""}</span>
|
||||||
<span className="audio-player__details__caption">
|
</p>
|
||||||
{caption ? caption + " — " : ""}
|
|
||||||
</span>
|
|
||||||
<span className="audio-player__details__description">
|
|
||||||
{description ?? ""}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user