PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.8
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.8
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / components / selectDropdown / selectDropdown.js

selectDropdown.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at src/components/selectDropdown/selectDropdown.js

95 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import "./editor.scss";
2 import Popup from "../popup/popup";
3
4 const SelectDropdown = ({
5 label,
6 options,
7 attributes,
8 setAttributes,
9 attributesKey,
10 onClick = null,
11 className = "",
12 onClose,
13 }) => {
14 return (
15 <>
16 <Popup label={label}>
17 {/* <ul
18 className={ `sp-smart-post-select-dropdown ${ className }` }
19 >
20 { options?.map( ( option, index ) => (
21 <li
22 key={ index }
23 className={ `sp-smart-post-select-dropdown-option ${
24 attributes === option.value ? 'active' : ''
25 } ` }
26 onClick={ () => {
27 selectHandler( option.value );
28 if ( typeof onClose === 'function' ) {
29 onClose();
30 console.log( 'hello' )
31 }
32 } }
33 >
34 { option.label && <span>{ option.label }</span> }
35 { option.icon && <span>{ option.icon }</span> }
36 </li>
37 ) ) }
38 </ul> */}
39 <SelectDropField
40 options={options}
41 attributes={attributes}
42 setAttributes={setAttributes}
43 attributesKey={attributesKey}
44 className={className}
45 onClick={onClick}
46 onClose={onClose}
47 />
48 </Popup>
49 </>
50 );
51 };
52
53 export default SelectDropdown;
54
55 const SelectDropField = ({
56 options,
57 attributes,
58 setAttributes,
59 attributesKey,
60 onClick = null,
61 className = "",
62 onClose,
63 }) => {
64 const selectHandler = (value) => {
65 if (onClick) {
66 onClick(value);
67 } else {
68 setAttributes({ [attributesKey]: value });
69 }
70 };
71
72 return (
73 <ul className={`sp-smart-post-select-dropdown ${className}`}>
74 {options?.map(({value, label, icon, disabled, type = ""}, index) => (
75 <li
76 key={index}
77 className={`sp-smart-post-select-dropdown-option${attributes === value ? " active" : ""}${disabled ? " disabled" : ""}`}
78 disabled={disabled}
79 onClick={() => {
80 selectHandler(value);
81 if (typeof onClose === "function") {
82 onClose();
83 }
84 }}
85 >
86 {label && <span> {`${label}`}
87 {"pro" === type && <a target="_blank" href="https://wpsmartpost.com/pricing/?ref=1" className="sp-smart-pro-text"> (Pro) </a>}
88 </span>}
89 {icon && <span>{icon}</span>}
90 </li>
91 ))}
92 </ul>
93 );
94 };
95