PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.1.5
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.1.5
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / admin / pages / demo / Designs.js

Designs.js in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 3.1.5, at admin/pages/demo/Designs.js

87 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useState, useEffect } from 'react';
2 import Pages from './demo-pages';
3 import Headers from './header';
4 import Footers from './footer';
5 import Sections from './sections';
6 import Countdemo from "./count-demo"
7 const { __ } = wp.i18n;
8
9 const Designs = () => {
10 const [navState, setNavState] = useState("pages");
11 const [demoData, setDemoData] = useState([])
12 const [isLoading, setISLoading] = useState(false)
13 useEffect(() => {
14 wp.apiFetch({
15 method: 'GET',
16 path: '/blockspare/v1/layouts/all?filter=allowed',
17 })
18 .then(async (components) => {
19 setDemoData(components);
20 setISLoading(true)
21 })
22 .catch(error => {
23 console.error('Error fetching data:', error);
24 // Handle the error, e.g., set an error state or show a message to the user.
25 });
26 }, [navState])
27 const handleNavStateChange = (tab) => {
28 // sessionStorage.setItem("nav", tab);
29 setNavState(tab);
30 };
31
32 return (
33 <div className="aft-dashboard-main-section">
34 <div className="bs-layout-tab-content settings-tab-content-wrapper">
35 <aside className='bs-layout-sidebar'>
36 <div className="bs-layout-category-list">
37 <div
38 className={`bs-layout-category ${navState == "pages" ? "bs-layout-selected-category" : ""
39 }`}
40 onClick={(e) => handleNavStateChange("pages")}
41 >
42 {__("Starter Templates", 'blockspare')}
43 <Countdemo type='page' data={demoData} />
44 </div>
45 <div
46 className={`bs-layout-category ${navState == "sections" ? "bs-layout-selected-category" : ""
47 }`}
48 onClick={(e) => handleNavStateChange("sections")}
49 >
50 {__("Sections", 'blockspare')}
51 <Countdemo type='section' data={demoData} />
52 </div>
53
54 <div
55 className={`bs-layout-category ${navState == "headers" ? "bs-layout-selected-category" : ""
56 }`}
57 onClick={(e) => handleNavStateChange("headers")}
58 >
59 {__("Headers", 'blockspare')}
60 <Countdemo type='header' data={demoData} />
61 </div>
62
63 <div
64 className={`bs-layout-category ${navState == "footers" ? "bs-layout-selected-category" : ""
65 }`}
66 onClick={(e) => handleNavStateChange("footers")}
67 >
68 {__("Footers", 'blockspare')}
69 <Countdemo type='footer' data={demoData} />
70 </div>
71
72
73 </div>
74 </aside>
75 {navState == "pages" && <Pages data={demoData} loader={isLoading} />}
76 {navState == "sections" && <Sections data={demoData} />}
77 {navState == "headers" && <Headers data={demoData} />}
78 {navState == "footers" && <Footers data={demoData} />}
79
80
81 </div>
82 </div>
83 )
84
85 }
86
87 export default Designs