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