PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / video / edit / background-color.js

background-color.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.2, at gutenberg/blocks/video/edit/background-color.js

134 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {
2 __experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
3 __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
4 InspectorControls,
5 } from '@wordpress/block-editor';
6 import { __ } from '@wordpress/i18n';
7
8 import { hasClass } from '../../../utils/classes-replacer';
9
10 export default function BackgroundColor(props) {
11 const { attributes, setAttributes, clientId } = props;
12 const {
13 type,
14 clickAction,
15
16 videoBackgroundColor,
17 videoBackgroundGradient,
18
19 fullscreenVideoBackgroundColor,
20 fullscreenVideoBackgroundGradient,
21
22 fullscreenBackgroundColor,
23 fullscreenBackgroundGradient,
24
25 className,
26 } = attributes;
27
28 const colorGradientSettings = useMultipleOriginColorsAndGradients();
29 const hasColor = colorGradientSettings.hasColorsOrGradients;
30 const hasIconOnly = hasClass(className, 'is-style-icon-only');
31
32 const hasVideoPlain =
33 type === 'video' && clickAction === 'plain' && !hasIconOnly;
34 const hasVideoFullscreen = type === 'video' && clickAction === 'fullscreen';
35 const hasFullscreen = clickAction === 'fullscreen';
36
37 return (hasColor && hasVideoPlain) ||
38 (hasColor && hasVideoFullscreen) ||
39 (hasColor && type === 'yt_vm_video' && hasFullscreen) ? (
40 <InspectorControls group="color">
41 {/* Video plain background. */}
42 {hasVideoPlain && (
43 <ColorGradientSettingsDropdown
44 __experimentalIsRenderedInSidebar
45 settings={[
46 {
47 colorValue: videoBackgroundColor,
48 gradientValue: videoBackgroundGradient,
49 label: __('Video Background', 'ghostkit'),
50 onColorChange: (val) => {
51 setAttributes({ videoBackgroundColor: val });
52 },
53 onGradientChange: (val) => {
54 setAttributes({ videoBackgroundGradient: val });
55 },
56 isShownByDefault: true,
57 resetAllFilter: () => ({
58 videoBackgroundColor: undefined,
59 videoBackgroundGradient: undefined,
60 }),
61 },
62 ]}
63 panelId={clientId}
64 {...colorGradientSettings}
65 />
66 )}
67
68 {/* Video fullscreen background. */}
69 {hasVideoFullscreen && (
70 <ColorGradientSettingsDropdown
71 __experimentalIsRenderedInSidebar
72 settings={[
73 {
74 colorValue: fullscreenVideoBackgroundColor,
75 gradientValue: fullscreenVideoBackgroundGradient,
76 label: __(
77 'Video Fullscreen Background',
78 'ghostkit'
79 ),
80 onColorChange: (val) => {
81 setAttributes({
82 fullscreenVideoBackgroundColor: val,
83 });
84 },
85 onGradientChange: (val) => {
86 setAttributes({
87 fullscreenVideoBackgroundGradient: val,
88 });
89 },
90 isShownByDefault: true,
91 resetAllFilter: () => ({
92 fullscreenVideoBackgroundColor: undefined,
93 fullscreenVideoBackgroundGradient: undefined,
94 }),
95 },
96 ]}
97 panelId={clientId}
98 {...colorGradientSettings}
99 />
100 )}
101
102 {/* Fullscreen background. */}
103 {hasFullscreen && (
104 <ColorGradientSettingsDropdown
105 __experimentalIsRenderedInSidebar
106 settings={[
107 {
108 colorValue: fullscreenBackgroundColor,
109 gradientValue: fullscreenBackgroundGradient,
110 label: __('Fullscreen Background', 'ghostkit'),
111 onColorChange: (val) => {
112 setAttributes({
113 fullscreenBackgroundColor: val,
114 });
115 },
116 onGradientChange: (val) => {
117 setAttributes({
118 fullscreenBackgroundGradient: val,
119 });
120 },
121 isShownByDefault: true,
122 resetAllFilter: () => ({
123 fullscreenBackgroundColor: undefined,
124 }),
125 },
126 ]}
127 panelId={clientId}
128 {...colorGradientSettings}
129 />
130 )}
131 </InspectorControls>
132 ) : null;
133 }
134