PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 2.7.1
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v2.7.1
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 / Settings.js

Settings.js in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 2.7.1, at admin/pages/Settings.js

120 lines 4.0 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 SettingWithInput from '../components/SettingWithInput'
3 const { apiFetch } = wp;
4 const Settings = () => {
5 useEffect(() => {
6 getScreensizes()
7 }, [])
8 const [success, setSuccess] = useState(false);
9 const [blockSettings, setBlockSettings] = useState({
10 aligncenter_size: '',
11 alignwide_size: '',
12 mobile_breakpoint: '768',
13 tablet_breakpoint: '1024'
14 });
15
16 function handleInputChange(event) {
17 const { name, value } = event.target;
18 setBlockSettings(prevState => ({
19 ...prevState,
20 [name]: value
21 }));
22
23 }
24
25 const getScreensizes = async (value) => {
26 let aligncenter_size = await apiFetch({
27 path: `blockspare-dashboard/v1/blocksettings`,
28 method: 'GET',
29
30 });
31 setBlockSettings(aligncenter_size)
32
33 }
34
35 const saveSettings = async (blockSettings) => {
36
37 const success = await apiFetch({
38 path: `blockspare-dashboard/v1/updateblocksettings`,
39 method: 'POST',
40 data: {
41 aligncenter_size: blockSettings.aligncenter_size,
42 alignwide_size: blockSettings.alignwide_size,
43 tablet_breakpoint: blockSettings.tablet_breakpoint,
44 mobile_breakpoint: blockSettings.mobile_breakpoint
45 }
46
47 });
48
49 setSuccess(true)
50 setTimeout(function () {
51 setSuccess(false)
52 }, 3000)
53
54
55 }
56
57 function handleInputBlur() {
58
59 saveSettings(blockSettings)
60
61
62 }
63
64
65
66
67
68
69 return (
70 <div className="content-wrapper settings">
71 <div className="settings-tab-container">
72 <div className="setting-header">
73 <h1>General Settings</h1>
74
75 {success &&
76 <p>Settings Updated</p>
77 }
78
79 </div>
80 <div className="setting-body">
81 <SettingWithInput
82 title="Nested Block Width"
83 description="The width used when a Columns block has its Content Width set to center. This is automatically detected from your theme. You can adjust it if your blocks are not aligned correctly."
84 name="aligncenter_size"
85 value={blockSettings.aligncenter_size}
86 handleChange={handleInputChange}
87 handleBlur={handleInputBlur}
88 />
89 <SettingWithInput
90 title="Nested Wide Block Width"
91 description="The width used when a Columns block has its Content Width set to center. This is automatically detected from your theme. You can adjust it if your blocks are not aligned correctly."
92 name="alignwide_size"
93 value={blockSettings.alignwide_size}
94 handleChange={handleInputChange}
95 handleBlur={handleInputBlur}
96 />
97 <SettingWithInput
98 title="Tablet Breakpoint"
99 description="Donec sollicitudin molestie malesuada. Donec sollicitudin molestie malesuada."
100 name="tablet_breakpoint"
101 value={blockSettings.tablet_breakpoint}
102 handleChange={handleInputChange}
103 handleBlur={handleInputBlur}
104 />
105 <SettingWithInput
106 title="Mobile Breakpoint"
107 description="Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus."
108 name="mobile_breakpoint"
109 value={blockSettings.mobile_breakpoint}
110 handleChange={handleInputChange}
111 handleBlur={handleInputBlur}
112 />
113 </div>
114 </div>
115 </div>
116 )
117 }
118
119 export default Settings
120