PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.7.2
GenerateBlocks v1.7.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 / button / css / tablet.js
generateblocks / src / blocks / button / css Last commit date
desktop.js 5 years ago main.js 3 years ago mobile.js 3 years ago tablet-only.js 5 years ago tablet.js 3 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 import LayoutCSS from '../../../extend/inspector-control/controls/layout/components/LayoutCSS';
5 import SizingCSS from '../../../extend/inspector-control/controls/sizing/components/SizingCSS';
6 import FlexChildCSS from '../../../extend/inspector-control/controls/flex-child-panel/components/FlexChildCSS';
7 import SpacingCSS from '../../../extend/inspector-control/controls/spacing/components/SpacingCSS';
8
9 import {
10 Component,
11 } from '@wordpress/element';
12
13 import {
14 applyFilters,
15 } from '@wordpress/hooks';
16
17 export default class TabletCSS extends Component {
18 render() {
19 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props );
20
21 const {
22 uniqueId,
23 removeText,
24 letterSpacingTablet,
25 fontSizeTablet,
26 fontSizeUnit,
27 paddingTopTablet,
28 paddingRightTablet,
29 paddingBottomTablet,
30 paddingLeftTablet,
31 paddingUnit,
32 borderSizeTopTablet,
33 borderSizeRightTablet,
34 borderSizeBottomTablet,
35 borderSizeLeftTablet,
36 borderRadiusTopRightTablet,
37 borderRadiusBottomRightTablet,
38 borderRadiusBottomLeftTablet,
39 borderRadiusTopLeftTablet,
40 borderRadiusUnit,
41 iconPaddingTopTablet,
42 iconPaddingRightTablet,
43 iconPaddingBottomTablet,
44 iconPaddingLeftTablet,
45 iconPaddingUnit,
46 iconSizeTablet,
47 iconSizeUnit,
48 hasButtonContainer,
49 alignmentTablet,
50 } = attributes;
51
52 const containerSelector = !! hasButtonContainer ? '.gb-button-wrapper ' : '';
53 let selector = '.gb-button-' + uniqueId;
54 selector = '.editor-styles-wrapper ' + containerSelector + selector;
55
56 let cssObj = [];
57
58 cssObj[ selector ] = [ {
59 'padding-top': valueWithUnit( paddingTopTablet, paddingUnit ),
60 'padding-right': valueWithUnit( paddingRightTablet, paddingUnit ),
61 'padding-bottom': valueWithUnit( paddingBottomTablet, paddingUnit ),
62 'padding-left': valueWithUnit( paddingLeftTablet, paddingUnit ),
63 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftTablet, borderRadiusUnit ),
64 'border-top-right-radius': valueWithUnit( borderRadiusTopRightTablet, borderRadiusUnit ),
65 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightTablet, borderRadiusUnit ),
66 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftTablet, borderRadiusUnit ),
67 'font-size': valueWithUnit( fontSizeTablet, fontSizeUnit ),
68 'letter-spacing': valueWithUnit( letterSpacingTablet, 'em' ),
69 'text-align': alignmentTablet,
70 } ];
71
72 SpacingCSS( cssObj, selector, attributes, 'Tablet' );
73 LayoutCSS( cssObj, selector, attributes, 'Tablet' );
74 SizingCSS( cssObj, selector, attributes, 'Tablet' );
75 FlexChildCSS( cssObj, selector, attributes, 'Tablet' );
76
77 if ( borderSizeTopTablet || borderSizeRightTablet || borderSizeBottomTablet || borderSizeLeftTablet ) {
78 cssObj[ 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[ 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