PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.9
Yatra – Travel Booking & Tour Operator Software v3.0.2.9
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
yatra / resources / js / blocks / activity / edit.tsx

edit.tsx in Yatra – Travel Booking & Tour Operator Software 3.0.2.9, at resources/js/blocks/activity/edit.tsx

88 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { InspectorControls } from "@wordpress/block-editor";
2 import {
3 PanelBody,
4 TextControl,
5 RangeControl,
6 SelectControl,
7 ToggleControl,
8 } from "@wordpress/components";
9 import { __ } from "@wordpress/i18n";
10 import ServerSideRender from "@wordpress/server-side-render";
11
12 interface ActivityBlockAttributes {
13 order: "asc" | "desc";
14 columns: number;
15 per_page: number;
16 title: string;
17 show_pagination: boolean;
18 }
19
20 interface EditProps {
21 attributes: ActivityBlockAttributes;
22 setAttributes: (attrs: Partial<ActivityBlockAttributes>) => void;
23 }
24
25 export default function Edit({ attributes, setAttributes }: EditProps) {
26 return (
27 <>
28 <InspectorControls>
29 <PanelBody title={__("Activity Settings", "yatra")} initialOpen={true}>
30 <TextControl
31 label={__("Title", "yatra")}
32 value={attributes.title}
33 onChange={(value: string) => setAttributes({ title: value })}
34 />
35 <SelectControl
36 label={__("Order", "yatra")}
37 value={attributes.order}
38 options={[
39 { label: __("Ascending", "yatra"), value: "asc" },
40 { label: __("Descending", "yatra"), value: "desc" },
41 ]}
42 onChange={(value: string) =>
43 setAttributes({ order: value as "asc" | "desc" })
44 }
45 />
46 <RangeControl
47 label={__("Number of Activities", "yatra")}
48 value={attributes.per_page}
49 onChange={(value: number | undefined) =>
50 setAttributes({
51 per_page: value !== undefined && value !== null ? value : 10,
52 })
53 }
54 min={1}
55 max={50}
56 />
57 <RangeControl
58 label={__("Columns", "yatra")}
59 value={attributes.columns}
60 onChange={(value: number | undefined) =>
61 setAttributes({
62 columns: value !== undefined && value !== null ? value : 3,
63 })
64 }
65 min={1}
66 max={6}
67 />
68 <ToggleControl
69 label={__("Show pagination", "yatra")}
70 checked={attributes.show_pagination}
71 onChange={(value: boolean) =>
72 setAttributes({ show_pagination: value })
73 }
74 />
75 </PanelBody>
76 </InspectorControls>
77
78 <div className="yatra-block-editor-preview">
79 <ServerSideRender
80 block="yatra/activity"
81 attributes={attributes}
82 key={JSON.stringify(attributes)}
83 />
84 </div>
85 </>
86 );
87 }
88