| 1 |
import { __, _x } from "@wordpress/i18n"; |
| 2 |
import { PanelBody, __experimentalInputControl as InputControl, Button } from "@wordpress/components"; |
| 3 |
|
| 4 |
import { MobileIcon, TabletIcon } from "../../components/responsive/icon"; |
| 5 |
import "./editor.scss"; |
| 6 |
import { useDispatch, useSelect } from "@wordpress/data"; |
| 7 |
import { Divider } from "../../components"; |
| 8 |
import { ResetIcon } from "../../icons/icons"; |
| 9 |
|
| 10 |
const Breakpoint = () => { |
| 11 |
const breakpoint = useSelect((select) => select("smartpost/global-settings").getCategory("breakpoint")); |
| 12 |
|
| 13 |
const { updateSetting } = useDispatch("smartpost/global-settings"); |
| 14 |
|
| 15 |
const breakpointChange = (newValue, key) => { |
| 16 |
updateSetting("breakpoint", key, newValue); |
| 17 |
}; |
| 18 |
|
| 19 |
const resetBreakpoint = (key) => { |
| 20 |
const resetValue = { |
| 21 |
container: 1200, |
| 22 |
tablet: 1023, |
| 23 |
mobile: 767, |
| 24 |
} |
| 25 |
updateSetting("breakpoint", key, resetValue[key]); |
| 26 |
}; |
| 27 |
|
| 28 |
return ( |
| 29 |
<PanelBody title={__("Responsive Breakpoints", "post-carousel")} initialOpen={false}> |
| 30 |
<div className="sp-smart-breakpoint-header"> |
| 31 |
<span>Tablet Max Width</span> |
| 32 |
<Button |
| 33 |
onClick={() => resetBreakpoint("tablet")} |
| 34 |
className={`sp-smart-breakpoint-reset ${1023 != breakpoint?.tablet ? "active" : ""}`} |
| 35 |
> |
| 36 |
<ResetIcon /> |
| 37 |
</Button> |
| 38 |
</div> |
| 39 |
<div className="sp-smart-breakpoint"> |
| 40 |
<div className="sp-smart-breakpoint-icon"> |
| 41 |
<TabletIcon /> |
| 42 |
</div> |
| 43 |
<InputControl |
| 44 |
type="number" |
| 45 |
value={breakpoint?.tablet} |
| 46 |
onChange={(newValue) => breakpointChange(newValue, "tablet")} |
| 47 |
/> |
| 48 |
<span>Px</span> |
| 49 |
</div> |
| 50 |
|
| 51 |
<div className="sp-smart-breakpoint-header"> |
| 52 |
<span>Mobile Max Width</span> |
| 53 |
<Button |
| 54 |
onClick={() => resetBreakpoint("mobile")} |
| 55 |
className={`sp-smart-breakpoint-reset ${767 != breakpoint?.mobile ? "active" : ""}`} |
| 56 |
> |
| 57 |
<ResetIcon /> |
| 58 |
</Button> |
| 59 |
</div> |
| 60 |
<div className="sp-smart-breakpoint"> |
| 61 |
<div className="sp-smart-breakpoint-icon"> |
| 62 |
<MobileIcon /> |
| 63 |
</div> |
| 64 |
<InputControl |
| 65 |
type="number" |
| 66 |
value={breakpoint?.mobile} |
| 67 |
onChange={(newValue) => breakpointChange(newValue, "mobile")} |
| 68 |
/> |
| 69 |
<span>Px</span> |
| 70 |
</div> |
| 71 |
</PanelBody> |
| 72 |
); |
| 73 |
}; |
| 74 |
|
| 75 |
export default Breakpoint; |
| 76 |
|