itmar-block-packages 1.3.11 → 1.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/build/index.asset.php +1 -1
- package/build/index.js +2 -2
- package/package.json +1 -1
- package/src/BlockPlace.js +91 -44
- package/src/cssPropertes.js +23 -3
package/package.json
CHANGED
package/src/BlockPlace.js
CHANGED
|
@@ -44,7 +44,7 @@ const vert_around = <Icon icon={justifySpaceBetween} className="rotate-icon" />;
|
|
|
44
44
|
|
|
45
45
|
export default function BlockPlace(props) {
|
|
46
46
|
const { attributes, clientId, blockRef, isMobile, isSubmenu } = props;
|
|
47
|
-
const { positionType, default_pos, mobile_pos } = attributes;
|
|
47
|
+
const { positionType, isPosCenter, default_pos, mobile_pos } = attributes;
|
|
48
48
|
|
|
49
49
|
//モバイルかデスクトップか
|
|
50
50
|
const sel_pos = isMobile ? mobile_pos : default_pos;
|
|
@@ -532,7 +532,19 @@ export default function BlockPlace(props) {
|
|
|
532
532
|
}}
|
|
533
533
|
/>
|
|
534
534
|
</div>
|
|
535
|
-
{
|
|
535
|
+
{positionType === "absolute" && (
|
|
536
|
+
<ToggleControl
|
|
537
|
+
label={__(
|
|
538
|
+
"Center Vertically and Horizontally",
|
|
539
|
+
"block-collections"
|
|
540
|
+
)}
|
|
541
|
+
checked={isPosCenter}
|
|
542
|
+
onChange={(newVal) => {
|
|
543
|
+
props.onIsPosCenterChange(newVal);
|
|
544
|
+
}}
|
|
545
|
+
/>
|
|
546
|
+
)}
|
|
547
|
+
{((positionType === "absolute" && !isPosCenter) ||
|
|
536
548
|
positionType === "fixed" ||
|
|
537
549
|
positionType === "sticky") && (
|
|
538
550
|
<>
|
|
@@ -541,62 +553,97 @@ export default function BlockPlace(props) {
|
|
|
541
553
|
) : (
|
|
542
554
|
<p>{__("Block Position(DeskTop)", "block-collections")}</p>
|
|
543
555
|
)}
|
|
544
|
-
<
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
vertBase
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
556
|
+
<PanelBody
|
|
557
|
+
title={__("Vertical", "block-collections")}
|
|
558
|
+
initialOpen={true}
|
|
559
|
+
>
|
|
560
|
+
{!sel_pos.posValue?.isVertCenter && (
|
|
561
|
+
<PanelRow className="position_row">
|
|
562
|
+
<ComboboxControl
|
|
563
|
+
options={[
|
|
564
|
+
{ value: "top", label: "Top" },
|
|
565
|
+
{ value: "bottom", label: "Bottom" },
|
|
566
|
+
]}
|
|
567
|
+
value={sel_pos.posValue?.vertBase || "top"}
|
|
568
|
+
onChange={(newValue) => {
|
|
569
|
+
const newValObj = {
|
|
570
|
+
...(sel_pos.posValue || {}),
|
|
571
|
+
vertBase: newValue,
|
|
572
|
+
};
|
|
573
|
+
props.onPosValueChange(newValObj);
|
|
574
|
+
}}
|
|
575
|
+
/>
|
|
576
|
+
<UnitControl
|
|
577
|
+
dragDirection="e"
|
|
578
|
+
onChange={(newValue) => {
|
|
579
|
+
const newValObj = {
|
|
580
|
+
...(sel_pos.posValue || {}),
|
|
581
|
+
vertValue: newValue,
|
|
582
|
+
};
|
|
583
|
+
props.onPosValueChange(newValObj);
|
|
584
|
+
}}
|
|
585
|
+
value={sel_pos.posValue?.vertValue || "3em"}
|
|
586
|
+
/>
|
|
587
|
+
</PanelRow>
|
|
588
|
+
)}
|
|
589
|
+
<ToggleControl
|
|
590
|
+
label={__("Is Center", "block-collections")}
|
|
591
|
+
checked={sel_pos.posValue?.isVertCenter}
|
|
580
592
|
onChange={(newValue) => {
|
|
581
593
|
const newValObj = {
|
|
582
594
|
...(sel_pos.posValue || {}),
|
|
583
|
-
|
|
595
|
+
isVertCenter: newValue,
|
|
584
596
|
};
|
|
585
597
|
props.onPosValueChange(newValObj);
|
|
586
598
|
}}
|
|
587
599
|
/>
|
|
588
|
-
|
|
589
|
-
|
|
600
|
+
</PanelBody>
|
|
601
|
+
|
|
602
|
+
<PanelBody
|
|
603
|
+
title={__("Horizon", "block-collections")}
|
|
604
|
+
initialOpen={true}
|
|
605
|
+
>
|
|
606
|
+
{!sel_pos.posValue?.isHorCenter && (
|
|
607
|
+
<PanelRow className="position_row">
|
|
608
|
+
<ComboboxControl
|
|
609
|
+
options={[
|
|
610
|
+
{ value: "left", label: "Left" },
|
|
611
|
+
{ value: "right", label: "Right" },
|
|
612
|
+
]}
|
|
613
|
+
value={sel_pos.posValue?.horBase || "left"}
|
|
614
|
+
onChange={(newValue) => {
|
|
615
|
+
const newValObj = {
|
|
616
|
+
...(sel_pos.posValue || {}),
|
|
617
|
+
horBase: newValue,
|
|
618
|
+
};
|
|
619
|
+
props.onPosValueChange(newValObj);
|
|
620
|
+
}}
|
|
621
|
+
/>
|
|
622
|
+
<UnitControl
|
|
623
|
+
dragDirection="e"
|
|
624
|
+
onChange={(newValue) => {
|
|
625
|
+
const newValObj = {
|
|
626
|
+
...(sel_pos.posValue || {}),
|
|
627
|
+
horValue: newValue,
|
|
628
|
+
};
|
|
629
|
+
props.onPosValueChange(newValObj);
|
|
630
|
+
}}
|
|
631
|
+
value={sel_pos.posValue?.horValue || "3em"}
|
|
632
|
+
/>
|
|
633
|
+
</PanelRow>
|
|
634
|
+
)}
|
|
635
|
+
<ToggleControl
|
|
636
|
+
label={__("Is Center", "block-collections")}
|
|
637
|
+
checked={sel_pos.posValue?.isHorCenter}
|
|
590
638
|
onChange={(newValue) => {
|
|
591
639
|
const newValObj = {
|
|
592
640
|
...(sel_pos.posValue || {}),
|
|
593
|
-
|
|
641
|
+
isHorCenter: newValue,
|
|
594
642
|
};
|
|
595
643
|
props.onPosValueChange(newValObj);
|
|
596
644
|
}}
|
|
597
|
-
value={sel_pos.posValue?.horValue || "3em"}
|
|
598
645
|
/>
|
|
599
|
-
</
|
|
646
|
+
</PanelBody>
|
|
600
647
|
</>
|
|
601
648
|
)}
|
|
602
649
|
</PanelBody>
|
package/src/cssPropertes.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
const capitalizeFirstLetter = (string) => {
|
|
3
3
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
4
4
|
};
|
|
5
|
+
// objectかどうか判定する関数
|
|
6
|
+
const isObject = (value) => {
|
|
7
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8
|
+
};
|
|
5
9
|
|
|
6
10
|
//角丸のパラメータを返す
|
|
7
11
|
export const radius_prm = (radius) => {
|
|
@@ -24,14 +28,26 @@ export const space_prm = (space) => {
|
|
|
24
28
|
};
|
|
25
29
|
//positionのオブジェクトを返します
|
|
26
30
|
export const position_prm = (pos, type) => {
|
|
27
|
-
|
|
31
|
+
//値でポジションを設定
|
|
32
|
+
if (isObject(pos)) {
|
|
28
33
|
const resetVertBase = pos.vertBase === "top" ? "bottom" : "top";
|
|
29
34
|
const resetHorBase = pos.horBase === "left" ? "right" : "left";
|
|
35
|
+
const centerVert = "50%";
|
|
36
|
+
const centerHor = "50%";
|
|
37
|
+
const centerTrans =
|
|
38
|
+
pos.isVertCenter && pos.isHorCenter
|
|
39
|
+
? "transform: translate(-50%, -50%);"
|
|
40
|
+
: pos.isVertCenter
|
|
41
|
+
? "transform: translateY(-50%);"
|
|
42
|
+
: pos.isHorCenter
|
|
43
|
+
? "transform: translateX(-50%);"
|
|
44
|
+
: null;
|
|
30
45
|
const ret_pos_prm =
|
|
31
46
|
pos && (type === "absolute" || type === "fixed" || type === "sticky")
|
|
32
47
|
? `
|
|
33
|
-
${pos.vertBase}: ${pos.vertValue};
|
|
34
|
-
${pos.horBase}: ${pos.horValue};
|
|
48
|
+
${pos.vertBase}: ${pos.isVertCenter ? centerVert : pos.vertValue};
|
|
49
|
+
${pos.horBase}: ${pos.isHorCenter ? centerHor : pos.horValue};
|
|
50
|
+
${centerTrans}
|
|
35
51
|
${resetVertBase}: auto;
|
|
36
52
|
${resetHorBase}: auto;
|
|
37
53
|
${
|
|
@@ -42,6 +58,10 @@ export const position_prm = (pos, type) => {
|
|
|
42
58
|
`
|
|
43
59
|
: "";
|
|
44
60
|
return ret_pos_prm;
|
|
61
|
+
//縦横中央揃え
|
|
62
|
+
} else if (pos) {
|
|
63
|
+
const ret_pos_prm = "top:50%;left: 50%;transform: translate(-50%, -50%);";
|
|
64
|
+
return ret_pos_prm;
|
|
45
65
|
}
|
|
46
66
|
return null;
|
|
47
67
|
};
|