PluginProbe
Text Typing – grab attention with animated typing headlines / trunk
Text Typing – grab attention with animated typing headlines vtrunk
2.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
text-typing / dashboard / App.js

App.js in Text Typing – grab attention with animated typing headlines trunk, at dashboard/App.js

113 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useState } from "react";
2 import {
3 HashRouter as Router,
4 Routes,
5 Route,
6 Navigate,
7 } from "react-router-dom";
8
9 import Demos from "../../bpl-tools/Admin/Demos";
10 import Pricing from "../../bpl-tools/Admin/Pricing";
11 import FeatureCompare from "../../bpl-tools/Admin/FeatureCompare";
12 import OurPlugins from "../../bpl-tools/Admin/OurPlugins";
13 import Settings from "../../bpl-tools/Admin/Settings";
14 import Blocks from "../../bpl-tools/Admin/Blocks";
15
16 import Layout from "./Layout/Layout";
17 import Welcome from "./Pages/Welcome";
18 import { demoInfo, pricingInfo } from "./utils/data";
19 import { allBlocks } from "./utils/blocks";
20
21 const App = (props) => {
22 const { disabledBlocks: initialDisabled = [], disabledBlocksNonce } = props;
23
24 // Disabled-block state is shared by the Welcome card and the Blocks page and
25 // persisted to the ttbDisabledBlocks option via admin-ajax (wp.ajax / wp-util).
26 const [disabledBlocks, setDisabledBlocks] = useState(
27 Array.isArray(initialDisabled) ? initialDisabled : [],
28 );
29 const [blocksStatus, setBlocksStatus] = useState("");
30
31 const handleBlocksChange = (names) => {
32 setDisabledBlocks(names);
33 setBlocksStatus("loading");
34
35 if (window.wp?.ajax) {
36 window.wp.ajax
37 .post("ttbDisabledBlocks", {
38 _wpnonce: disabledBlocksNonce,
39 data: JSON.stringify(names),
40 })
41 .done(() => setBlocksStatus("success"))
42 .fail(() => setBlocksStatus("error"));
43 }
44 };
45
46 const blocksProps = {
47 allBlocks,
48 disabledBlocks,
49 onChange: handleBlocksChange,
50 status: blocksStatus,
51 };
52
53 return (
54 <Router>
55 <Routes>
56 <Route path="/" element={<Layout {...props} />}>
57 <Route
58 index
59 element={<Welcome {...props} blocksProps={blocksProps} />}
60 />
61
62 <Route
63 path="welcome"
64 element={<Welcome {...props} blocksProps={blocksProps} />}
65 />
66
67 <Route
68 path="demos"
69 element={<Demos demoInfo={demoInfo} {...props} />}
70 />
71
72 <Route
73 path="blocks"
74 element={<Blocks {...props} {...blocksProps} pageTitle="Blocks" />}
75 />
76
77 <Route
78 path="pricing"
79 element={
80 <Pricing pricingInfo={pricingInfo} options={{}} {...props} />
81 }
82 />
83
84 <Route
85 path="feature-comparison"
86 element={<FeatureCompare plans={["free", "pro"]} {...props} />}
87 />
88
89 <Route path="our-plugins" element={<OurPlugins {...props} />} />
90
91 <Route
92 path="settings"
93 element={
94 <Settings
95 {...props}
96 ajaxAction="ttbSaveUninstallOption"
97 cleanupItems={[
98 "All Typing Text posts (ShortCode Generator items)",
99 "Plugin settings and options",
100 "License activation data",
101 ]}
102 />
103 }
104 />
105
106 <Route path="*" element={<Navigate to="/welcome" replace />} />
107 </Route>
108 </Routes>
109 </Router>
110 );
111 };
112 export default App;
113