Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【outerのリンク設定が配信されるまで一旦draft/確認中】[ Outer ] 背景画像に焦点ピッカー追加 #2255

Draft
wants to merge 56 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
33f74d3
Add FocalPointPicker
mtdkei Aug 7, 2024
acef91f
Add bgFocalPoint
mtdkei Aug 7, 2024
f3f297e
Add FocalPointPicker
mtdkei Aug 7, 2024
785abb6
Add bgFocalPoint
mtdkei Aug 7, 2024
80d7fdc
Revert edit.js to develop state
Aug 13, 2024
5c19b87
Fix: Update background position in real-time during FocalPointPicker …
mtdkei Oct 4, 2024
7eaeb64
Fix: blockProps
Oct 4, 2024
fa8514b
Fix: blockRef
Oct 4, 2024
88a22a2
Undo code
Oct 4, 2024
c4bc7d9
Undo commentout
Oct 4, 2024
bb7df81
Add test file
Oct 4, 2024
fd7116b
Add deprecated file ver.1.85.1
Oct 4, 2024
c4251ec
Merge branch 'develop' into add/outer/focal-point-picker
Oct 4, 2024
1f55f83
Update readme.txt
mtdkei Oct 4, 2024
8dabd59
Merge develo@
Oct 4, 2024
511353a
Fix: label
Oct 4, 2024
711b4d1
Add tablet and mobile setting for bgFocalPoint
Oct 4, 2024
d563fb0
Fix: build
Oct 4, 2024
a8fd083
Add test file
Oct 4, 2024
5771f46
Merge develop gile
Oct 4, 2024
3ecfea4
Fix: Ensure default focal point values for undefined background settings
Oct 4, 2024
1088f11
Fix: lint
Oct 4, 2024
607bc7e
Fix: label
mtdkei Oct 5, 2024
d9be9b2
Fix: label
mtdkei Oct 5, 2024
1a85c79
Enhancement: Real-time background position update on FocalPoint change
Oct 5, 2024
b0ea3b7
Build
Oct 6, 2024
931605f
Merge branch 'develop' into add/outer/focal-point-picker
mtdkei Oct 7, 2024
479d214
Fix: real-time focus
Oct 7, 2024
9cd6acc
Merge branch 'develop' into add/outer/focal-point-picker
mtdkei Oct 7, 2024
5fa1b0f
Fix: build
Oct 7, 2024
adf869e
Merge branch 'develop' into add/outer/focal-point-picker
mtdkei Oct 8, 2024
36e0be5
Merge branch 'develop' into add/outer/focal-point-picker
mtdkei Oct 9, 2024
6b3ed30
Resolve merge conflict
Oct 9, 2024
98129a9
Resolve merge conflict
Oct 9, 2024
4c9f479
Add focalpoint setting for mulch devise
Oct 9, 2024
5d3822e
Add attrubutes
Oct 9, 2024
a840569
Fix: Togglecontrol
Oct 9, 2024
4afe200
lint
Oct 9, 2024
24a3481
Delete Duplicate Code
Oct 9, 2024
543fd16
Fix: focal toggle setting
Oct 9, 2024
71f7726
Fix: focal toggle setting
Oct 9, 2024
38ee5e4
Add attributes
Oct 9, 2024
4df7c7c
Merge branch 'develop' into add/outer/focal-point-picker
mtdkei Oct 17, 2024
b0748f1
Merge branch 'develop' into add/outer/focal-point-picker
mtdkei Oct 24, 2024
148de05
Fix: background-position for tablet only
mtdkei Oct 24, 2024
69fb903
Merge branch 'develop' into add/outer/focal-point-picker
mtdkei Oct 25, 2024
1cfe60d
Merge branch 'develop' into add/outer/focal-point-picker
mtdkei Nov 19, 2024
31c69d0
Add ver1.90.1
Nov 19, 2024
65a2935
Delete ver1.85.1
Nov 19, 2024
0f29d32
Add ver1.90.1
Nov 19, 2024
6095dac
Fix: outer default files
Nov 19, 2024
418f291
Delete test/e2e-tests/fixtures/blocks/vk-blocks__outer__deprecated-1-…
mtdkei Nov 19, 2024
163d6b1
Delete test/e2e-tests/fixtures/blocks/vk-blocks__outer__divider__depr…
mtdkei Nov 19, 2024
dd666b2
Fix: text
mtdkei Nov 19, 2024
c2b33bf
Fix: outer default files
Nov 19, 2024
26a91f2
Update vk-blocks__outer__divider.html
mtdkei Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ e.g.

== Changelog ==

[ Add function ][ Outer (Pro) ] Added the ability to set a focal point for background images.

= 1.88.0 =
[ Specification change ][ Grid Column Card (Pro) ] Changed the default settings of headerDisplay and footerDisplay from "Delete" to "Display".
[ Specification change ] Add filter vk_post_taxonomies_html ( Update VK Components 1.6.1 )
[ Bug fix ][ Link Component ] Fix adding "http://" with "tel:" and "mailto:" link.
[ Bug fix ][ Slider ] Fix an issue where full width alignment does not work in tt4 and tt5.

