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
mobile.js
69 lines
| 1 | import buildCSS from '../../../utils/build-css'; |
| 2 | import LayoutCSS from '../../../extend/inspector-control/controls/layout/components/LayoutCSS'; |
| 3 | import FlexChildCSS from '../../../extend/inspector-control/controls/flex-child-panel/components/FlexChildCSS'; |
| 4 | import SizingCSS from '../../../extend/inspector-control/controls/sizing/components/SizingCSS'; |
| 5 | import SpacingCSS from '../../../extend/inspector-control/controls/spacing/components/SpacingCSS'; |
| 6 | import TypographyCSS from '../../../extend/inspector-control/controls/typography/components/TypographyCSS'; |
| 7 | import BorderCSS from '../../../extend/inspector-control/controls/borders/BorderCSS'; |
| 8 | |
| 9 | import { |
| 10 | Component, |
| 11 | } from '@wordpress/element'; |
| 12 | |
| 13 | import { |
| 14 | applyFilters, |
| 15 | } from '@wordpress/hooks'; |
| 16 | |
| 17 | export default class MobileCSS extends Component { |
| 18 | render() { |
| 19 | const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props ); |
| 20 | |
| 21 | const { |
| 22 | clientId, |
| 23 | } = this.props; |
| 24 | |
| 25 | const { |
| 26 | uniqueId, |
| 27 | element, |
| 28 | removeText, |
| 29 | displayMobile, |
| 30 | inlineWidthMobile, |
| 31 | iconStyles, |
| 32 | } = attributes; |
| 33 | |
| 34 | const selector = element + '.gb-headline-' + uniqueId; |
| 35 | let cssObj = []; |
| 36 | |
| 37 | TypographyCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes.typography, 'Mobile' ); |
| 38 | SpacingCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes.spacing, 'Mobile' ); |
| 39 | BorderCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes.borders, 'Mobile' ); |
| 40 | LayoutCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes, 'Mobile' ); |
| 41 | SizingCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes, 'Mobile' ); |
| 42 | FlexChildCSS( cssObj, '.editor-styles-wrapper ' + selector, attributes, 'Mobile' ); |
| 43 | |
| 44 | cssObj[ selector + ' .gb-icon' ] = [ { |
| 45 | 'padding-top': ! removeText ? iconStyles?.paddingTopMobile : null, |
| 46 | 'padding-right': ! removeText ? iconStyles?.paddingRightMobile : null, |
| 47 | 'padding-bottom': ! removeText ? iconStyles?.paddingBottomMobile : null, |
| 48 | 'padding-left': ! removeText ? iconStyles?.paddingLeftMobile : null, |
| 49 | } ]; |
| 50 | |
| 51 | cssObj[ selector + ' .gb-icon svg' ] = [ { |
| 52 | width: iconStyles?.widthMobile, |
| 53 | height: iconStyles?.heightMobile, |
| 54 | } ]; |
| 55 | |
| 56 | if ( inlineWidthMobile ) { |
| 57 | cssObj[ '.gb-is-root-block[data-block="' + clientId + '"]' ] = [ { |
| 58 | display: displayMobile, |
| 59 | } ]; |
| 60 | } |
| 61 | |
| 62 | cssObj = applyFilters( 'generateblocks.editor.mobileCSS', cssObj, this.props, 'headline' ); |
| 63 | |
| 64 | return ( |
| 65 | <style>{ buildCSS( cssObj ) }</style> |
| 66 | ); |
| 67 | } |
| 68 | } |
| 69 |