| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { Toggle, SPRangeControl, SelectField, Layouts, InputControl } from "../../components"; |
| 3 |
import { AlignCenter, AlignLeft, AlignRight } from "../../icons/icons"; |
| 4 |
import { getPaginationBlock } from "../shared/helpFn"; |
| 5 |
import useLayouts from "../../hooks/useLayouts"; |
| 6 |
import { openLinksOptions } from "../../controls/constants"; |
| 7 |
import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl"; |
| 8 |
import ProInfo from "../../components/proInfo/proInfo"; |
| 9 |
|
| 10 |
export const GridFourGeneralTab = ({ attributes, setAttributes }) => { |
| 11 |
const { |
| 12 |
postGridLayout, |
| 13 |
gridFourColumns, |
| 14 |
itemsPerPage, |
| 15 |
gridFourHorizontalGap, |
| 16 |
gridFourVerticalGap, |
| 17 |
contentAlignment, |
| 18 |
// gridFourMasonryEnable, |
| 19 |
preloaderEnable, |
| 20 |
blockName, |
| 21 |
generalLinkOpen, |
| 22 |
// masonryGap, |
| 23 |
smallItemHeight, |
| 24 |
largeItemHeight, |
| 25 |
postLimit, |
| 26 |
metaDisplayType, |
| 27 |
paginationEnable, |
| 28 |
liveFilterEnable, |
| 29 |
clientId, |
| 30 |
} = attributes; |
| 31 |
const layouts = useLayouts(blockName, postGridLayout); |
| 32 |
|
| 33 |
const paginationBlock = getPaginationBlock(clientId); |
| 34 |
|
| 35 |
const paginationToggle = (newValue) => { |
| 36 |
setAttributes({ paginationEnable: !newValue }); |
| 37 |
|
| 38 |
if (!newValue && paginationBlock) { |
| 39 |
const { block, select } = paginationBlock; |
| 40 |
select(block?.clientId); |
| 41 |
} |
| 42 |
}; |
| 43 |
|
| 44 |
return ( |
| 45 |
<> |
| 46 |
{layouts?.length > 0 && ( |
| 47 |
<Layouts |
| 48 |
label={__("Grid Layout", "post-carousel")} |
| 49 |
attributes={postGridLayout} |
| 50 |
attributesKey={"postGridLayout"} |
| 51 |
setAttributes={setAttributes} |
| 52 |
displayActive={true} |
| 53 |
showDemoTitle={true} |
| 54 |
grid={3} |
| 55 |
items={layouts} |
| 56 |
/> |
| 57 |
)} |
| 58 |
<Toggle |
| 59 |
label={__("Smart Frontend Filter", "post-carousel")} |
| 60 |
attributes={liveFilterEnable} |
| 61 |
setAttributes={setAttributes} |
| 62 |
attributesKey={"liveFilterEnable"} |
| 63 |
/> |
| 64 |
<Toggle |
| 65 |
label={__("Smart Pagination", "post-carousel")} |
| 66 |
attributes={paginationEnable} |
| 67 |
// attributesKey={ 'paginationEnable' } |
| 68 |
// setAttributes={ setAttributes } |
| 69 |
onChange={paginationToggle} |
| 70 |
/> |
| 71 |
<SPRangeControl |
| 72 |
label={__("Columns", "post-carousel")} |
| 73 |
attributes={gridFourColumns} |
| 74 |
attributesKey={"gridFourColumns"} |
| 75 |
setAttributes={setAttributes} |
| 76 |
max={9} |
| 77 |
min={1} |
| 78 |
defaultValue={{ unit: "", value: 3 }} |
| 79 |
/> |
| 80 |
<InputControl |
| 81 |
label={__("Posts Per Page", "post-carousel")} |
| 82 |
className="sp-smart-limit-field" |
| 83 |
ajax={true} |
| 84 |
attributes={postLimit} |
| 85 |
min={1} |
| 86 |
max={500} |
| 87 |
attributesKey={"postLimit"} |
| 88 |
setAttributes={setAttributes} |
| 89 |
/> |
| 90 |
<SPRangeControl |
| 91 |
label={__("Large item Height", "post-carousel")} |
| 92 |
attributes={largeItemHeight} |
| 93 |
attributesKey={"largeItemHeight"} |
| 94 |
setAttributes={setAttributes} |
| 95 |
max={2000} |
| 96 |
units={["PX", "%", "EM"]} |
| 97 |
defaultValue={{ unit: "px", value: "" }} |
| 98 |
pro={true} |
| 99 |
/> |
| 100 |
<SPRangeControl |
| 101 |
label={__("Small item Height", "post-carousel")} |
| 102 |
attributes={smallItemHeight} |
| 103 |
attributesKey={"smallItemHeight"} |
| 104 |
setAttributes={setAttributes} |
| 105 |
max={2000} |
| 106 |
units={["PX", "%", "EM"]} |
| 107 |
defaultValue={{ unit: "px", value: 275 }} |
| 108 |
pro={true} |
| 109 |
/> |
| 110 |
<SPRangeControl |
| 111 |
label={__("Horizontal Gap", "post-carousel")} |
| 112 |
attributes={gridFourHorizontalGap} |
| 113 |
attributesKey={"gridFourHorizontalGap"} |
| 114 |
setAttributes={setAttributes} |
| 115 |
max={150} |
| 116 |
units={["PX", "%", "EM"]} |
| 117 |
defaultValue={{ unit: "px", value: 12 }} |
| 118 |
/> |
| 119 |
<SPRangeControl |
| 120 |
label={__("Vertical Gap", "post-carousel")} |
| 121 |
attributes={gridFourVerticalGap} |
| 122 |
attributesKey={"gridFourVerticalGap"} |
| 123 |
setAttributes={setAttributes} |
| 124 |
max={150} |
| 125 |
units={["PX", "%", "EM"]} |
| 126 |
defaultValue={{ unit: "px", value: 12 }} |
| 127 |
/> |
| 128 |
{/* { gridFourMasonryEnable && ( |
| 129 |
<SPRangeControl |
| 130 |
label={ __( 'Masonry Gap', 'post-carousel' ) } |
| 131 |
attributes={ masonryGap } |
| 132 |
attributesKey={ 'masonryGap' } |
| 133 |
setAttributes={ setAttributes } |
| 134 |
max={ 150 } |
| 135 |
units={ [ 'PX', '%', 'EM' ] } |
| 136 |
/> |
| 137 |
) } */} |
| 138 |
<SPToggleGroupControl |
| 139 |
label={__("Content Alignment", "post-carousel")} |
| 140 |
attributes={contentAlignment} |
| 141 |
attributesKey={"contentAlignment"} |
| 142 |
setAttributes={setAttributes} |
| 143 |
items={[ |
| 144 |
{ label: <AlignLeft />, value: "left" }, |
| 145 |
{ label: <AlignCenter />, value: "center" }, |
| 146 |
{ label: <AlignRight />, value: "right" }, |
| 147 |
]} |
| 148 |
/> |
| 149 |
<SelectField |
| 150 |
label={__("Link Open In", "post-carousel")} |
| 151 |
attributes={generalLinkOpen} |
| 152 |
attributesKey={"generalLinkOpen"} |
| 153 |
setAttributes={setAttributes} |
| 154 |
items={openLinksOptions} |
| 155 |
/> |
| 156 |
{/* <Toggle |
| 157 |
label={ __( 'Masonry', 'post-carousel' ) } |
| 158 |
attributes={ gridFourMasonryEnable ) } |
| 159 |
attributesKey={ 'gridFourMasonryEnable' } |
| 160 |
setAttributes={ setAttributes } |
| 161 |
/> */} |
| 162 |
<Toggle |
| 163 |
label={__("Preloader", "post-carousel")} |
| 164 |
attributes={preloaderEnable} |
| 165 |
attributesKey={"preloaderEnable"} |
| 166 |
setAttributes={setAttributes} |
| 167 |
/> |
| 168 |
<ProInfo> |
| 169 |
<span>Unlock exclusive layouts and advanced display controls.</span> <a href="https://wpsmartpost.com/pricing/?ref=1" target="_blank" rel="noopener noreferrer">Upgrade to Pro!</a> |
| 170 |
</ProInfo> |
| 171 |
</> |
| 172 |
); |
| 173 |
}; |
| 174 |
|