PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.0
GenerateBlocks v1.8.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / headline / components / ComponentCSS.js
generateblocks / src / blocks / headline / components Last commit date
BlockControls.js 2 years ago ComponentCSS.js 4 years ago HeadlineContentRenderer.js 3 years ago InspectorAdvancedControls.js 3 years ago TagName.js 3 years ago ToolbarGroup.js 4 years ago
ComponentCSS.js
59 lines
1 import { memo } from '@wordpress/element';
2 import { useSelect } from '@wordpress/data';
3 import DesktopCSS from '../css/desktop';
4 import TabletCSS from '../css/tablet';
5 import TabletOnlyCSS from '../css/tablet-only';
6 import MobileCSS from '../css/mobile';
7 import MainCSS from '../css/main';
8 import shouldRebuildCSS from '../../../utils/should-rebuild-css';
9
10 function ComponentCSS( props ) {
11 const deviceType = useSelect( ( select ) => {
12 if ( ! select( 'core/edit-post' ) ) {
13 return 'Desktop';
14 }
15
16 const {
17 __experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType = () => 'Desktop',
18 } = select( 'core/edit-post' );
19
20 return experimentalGetPreviewDeviceType();
21 }, [] );
22
23 const {
24 isBlockPreview = false,
25 } = props?.attributes;
26
27 if ( isBlockPreview ) {
28 return null;
29 }
30
31 return (
32 <>
33 <MainCSS { ...props } />
34
35 { deviceType &&
36 <>
37 { 'Desktop' === deviceType &&
38 <DesktopCSS { ...props } />
39 }
40
41 { ( 'Tablet' === deviceType || 'Mobile' === deviceType ) &&
42 <TabletCSS { ...props } />
43 }
44
45 { 'Tablet' === deviceType &&
46 <TabletOnlyCSS { ...props } />
47 }
48
49 { 'Mobile' === deviceType &&
50 <MobileCSS { ...props } />
51 }
52 </>
53 }
54 </>
55 );
56 }
57
58 export default memo( ComponentCSS, shouldRebuildCSS );
59