-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:vektor-inc/vk-blocks-pro into fi…
…x/tab-labels-margin
- Loading branch information
Showing
14 changed files
with
1,002 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/blocks/_pro/outer/deprecated/save/1.93.0/GenerateBgImage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
const GenerateBgImage = (props) => { | ||
const { attributes, prefix } = props; | ||
const { bgImageMobile, bgImageTablet, bgImage, bgSize, blockId } = | ||
attributes; | ||
|
||
const mobileViewport = 'max-width: 575.98px'; | ||
const tabletViewport = 'min-width: 576px'; | ||
const pcViewport = 'min-width: 992px'; | ||
const underPcViewport = 'max-width: 992.98px'; | ||
|
||
let backgroundStyle; | ||
const backgroundPosition = 'background-position:center!important;'; | ||
if ('cover' === bgSize) { | ||
backgroundStyle = `background-size:${bgSize}!important; ${backgroundPosition}`; | ||
} else if ('repeat' === bgSize) { | ||
backgroundStyle = `background-repeat:${bgSize}!important; background-size: auto; ${backgroundPosition}`; | ||
} else { | ||
backgroundStyle = ``; | ||
} | ||
|
||
//moible only | ||
if (bgImageMobile && !bgImageTablet && !bgImage) { | ||
return ( | ||
<style>{`.${prefix}-${blockId}{background-image: url(${bgImageMobile}); ${backgroundStyle}}`}</style> | ||
); | ||
} | ||
//tablet only | ||
if (!bgImageMobile && bgImageTablet && !bgImage) { | ||
return ( | ||
<style>{`.${prefix}-${blockId}{background-image: url(${bgImageTablet}); ${backgroundStyle}}`}</style> | ||
); | ||
} | ||
//pc only | ||
if (!bgImageMobile && !bgImageTablet && bgImage) { | ||
return ( | ||
<style>{`.${prefix}-${blockId}{background-image: url(${bgImage}); ${backgroundStyle}}`}</style> | ||
); | ||
} | ||
//pc -mobile | ||
if (bgImageMobile && !bgImageTablet && bgImage) { | ||
return ( | ||
<style> | ||
{` | ||
@media screen and (${underPcViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImageMobile}); ${backgroundStyle}} | ||
} | ||
@media screen and (${pcViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImage}); ${backgroundStyle}} | ||
} | ||
`} | ||
</style> | ||
); | ||
} | ||
//pc -tablet | ||
if (!bgImageMobile && bgImageTablet && bgImage) { | ||
return ( | ||
<style> | ||
{` | ||
@media screen and (${underPcViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImageTablet}); ${backgroundStyle}} | ||
} | ||
@media screen and (${pcViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImage}); ${backgroundStyle}} | ||
} | ||
`} | ||
</style> | ||
); | ||
} | ||
//tablet - mobile | ||
if (bgImageMobile && bgImageTablet && !bgImage) { | ||
return ( | ||
<style> | ||
{` | ||
@media screen and (${mobileViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImageMobile}); ${backgroundStyle}} | ||
} | ||
@media screen and (${tabletViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImageTablet}); ${backgroundStyle}} | ||
} | ||
`} | ||
</style> | ||
); | ||
} | ||
//pc -tablet - mobile | ||
if (bgImageMobile && bgImageTablet && bgImage) { | ||
return ( | ||
<style> | ||
{` | ||
@media screen and (${mobileViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImageMobile}); ${backgroundStyle}} | ||
} | ||
@media screen and (${tabletViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImageTablet}); ${backgroundStyle}} | ||
} | ||
@media screen and (${pcViewport}) { | ||
.${prefix}-${blockId}{background-image: url(${bgImage}); ${backgroundStyle}} | ||
} | ||
`} | ||
</style> | ||
); | ||
} | ||
}; | ||
export default GenerateBgImage; |
Oops, something went wrong.