PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.2
GenerateBlocks v2.0.2
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 / css / main.js
generateblocks / src / blocks / headline / css Last commit date
desktop.js 5 years ago main.js 2 years ago mobile.js 2 years ago tablet-only.js 5 years ago tablet.js 2 years ago
main.js
106 lines
1 import buildCSS from '../../../utils/build-css';
2 import hexToRGBA from '../../../utils/hex-to-rgba';
3 import LayoutCSS from '../../../extend/inspector-control/controls/layout/components/LayoutCSS';
4 import FlexChildCSS from '../../../extend/inspector-control/controls/flex-child-panel/components/FlexChildCSS';
5 import SizingCSS from '../../../extend/inspector-control/controls/sizing/components/SizingCSS';
6 import SpacingCSS from '../../../extend/inspector-control/controls/spacing/components/SpacingCSS';
7 import TypographyCSS from '../../../extend/inspector-control/controls/typography/components/TypographyCSS';
8
9 import {
10 Component,
11 } from '@wordpress/element';
12
13 import {
14 applyFilters,
15 } from '@wordpress/hooks';
16 import BorderCSS from '../../../extend/inspector-control/controls/borders/BorderCSS';
17
18 export default class MainCSS extends Component {
19 render() {
20 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props );
21
22 const {
23 clientId,
24 } = this.props;
25
26 const {
27 uniqueId,
28 element,
29 backgroundColor,
30 backgroundColorOpacity,
31 textColor,
32 linkColor,
33 linkColorHover,
34 highlightTextColor,
35 fontFamilyFallback,
36 iconColor,
37 iconColorOpacity,
38 removeText,
39 display,
40 inlineWidth,
41 iconStyles,
42 } = attributes;
43
44 const selector = element + '.gb-headline-' + uniqueId;
45
46 let cssObj = [];
47
48 cssObj[ '.editor-styles-wrapper ' + selector ] = [ {
49 color: textColor,
50 } ];
51
52 TypographyCSS( cssObj, '.editor-styles-wrapper ' + selector, { ...attributes.typography, fontFamilyFallback } );
53 SpacingCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes.spacing );
54 BorderCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes.borders );
55 LayoutCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes );
56 SizingCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes );
57 FlexChildCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes );
58
59 cssObj[ '.editor-styles-wrapper .gb-container ' + selector ] = [ {
60 color: textColor,
61 } ];
62
63 cssObj[ '.editor-styles-wrapper ' + selector ].push( {
64 'background-color': hexToRGBA( backgroundColor, backgroundColorOpacity ),
65 'color': textColor, // eslint-disable-line quote-props
66 } );
67
68 cssObj[ '.editor-styles-wrapper ' + selector + ' a' ] = [ {
69 color: linkColor,
70 } ];
71
72 cssObj[ '.editor-styles-wrapper ' + selector + ' a:hover' ] = [ {
73 color: linkColorHover,
74 } ];
75
76 cssObj[ selector + ' .gb-icon' ] = [ {
77 'padding-top': ! removeText ? iconStyles?.paddingTop : null,
78 'padding-right': ! removeText ? iconStyles?.paddingRight : null,
79 'padding-bottom': ! removeText ? iconStyles?.paddingBottom : null,
80 'padding-left': ! removeText ? iconStyles?.paddingLeft : null,
81 'color': hexToRGBA( iconColor, iconColorOpacity ), // eslint-disable-line quote-props
82 } ];
83
84 cssObj[ selector + ' .gb-icon svg' ] = [ {
85 width: iconStyles?.width,
86 height: iconStyles?.height,
87 } ];
88
89 cssObj[ selector + ' .gb-highlight' ] = [ {
90 'color': highlightTextColor, // eslint-disable-line quote-props
91 } ];
92
93 if ( inlineWidth ) {
94 cssObj[ '.gb-is-root-block[data-block="' + clientId + '"]' ] = [ {
95 display,
96 } ];
97 }
98
99 cssObj = applyFilters( 'generateblocks.editor.mainCSS', cssObj, this.props, 'headline' );
100
101 return (
102 <style>{ buildCSS( cssObj ) }</style>
103 );
104 }
105 }
106