deprecated
2 months ago
advanced-spacer-control.js
2 months ago
block.json
2 days ago
edit.js
2 weeks ago
icon.svg
2 months ago
index.js
2 months ago
index.php
2 months ago
save.js
2 months ago
spacers.js
2 months ago
style.scss
2 months ago
transforms.js
2 months ago
spacers.js
88 lines
| 1 | // Spacers |
| 2 | |
| 3 | const Spacer = ({ style, viewPort }) => { |
| 4 | return <div className={`vk_spacer-display-${viewPort}`} style={style} />; |
| 5 | }; |
| 6 | |
| 7 | export default function Spacers({ |
| 8 | spaceSize, |
| 9 | type, |
| 10 | pcSize, |
| 11 | tabletSize, |
| 12 | mobileSize, |
| 13 | unit, |
| 14 | }) { |
| 15 | const SPACE_SIZE_CLASSNAMES = { |
| 16 | xxs: 'vk_block-margin-xxs', |
| 17 | xs: 'vk_block-margin-xs', |
| 18 | small: 'vk_block-margin-sm', |
| 19 | medium: 'vk_block-margin-md', |
| 20 | large: 'vk_block-margin-lg', |
| 21 | xl: 'vk_block-margin-xl', |
| 22 | xxl: 'vk_block-margin-xxl', |
| 23 | }; |
| 24 | |
| 25 | if (spaceSize !== undefined && SPACE_SIZE_CLASSNAMES[spaceSize]) { |
| 26 | if (type === 'margin-top') { |
| 27 | return ( |
| 28 | <div |
| 29 | className={ |
| 30 | SPACE_SIZE_CLASSNAMES[spaceSize] + '--margin-top' |
| 31 | } |
| 32 | /> |
| 33 | ); |
| 34 | } else if (type === 'margin-bottom') { |
| 35 | return ( |
| 36 | <div |
| 37 | className={ |
| 38 | SPACE_SIZE_CLASSNAMES[spaceSize] + '--margin-bottom' |
| 39 | } |
| 40 | /> |
| 41 | ); |
| 42 | } |
| 43 | return ( |
| 44 | <div className={SPACE_SIZE_CLASSNAMES[spaceSize] + '--height'} /> |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | if (type === 'margin-top') { |
| 49 | return ( |
| 50 | <> |
| 51 | <Spacer viewPort={'pc'} style={{ marginTop: pcSize + unit }} /> |
| 52 | <Spacer |
| 53 | viewPort={'tablet'} |
| 54 | style={{ marginTop: tabletSize + unit }} |
| 55 | /> |
| 56 | <Spacer |
| 57 | viewPort={'mobile'} |
| 58 | style={{ marginTop: mobileSize + unit }} |
| 59 | /> |
| 60 | </> |
| 61 | ); |
| 62 | } else if (type === 'margin-bottom') { |
| 63 | return ( |
| 64 | <> |
| 65 | <Spacer |
| 66 | viewPort={'pc'} |
| 67 | style={{ marginBottom: pcSize + unit }} |
| 68 | /> |
| 69 | <Spacer |
| 70 | viewPort={'tablet'} |
| 71 | style={{ marginBottom: tabletSize + unit }} |
| 72 | /> |
| 73 | <Spacer |
| 74 | viewPort={'mobile'} |
| 75 | style={{ marginBottom: mobileSize + unit }} |
| 76 | /> |
| 77 | </> |
| 78 | ); |
| 79 | } |
| 80 | return ( |
| 81 | <> |
| 82 | <Spacer viewPort={'pc'} style={{ height: pcSize + unit }} /> |
| 83 | <Spacer viewPort={'tablet'} style={{ height: tabletSize + unit }} /> |
| 84 | <Spacer viewPort={'mobile'} style={{ height: mobileSize + unit }} /> |
| 85 | </> |
| 86 | ); |
| 87 | } |
| 88 |