PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.4.0
GenerateBlocks v1.4.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 / button / css / tablet.js
generateblocks / src / blocks / button / css Last commit date
desktop.js 5 years ago main.js 5 years ago mobile.js 5 years ago tablet-only.js 5 years ago tablet.js 5 years ago
tablet.js
103 lines
1 /* eslint-disable quotes */
2 import buildCSS from '../../../utils/build-css';
3 import valueWithUnit from '../../../utils/value-with-unit';
4
5 import {
6 Component,
7 } from '@wordpress/element';
8
9 import {
10 applyFilters,
11 } from '@wordpress/hooks';
12
13 export default class TabletCSS extends Component {
14 render() {
15 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props );
16
17 const {
18 url,
19 uniqueId,
20 removeText,
21 letterSpacingTablet,
22 fontSizeTablet,
23 fontSizeUnit,
24 marginTopTablet,
25 marginRightTablet,
26 marginBottomTablet,
27 marginLeftTablet,
28 marginUnit,
29 paddingTopTablet,
30 paddingRightTablet,
31 paddingBottomTablet,
32 paddingLeftTablet,
33 paddingUnit,
34 borderSizeTopTablet,
35 borderSizeRightTablet,
36 borderSizeBottomTablet,
37 borderSizeLeftTablet,
38 borderRadiusTopRightTablet,
39 borderRadiusBottomRightTablet,
40 borderRadiusBottomLeftTablet,
41 borderRadiusTopLeftTablet,
42 borderRadiusUnit,
43 iconPaddingTopTablet,
44 iconPaddingRightTablet,
45 iconPaddingBottomTablet,
46 iconPaddingLeftTablet,
47 iconPaddingUnit,
48 iconSizeTablet,
49 iconSizeUnit,
50 } = attributes;
51
52 let selector = 'a.gb-button-' + uniqueId;
53
54 if ( ! url ) {
55 selector = '.gb-button-' + uniqueId;
56 }
57
58 let cssObj = [];
59
60 cssObj[ '.block-editor-block-list__block ' + selector ] = [ {
61 'padding-top': valueWithUnit( paddingTopTablet, paddingUnit ),
62 'padding-right': valueWithUnit( paddingRightTablet, paddingUnit ),
63 'padding-bottom': valueWithUnit( paddingBottomTablet, paddingUnit ),
64 'padding-left': valueWithUnit( paddingLeftTablet, paddingUnit ),
65 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftTablet, borderRadiusUnit ),
66 'border-top-right-radius': valueWithUnit( borderRadiusTopRightTablet, borderRadiusUnit ),
67 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightTablet, borderRadiusUnit ),
68 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftTablet, borderRadiusUnit ),
69 'font-size': valueWithUnit( fontSizeTablet, fontSizeUnit ),
70 'letter-spacing': valueWithUnit( letterSpacingTablet, 'em' ),
71 'margin-top': valueWithUnit( marginTopTablet, marginUnit ),
72 'margin-right': valueWithUnit( marginRightTablet, marginUnit ),
73 'margin-bottom': valueWithUnit( marginBottomTablet, marginUnit ),
74 'margin-left': valueWithUnit( marginLeftTablet, marginUnit ),
75 } ];
76
77 if ( borderSizeTopTablet || borderSizeRightTablet || borderSizeBottomTablet || borderSizeLeftTablet ) {
78 cssObj[ '.block-editor-block-list__block ' + selector ].push( {
79 'border-top-width': valueWithUnit( borderSizeTopTablet, 'px' ),
80 'border-right-width': valueWithUnit( borderSizeRightTablet, 'px' ),
81 'border-bottom-width': valueWithUnit( borderSizeBottomTablet, 'px' ),
82 'border-left-width': valueWithUnit( borderSizeLeftTablet, 'px' ),
83 'border-style': 'solid',
84 } );
85 }
86
87 cssObj[ '.block-editor-block-list__block ' + selector + ' .gb-icon' ] = [ {
88 'padding-top': ! removeText ? valueWithUnit( iconPaddingTopTablet, iconPaddingUnit ) : false,
89 'padding-right': ! removeText ? valueWithUnit( iconPaddingRightTablet, iconPaddingUnit ) : false,
90 'padding-bottom': ! removeText ? valueWithUnit( iconPaddingBottomTablet, iconPaddingUnit ) : false,
91 'padding-left': ! removeText ? valueWithUnit( iconPaddingLeftTablet, iconPaddingUnit ) : false,
92 'font-size': valueWithUnit( iconSizeTablet, iconSizeUnit ),
93 } ];
94
95 cssObj = applyFilters( 'generateblocks.editor.tabletCSS', cssObj, this.props, 'button' );
96
97 return (
98 <style>{ buildCSS( cssObj ) }</style>
99 );
100 }
101 }
102 /* eslint-enable quotes */
103