= 1.87.0 =
[ Add function ][ Link Toolbar ] Added to skip retrieving metadata (title and favicon) for external links in link toolbar to prevent CORS errors.
[ Add function ][ icon ] Add toolbar link for components.
[ Bug fix ][ Link Toolbar ] Added to skip retrieving metadata (title and favicon) for external links in link toolbar to prevent CORS errors.
[ Bug fix ][ Slider ] Adjusting the timing of loading swiper to prevent the slider from collapsing.
[ Bug fix ][ Grid Column Card (Pro) ] Add translation.
[ Bug fix ][ Category Badge (Pro) ] Added Pro label to the inserter.
Expand Down
216 changes: 174 additions & 42 deletions src/blocks/_pro/outer/GenerateBgImage.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,235 @@
const GenerateBgImage = (props) => {
const { attributes, prefix } = props;
const { bgImageMobile, bgImageTablet, bgImage, bgSize, blockId } =
attributes;
const {
bgImageMobile,
bgImageTablet,
bgImage,
bgFocalPointPC,
bgFocalPointTablet,
bgFocalPointMobile,
bgSize,
blockId,
enableFocalPointPC,
enableFocalPointTablet,
enableFocalPointMobile,
} = attributes;

const mobileViewport = 'max-width: 575.98px';
const tabletViewport = 'min-width: 576px';
const pcViewport = 'min-width: 992px';
const underPcViewport = 'max-width: 992.98px';
// const underPcViewport = 'max-width: 992.98px'; FocalPoint設定のためにコメントアウト

// 背景位置の変換関数
const coordsToBackgroundPosition = (focalPoint) => {
if (!focalPoint || (isNaN(focalPoint.x) && isNaN(focalPoint.y))) {
return '50% 50%';
}
const x = isNaN(focalPoint.x) ? 0.5 : focalPoint.x;
const y = isNaN(focalPoint.y) ? 0.5 : focalPoint.y;
return `${x * 100}% ${y * 100}%`;
};

const defaultFocalPoint = { x: 0.5, y: 0.5 };
const getFocalPoint = (focalPoint, fallback) => focalPoint || fallback;

const focalPointPC = enableFocalPointPC
? getFocalPoint(bgFocalPointPC, defaultFocalPoint)
: defaultFocalPoint;

const focalPointTablet = enableFocalPointTablet
? getFocalPoint(bgFocalPointTablet, focalPointPC)
: focalPointPC;

const focalPointMobile = enableFocalPointMobile
? getFocalPoint(bgFocalPointMobile, focalPointTablet, focalPointPC)
: getFocalPoint(focalPointTablet, focalPointPC);

let backgroundStyle;
const backgroundPosition = 'background-position:center!important;';
if ('cover' === bgSize) {
backgroundStyle = `background-size:${bgSize}!important; ${backgroundPosition}`;
backgroundStyle = `background-size:${bgSize}!important;`;
} else if ('repeat' === bgSize) {
backgroundStyle = `background-repeat:${bgSize}!important; background-size: auto; ${backgroundPosition}`;
backgroundStyle = `background-repeat:${bgSize}!important; background-size: auto;`;
} else {
backgroundStyle = ``;
}

//moible only
// モバイルのみ
if (bgImageMobile && !bgImageTablet && !bgImage) {
return (
<style>{`.${prefix}-${blockId}{background-image: url(${bgImageMobile}); ${backgroundStyle}}`}</style>
<style>
{`
.${prefix}-${blockId} {
background-image: url(${bgImageMobile}) !important;
background-position: ${coordsToBackgroundPosition(focalPointMobile)}!important;
${backgroundStyle}
}
`}
</style>
);
}
//tablet only
// タブレットのみ
if (!bgImageMobile && bgImageTablet && !bgImage) {
return (
<style>{`.${prefix}-${blockId}{background-image: url(${bgImageTablet}); ${backgroundStyle}}`}</style>
<style>
{`
.${prefix}-${blockId} {
background-image: url(${bgImageTablet}) !important;
background-position: ${coordsToBackgroundPosition(focalPointTablet)}!important;
${backgroundStyle}
}
@media screen and (${mobileViewport}) {
.${prefix}-${blockId} {
background-position: ${coordsToBackgroundPosition(focalPointMobile)}!important;
${backgroundStyle}
}
}
`}
</style>
);
}
//pc only
// PCのみ
if (!bgImageMobile && !bgImageTablet && bgImage) {
return (
<style>{`.${prefix}-${blockId}{background-image: url(${bgImage}); ${backgroundStyle}}`}</style>
<style>
{`
.${prefix}-${blockId} {
background-image: url(${bgImage}) !important;
${backgroundStyle}
}
@media screen and (${mobileViewport}) {
.${prefix}-${blockId} {
background-position: ${coordsToBackgroundPosition(focalPointMobile)}!important;
${backgroundStyle}
}
}
@media screen and (${tabletViewport}) {
.${prefix}-${blockId} {
background-position: ${coordsToBackgroundPosition(focalPointTablet)}!important;
${backgroundStyle}
}
}
@media screen and (${pcViewport}) {
.${prefix}-${blockId} {
background-position: ${coordsToBackgroundPosition(focalPointPC)}!important;
${backgroundStyle}
}
}
`}
</style>
);
}
//pc -mobile
// PCとモバイル
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}}
}
`}
@media screen and (${mobileViewport}) {
.${prefix}-${blockId} {
background-image: url(${bgImageMobile}) !important;
background-position: ${coordsToBackgroundPosition(focalPointMobile)}!important;
${backgroundStyle}
}
}
@media screen and (${tabletViewport}) {
.${prefix}-${blockId} {
background-position: ${coordsToBackgroundPosition(focalPointTablet)}!important;
${backgroundStyle}
}
}
@media screen and (${pcViewport}) {
.${prefix}-${blockId} {
background-image: url(${bgImage}) !important;
background-position: ${coordsToBackgroundPosition(focalPointPC)}!important;
${backgroundStyle}
}
}
`}
</style>
);
}
//pc -tablet
// PCとタブレット
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}}
}
`}
@media screen and (${mobileViewport}) {
.${prefix}-${blockId} {
background-image: url(${bgImageTablet}) !important;
background-position: ${coordsToBackgroundPosition(focalPointMobile)}!important;
${backgroundStyle}
}
}
@media screen and (${tabletViewport}) {
.${prefix}-${blockId} {
background-image: url(${bgImageTablet}) !important;
background-position: ${coordsToBackgroundPosition(focalPointTablet)}!important;
${backgroundStyle}
}
}
@media screen and (${pcViewport}) {
.${prefix}-${blockId} {
background-image: url(${bgImage}) !important;
background-position: ${coordsToBackgroundPosition(focalPointPC)}!important;
${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}}
}
@media screen and (${mobileViewport}) {
.${prefix}-${blockId} {
background-image: url(${bgImageMobile}) !important;
background-position: ${coordsToBackgroundPosition(focalPointMobile)}!important;
${backgroundStyle}
}
}
@media screen and (${tabletViewport}) {
.${prefix}-${blockId} {
background-image: url(${bgImageTablet}) !important;
background-position: ${coordsToBackgroundPosition(focalPointTablet)}!important;
${backgroundStyle}
}
}
`}
</style>
);
}
//pc -tablet - mobile
// PC、タブレット、モバイル
if (bgImageMobile && bgImageTablet && bgImage) {
return (
<style>
{`
@media screen and (${mobileViewport}) {
.${prefix}-${blockId}{background-image: url(${bgImageMobile}); ${backgroundStyle}}
}
.${prefix}-${blockId} {
background-image: url(${bgImageMobile}) !important;
background-position: ${coordsToBackgroundPosition(focalPointMobile)}!important;
${backgroundStyle}
}
}
@media screen and (${tabletViewport}) {
.${prefix}-${blockId}{background-image: url(${bgImageTablet}); ${backgroundStyle}}
}
.${prefix}-${blockId} {
background-image: url(${bgImageTablet}) !important;
background-position: ${coordsToBackgroundPosition(focalPointTablet)}!important;
${backgroundStyle}
}
}
@media screen and (${pcViewport}) {
.${prefix}-${blockId}{background-image: url(${bgImage}); ${backgroundStyle}}
}
.${prefix}-${blockId} {
background-image: url(${bgImage}) !important;
background-position: ${coordsToBackgroundPosition(focalPointPC)}!important;
${backgroundStyle}
}
}
`}
</style>
);
}
};

export default GenerateBgImage;
24 changes: 24 additions & 0 deletions src/blocks/_pro/outer/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@
"type": "string",
"default": "normal"
},
"bgFocalPointPC": {
"type": "object",
"default": { "x": 0.5, "y": 0.5 }
},
"bgFocalPointTablet": {
"type": "object",
"default": { "x": 0.5, "y": 0.5 }
},
"bgFocalPointMobile": {
"type": "object",
"default": { "x": 0.5, "y": 0.5 }
},
"enableFocalPointPC": {
"type": "boolean",
"default": false
},
"enableFocalPointTablet": {
"type": "boolean",
"default": false
},
"enableFocalPointMobile": {
"type": "boolean",
"default": false
},
"padding_left_and_right": {
"type": "string",
"default": "0"
Expand Down
1 change: 1 addition & 0 deletions src/blocks/_pro/outer/deprecated/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import OuterHook0_0_1 from './0.0.1'
// saveの数分必要
export default [
// 後方互換
OuterHook1_60_0, // 1.85.1
OuterHook1_60_0, // 1.76.0
OuterHook1_60_0, // 1.71.0
OuterHook1_60_0, // 1.64.0
Expand Down
Loading
Loading