PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.7
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.7
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / admin / pages / modules / index.js

index.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.7, at src/admin/pages/modules/index.js

237 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 "../../components/icons/modules";
16 import ModulesCard from "../../components/cards/ModulesCard";
17 import { useSelect } from "@wordpress/data";
18 import { SelectField } from "../../../components";
19 import { BackToTopGeneral, BackToTopPreview, BackToTopStyle } from "../shared/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 = "", filterModules = null }) => {
161 // Filter modulesData if filterModules is provided
162 const filteredModulesData = filterModules
163 ? Object.fromEntries(Object.entries(modulesData).filter(([moduleName]) => filterModules.includes(moduleName)))
164 : modulesData;
165
166 // For quick-start type, don't use the wrapper div since it's already wrapped in the parent
167 const isQuickStart = type === "quick-start";
168
169 if (isQuickStart) {
170 return (
171 <>
172 {Object.entries(filteredModulesData)?.map(([moduleName, data]) => {
173 const toggleValue = modulesOptions.find((item) => item?.module_name === moduleName)?.show;
174 return (
175 <ModulesCard
176 key={moduleName}
177 value={toggleValue}
178 moduleName={moduleName}
179 data={data}
180 blockShowHideHandler={blockShowHideHandler}
181 settingsValue={modulesOptions}
182 type={type}
183 />
184 );
185 })}
186 </>
187 );
188 }
189
190 return (
191 <>
192 <div className="sp-pcp-blocks-setting-modules-page">
193 {"setup-wizard" !== type &&
194 <div className="sp-pcp-page-section-title">
195 <h3 className="sp-pcp-blocks-setting-title">Manage Modules</h3>
196 <span>Enable only the modules you need to keep your site fast and optimized.</span>
197 </div>
198 }
199 {Object.entries(filteredModulesData)?.map(([moduleName, data]) => {
200 const toggleValue = modulesOptions.find((item) => item?.module_name === moduleName)?.show;
201 return (
202 <ModulesCard
203 key={moduleName}
204 value={toggleValue}
205 moduleName={moduleName}
206 data={data}
207 blockShowHideHandler={blockShowHideHandler}
208 settingsValue={modulesOptions}
209 type={type}
210 // settingsAttr={ settingsAttr || {}}
211 // setSettingsAttr={ setSettingsAttr }
212 />
213 );
214 })}
215 {haveUpcomingData && (
216 <>
217 <h3 className="sp-pcp-blocks-setting-title">Upcoming Modules</h3>
218 {Object.entries(upcomingModulesData)?.map(([moduleName, data]) => (
219 <ModulesCard
220 key={moduleName}
221 value={modulesOptions[moduleName]}
222 moduleName={moduleName}
223 data={data}
224 blockShowHideHandler={blockShowHideHandler}
225 isDisabled={true}
226 type={type}
227 />
228 ))}
229 </>
230 )}
231 </div>
232 </>
233 );
234 };
235
236 export default Modules;
237