desktop.js
5 years ago
main.js
4 years ago
mobile.js
4 years ago
tablet-only.js
5 years ago
tablet.js
4 years ago
mobile.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 MobileCSS 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 | letterSpacingMobile, |
| 22 | fontSizeMobile, |
| 23 | fontSizeUnit, |
| 24 | marginTopMobile, |
| 25 | marginRightMobile, |
| 26 | marginBottomMobile, |
| 27 | marginLeftMobile, |
| 28 | marginUnit, |
| 29 | paddingTopMobile, |
| 30 | paddingRightMobile, |
| 31 | paddingBottomMobile, |
| 32 | paddingLeftMobile, |
| 33 | paddingUnit, |
| 34 | borderSizeTopMobile, |
| 35 | borderSizeRightMobile, |
| 36 | borderSizeBottomMobile, |
| 37 | borderSizeLeftMobile, |
| 38 | borderRadiusTopRightMobile, |
| 39 | borderRadiusBottomRightMobile, |
| 40 | borderRadiusBottomLeftMobile, |
| 41 | borderRadiusTopLeftMobile, |
| 42 | borderRadiusUnit, |
| 43 | iconPaddingTopMobile, |
| 44 | iconPaddingRightMobile, |
| 45 | iconPaddingBottomMobile, |
| 46 | iconPaddingLeftMobile, |
| 47 | iconPaddingUnit, |
| 48 | iconSizeMobile, |
| 49 | iconSizeUnit, |
| 50 | } = attributes; |
| 51 | |
| 52 | let selector = '.editor-styles-wrapper .gb-button-wrapper a.gb-button-' + uniqueId; |
| 53 | |
| 54 | if ( ! url ) { |
| 55 | selector = '.editor-styles-wrapper .gb-button-wrapper .gb-button-' + uniqueId; |
| 56 | } |
| 57 | |
| 58 | let cssObj = []; |
| 59 | |
| 60 | cssObj[ selector ] = [ { |
| 61 | 'padding-top': valueWithUnit( paddingTopMobile, paddingUnit ), |
| 62 | 'padding-right': valueWithUnit( paddingRightMobile, paddingUnit ), |
| 63 | 'padding-bottom': valueWithUnit( paddingBottomMobile, paddingUnit ), |
| 64 | 'padding-left': valueWithUnit( paddingLeftMobile, paddingUnit ), |
| 65 | 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftMobile, borderRadiusUnit ), |
| 66 | 'border-top-right-radius': valueWithUnit( borderRadiusTopRightMobile, borderRadiusUnit ), |
| 67 | 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightMobile, borderRadiusUnit ), |
| 68 | 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftMobile, borderRadiusUnit ), |
| 69 | 'font-size': valueWithUnit( fontSizeMobile, fontSizeUnit ), |
| 70 | 'letter-spacing': valueWithUnit( letterSpacingMobile, 'em' ), |
| 71 | 'margin-top': valueWithUnit( marginTopMobile, marginUnit ), |
| 72 | 'margin-right': valueWithUnit( marginRightMobile, marginUnit ), |
| 73 | 'margin-bottom': valueWithUnit( marginBottomMobile, marginUnit ), |
| 74 | 'margin-left': valueWithUnit( marginLeftMobile, marginUnit ), |
| 75 | } ]; |
| 76 | |
| 77 | if ( borderSizeTopMobile || borderSizeRightMobile || borderSizeBottomMobile || borderSizeLeftMobile ) { |
| 78 | cssObj[ selector ].push( { |
| 79 | 'border-top-width': valueWithUnit( borderSizeTopMobile, 'px' ), |
| 80 | 'border-right-width': valueWithUnit( borderSizeRightMobile, 'px' ), |
| 81 | 'border-bottom-width': valueWithUnit( borderSizeBottomMobile, 'px' ), |
| 82 | 'border-left-width': valueWithUnit( borderSizeLeftMobile, 'px' ), |
| 83 | 'border-style': 'solid', |
| 84 | } ); |
| 85 | } |
| 86 | |
| 87 | cssObj[ selector + ' .gb-icon' ] = [ { |
| 88 | 'padding-top': ! removeText ? valueWithUnit( iconPaddingTopMobile, iconPaddingUnit ) : false, |
| 89 | 'padding-right': ! removeText ? valueWithUnit( iconPaddingRightMobile, iconPaddingUnit ) : false, |
| 90 | 'padding-bottom': ! removeText ? valueWithUnit( iconPaddingBottomMobile, iconPaddingUnit ) : false, |
| 91 | 'padding-left': ! removeText ? valueWithUnit( iconPaddingLeftMobile, iconPaddingUnit ) : false, |
| 92 | 'font-size': valueWithUnit( iconSizeMobile, iconSizeUnit ), |
| 93 | } ]; |
| 94 | |
| 95 | cssObj = applyFilters( 'generateblocks.editor.mobileCSS', cssObj, this.props, 'button' ); |
| 96 | |
| 97 | return ( |
| 98 | <style>{ buildCSS( cssObj ) }</style> |
| 99 | ); |
| 100 | } |
| 101 | } |
| 102 | /* eslint-enable quotes */ |
| 103 |