| 1 |
import { |
| 2 |
taxonomyModuleIcon, |
| 3 |
shortcodeModuleIcon, |
| 4 |
webBuilderModuleIcon, |
| 5 |
templateLibraryModuleIcon, |
| 6 |
saveTemplateModuleIcon, |
| 7 |
dynamicDataFieldModuleIcon, |
| 8 |
frontPostSubmissionModuleIcon, |
| 9 |
readingScrollModuleIcon, |
| 10 |
postImageGalleryModuleIcon, |
| 11 |
postFeaturedVideoModuleIcon, |
| 12 |
postBadgesModuleIcon, |
| 13 |
StarterSitesModuleIcon, |
| 14 |
BackToTopModuleIcon, |
| 15 |
} from "../template-parts/icons"; |
| 16 |
import ModulesCard from "../template-parts/modules"; |
| 17 |
import { useSelect } from "@wordpress/data"; |
| 18 |
import { SelectField } from "../../components"; |
| 19 |
import { BackToTopGeneral, BackToTopPreview, BackToTopStyle } from "./modulePart"; |
| 20 |
import { useMemo } from "@wordpress/element"; |
| 21 |
|
| 22 |
export const SettingsDemoTab = ({ attributes, setSettingsValue }) => { |
| 23 |
const { post_type } = attributes?.options; |
| 24 |
|
| 25 |
const allPostTypes = useSelect((select) => select("core").getPostTypes(), [] ); |
| 26 |
const getPostTypes = useMemo(() => { |
| 27 |
if (!allPostTypes) { |
| 28 |
return []; |
| 29 |
} |
| 30 |
return Object.values(allPostTypes) |
| 31 |
.filter(({ viewable }) => viewable) |
| 32 |
?.map(({ name, slug }) => ({ label: name, value: slug })); |
| 33 |
}, [allPostTypes]); |
| 34 |
const postTypeHandler = (newValue) => { |
| 35 |
setSettingsValue({ ...attributes, options: { post_type: newValue } }); |
| 36 |
}; |
| 37 |
|
| 38 |
return ( |
| 39 |
<> |
| 40 |
<SelectField |
| 41 |
label="Button Group" |
| 42 |
attributes={post_type} |
| 43 |
attributesKey={"post_type"} |
| 44 |
onChange={(newValue) => postTypeHandler(newValue)} |
| 45 |
items={getPostTypes} |
| 46 |
/> |
| 47 |
</> |
| 48 |
); |
| 49 |
}; |
| 50 |
|
| 51 |
const modulesData = { |
| 52 |
"back-to-top": { |
| 53 |
Icon: BackToTopModuleIcon, |
| 54 |
title: "Back To Top", |
| 55 |
text: "This lets you add a back-to-top button to help users navigate efficiently and enhance experience.", |
| 56 |
// demoLink: "https://wpsmartpost.com/back-to-top/", |
| 57 |
docsLink: "https://wpsmartpost.com/docs/back-to-top/", |
| 58 |
settings: true, |
| 59 |
General: BackToTopGeneral, |
| 60 |
Style: BackToTopStyle, |
| 61 |
Preview: BackToTopPreview, |
| 62 |
}, |
| 63 |
"saved-template": { |
| 64 |
Icon: saveTemplateModuleIcon, |
| 65 |
title: "Saved Templates", |
| 66 |
text: "This lets you create unlimited templates by converting blocks into shortcodes to reuse anywhere.", |
| 67 |
// demoLink: "https://wpsmartpost.com/saved-template/", |
| 68 |
docsLink: "https://wpsmartpost.com/docs/saved-templates/", |
| 69 |
settings: false, |
| 70 |
}, |
| 71 |
"template-library": { |
| 72 |
Icon: templateLibraryModuleIcon, |
| 73 |
title: "Smart Design Library", |
| 74 |
text: "Access a library of professional, ready-made starter sites, patterns, and pages for creating fast, elegant websites.", |
| 75 |
docsLink: "https://wpsmartpost.com/docs/smart-design-library/", |
| 76 |
}, |
| 77 |
taxonomy: { |
| 78 |
Icon: taxonomyModuleIcon, |
| 79 |
title: "Taxonomy Image & Color", |
| 80 |
text: "It allows you to assign featured images and colors to categories and taxonomies for better visual appeal.", |
| 81 |
demoLink: "https://wpsmartpost.com/blocks/#demoId3604", |
| 82 |
docsLink: "https://wpsmartpost.com/docs/taxonomy-image-color/", |
| 83 |
pro: true, |
| 84 |
}, |
| 85 |
"post-badges": { |
| 86 |
Icon: postBadgesModuleIcon, |
| 87 |
title: "Post Badges", |
| 88 |
text: "This lets you add taxonomy fields and highlight posts with badges like “Hot,” “New,” or custom labels.", |
| 89 |
demoLink: "https://wpsmartpost.com/blocks/#demoId3514", |
| 90 |
docsLink: "https://wpsmartpost.com/docs/post-badges/", |
| 91 |
settings: false, |
| 92 |
SettingsTab: SettingsDemoTab, |
| 93 |
pro: true, |
| 94 |
}, |
| 95 |
"image-gallery": { |
| 96 |
Icon: postImageGalleryModuleIcon, |
| 97 |
title: "Post Image Gallery", |
| 98 |
text: "Lets you add and display images in a responsive gallery slider within your post card to boost engagement.", |
| 99 |
demoLink: "https://wpsmartpost.com/blocks/#demoId3497", |
| 100 |
docsLink: "https://wpsmartpost.com/docs/post-image-gallery/", |
| 101 |
settings: false, |
| 102 |
pro: true, |
| 103 |
}, |
| 104 |
"featured-video": { |
| 105 |
Icon: postFeaturedVideoModuleIcon, |
| 106 |
title: "Post Featured Video", |
| 107 |
text: "This allows you to add video links to replace the featured image for more engaging posts and a better impact.", |
| 108 |
demoLink: "https://wpsmartpost.com/blocks/#demoId3514", |
| 109 |
docsLink: "https://wpsmartpost.com/docs/post-featured-video/", |
| 110 |
settings: false, |
| 111 |
pro: true, |
| 112 |
}, |
| 113 |
}; |
| 114 |
const upcomingModulesData = { |
| 115 |
"website-builder": { |
| 116 |
Icon: webBuilderModuleIcon, |
| 117 |
title: "Website Builder", |
| 118 |
text: "This lets you create dynamic home and archive page templates with a powerful Gutenberg builder.", |
| 119 |
demoLink: "#", |
| 120 |
docsLink: "#", |
| 121 |
}, |
| 122 |
"starter-sites": { |
| 123 |
Icon: StarterSitesModuleIcon, |
| 124 |
title: "Starter Sites", |
| 125 |
text: "Starter Sites are ready-made website templates designed to help you launch professional, responsive sites quickly.", |
| 126 |
demoLink: "#", |
| 127 |
docsLink: "#", |
| 128 |
}, |
| 129 |
"dynamic-datafield": { |
| 130 |
Icon: dynamicDataFieldModuleIcon, |
| 131 |
title: "Dynamic Data & Fields", |
| 132 |
text: "Add dynamic content like excerpts, dates, authors, and fields into SmartPost blocks and layouts.", |
| 133 |
demoLink: "#", |
| 134 |
docsLink: "#", |
| 135 |
}, |
| 136 |
"front-post-submission": { |
| 137 |
Icon: frontPostSubmissionModuleIcon, |
| 138 |
title: "Frontend Post Submission", |
| 139 |
text: "It allows your users to submit posts from the frontend without accessing the WordPress dashboard.", |
| 140 |
demoLink: "#", |
| 141 |
docsLink: "#", |
| 142 |
}, |
| 143 |
"reading-scroll-progress": { |
| 144 |
Icon: readingScrollModuleIcon, |
| 145 |
title: "Reading & Scroll Progress", |
| 146 |
text: "Display a visual indicator of reading progress for blog posts and scrolling progress on pages.", |
| 147 |
demoLink: "#", |
| 148 |
docsLink: "#", |
| 149 |
}, |
| 150 |
shortcode: { |
| 151 |
Icon: shortcodeModuleIcon, |
| 152 |
title: "Classic Shortcode Generator", |
| 153 |
text: "Lets you disable the Classic Shortcode Generator menu (Manage Shows, Replace Layout) to improve speed.", |
| 154 |
demoLink: "#", |
| 155 |
docsLink: "#", |
| 156 |
}, |
| 157 |
}; |
| 158 |
const haveUpcomingData = Object.entries(upcomingModulesData)?.length > 0; |
| 159 |
|
| 160 |
const Modules = ({ blockShowHideHandler, modulesOptions, type = "" }) => { |
| 161 |
return ( |
| 162 |
<> |
| 163 |
<div className="sp-pcp-blocks-setting-modules-page"> |
| 164 |
{"setup-wizard" !== type && |
| 165 |
<div className="sp-pcp-page-section-title"> |
| 166 |
<h3 className="sp-pcp-blocks-setting-title">Manage Modules</h3> |
| 167 |
<span>Enable only the modules you need to keep your site fast and optimized.</span> |
| 168 |
</div> |
| 169 |
} |
| 170 |
{Object.entries(modulesData)?.map(([moduleName, data]) => { |
| 171 |
const toggleValue = modulesOptions.find((item) => item?.module_name === moduleName).show; |
| 172 |
return ( |
| 173 |
<ModulesCard |
| 174 |
key={moduleName} |
| 175 |
value={toggleValue} |
| 176 |
moduleName={moduleName} |
| 177 |
data={data} |
| 178 |
blockShowHideHandler={blockShowHideHandler} |
| 179 |
settingsValue={modulesOptions} |
| 180 |
type={type} |
| 181 |
// settingsAttr={ settingsAttr || {}} |
| 182 |
// setSettingsAttr={ setSettingsAttr } |
| 183 |
/> |
| 184 |
); |
| 185 |
})} |
| 186 |
{haveUpcomingData && ( |
| 187 |
<> |
| 188 |
<h3 className="sp-pcp-blocks-setting-title">Upcoming Modules</h3> |
| 189 |
{Object.entries(upcomingModulesData)?.map(([moduleName, data]) => ( |
| 190 |
<ModulesCard |
| 191 |
key={moduleName} |
| 192 |
value={modulesOptions[moduleName]} |
| 193 |
moduleName={moduleName} |
| 194 |
data={data} |
| 195 |
blockShowHideHandler={blockShowHideHandler} |
| 196 |
isDisabled={true} |
| 197 |
type={type} |
| 198 |
/> |
| 199 |
))} |
| 200 |
</> |
| 201 |
)} |
| 202 |
</div> |
| 203 |
</> |
| 204 |
); |
| 205 |
}; |
| 206 |
|
| 207 |
export default Modules; |
| 208 |
|