PluginProbe
CodePen Embed Block / trunk
CodePen Embed Block vtrunk
codepen-embed-block / src / settings.js

settings.js in CodePen Embed Block trunk, at src/settings.js

59 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 import { __ } from "@wordpress/i18n";
5 import { InspectorControls } from "@wordpress/block-editor";
6 import {
7 TextControl,
8 ToggleControl,
9 SelectControl,
10 } from "@wordpress/components";
11
12 export default function formFields(attributes, setAttributes) {
13 const { penHeight, penType, clickToLoad, penTheme, editable } = attributes;
14
15 const penTypeOptions = [
16 { value: "result", label: __("Result only") },
17 { value: "html,result", label: __("HTML and result") },
18 { value: "js,result", label: __("JavaScript and result") },
19 { value: "css,result", label: __("CSS and result") },
20 ];
21
22 return (
23 <InspectorControls>
24 <TextControl
25 label={__("Pen Height (in pixels)")}
26 onChange={(value) =>
27 setAttributes({ penHeight: Number.parseInt(value, 10) })
28 }
29 value={penHeight}
30 type="number"
31 />
32 <TextControl
33 label={__("Pen Theme ID")}
34 select={penTheme}
35 onChange={(value) => setAttributes({ penTheme: value })}
36 value={penTheme}
37 help="You can use 'light' and 'dark' also"
38 />
39 <SelectControl
40 label={__("Pen View")}
41 select={penType}
42 options={penTypeOptions}
43 onChange={(value) => setAttributes({ penType: value })}
44 value={penType}
45 />
46 <ToggleControl
47 label={__("Use click-to-load (increases performance)")}
48 checked={!!clickToLoad}
49 onChange={() => setAttributes({ clickToLoad: !clickToLoad })}
50 />
51 <ToggleControl
52 label={__("Editable? (decreases performance, but becomes live editor)")}
53 checked={!!editable}
54 onChange={() => setAttributes({ editable: !editable })}
55 />
56 </InspectorControls>
57 );
58 }
59