CTA.js
5 years ago
CheckboxControl.js
5 years ago
CodeMirror.js
3 years ago
ColorPicker.js
5 years ago
ComboboxControl.js
3 years ago
Disabled.js
5 years ago
Fields.js
5 years ago
Group.js
3 years ago
Groups.js
5 years ago
Integration.js
5 years ago
Loading.js
5 years ago
Media.js
3 years ago
Notices.js
3 years ago
NullView.js
5 years ago
Page.js
5 years ago
SaveButton.js
3 years ago
SelectControl.js
5 years ago
TextControl.js
5 years ago
ToggleControl.js
5 years ago
Media.js
72 lines
| 1 | import { __ } from "@wordpress/i18n"; |
| 2 | import { Button, BaseControl } from "@wordpress/components"; |
| 3 | import { MediaUpload } from "@wordpress/media-utils"; |
| 4 | import classNames from "classnames"; |
| 5 | |
| 6 | export default ({ |
| 7 | option, |
| 8 | label, |
| 9 | help, |
| 10 | allowedTypes, |
| 11 | value, |
| 12 | className, |
| 13 | maxWidth, |
| 14 | onSelect, |
| 15 | }) => { |
| 16 | return ( |
| 17 | <div |
| 18 | className={classNames( |
| 19 | className, |
| 20 | "presto-settings__setting is-media-control" |
| 21 | )} |
| 22 | > |
| 23 | <BaseControl className="editor-video-poster-control"> |
| 24 | <BaseControl.VisualLabel>{label}</BaseControl.VisualLabel> |
| 25 | {value && ( |
| 26 | <BaseControl> |
| 27 | <img |
| 28 | style={{ |
| 29 | maxWidth, |
| 30 | border: "1px solid #dcdcdc", |
| 31 | }} |
| 32 | src={value} |
| 33 | /> |
| 34 | </BaseControl> |
| 35 | )} |
| 36 | <br /> |
| 37 | <MediaUpload |
| 38 | title={help} |
| 39 | onSelect={onSelect} |
| 40 | allowedTypes={allowedTypes} |
| 41 | render={({ open }) => ( |
| 42 | <Button |
| 43 | isSecondary |
| 44 | onClick={open} |
| 45 | className={!value ? "button-select" : "button-replace"} |
| 46 | > |
| 47 | {!value |
| 48 | ? __("Select", "presto-player") |
| 49 | : __("Replace", "presto-player")} |
| 50 | </Button> |
| 51 | )} |
| 52 | />{" "} |
| 53 | <p id={`video-block__logo-image-description-${option?.id}`} hidden> |
| 54 | {value |
| 55 | ? sprintf( |
| 56 | /* translators: %s: poster image URL. */ |
| 57 | __("The current logo image url is %s", "presto-player"), |
| 58 | value |
| 59 | ) |
| 60 | : __("There is no logo image currently selected", "presto-player")} |
| 61 | </p> |
| 62 | {!!value && ( |
| 63 | <Button onClick={() => onSelect("")} isTertiary> |
| 64 | {__("Remove", "presto-player")} |
| 65 | </Button> |
| 66 | )} |
| 67 | </BaseControl> |
| 68 | <br /> |
| 69 | </div> |
| 70 | ); |
| 71 | }; |
| 72 |