block.json
1 month ago
edit.js
1 week ago
index-min.js
1 year ago
index.js
1 year ago
save.js
1 year ago
edit.js
161 lines
| 1 | /** |
| 2 | * WordPress components that create the necessary UI elements for the block |
| 3 | * |
| 4 | * @see https://developer.wordpress.org/block-editor/packages/packages-components/ |
| 5 | */ |
| 6 | import {TextControl, ToggleControl, Panel, PanelBody, PanelRow} from '@wordpress/components'; |
| 7 | |
| 8 | |
| 9 | /** |
| 10 | * React hook that is used to mark the block wrapper element. |
| 11 | * It provides all the necessary props like the class name. |
| 12 | * |
| 13 | * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops |
| 14 | */ |
| 15 | import { |
| 16 | useBlockProps, |
| 17 | InspectorControls, |
| 18 | } from '@wordpress/block-editor'; |
| 19 | import styled from "@emotion/styled"; |
| 20 | import IframeEmotionCacheProvider from '../utils/IframeEmotionCacheProvider'; |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * The edit function describes the structure of your block in the context of the |
| 25 | * editor. This represents what the editor will render when the block is used. |
| 26 | * |
| 27 | * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit |
| 28 | * |
| 29 | * @param {Object} props Properties passed to the function. |
| 30 | * @param {Object} props.attributes Available block attributes. |
| 31 | * @param {Function} props.setAttributes Function that updates individual attributes. |
| 32 | * |
| 33 | * @return {WPElement} Element to render. |
| 34 | */ |
| 35 | export default function Edit({attributes, setAttributes}) { |
| 36 | const blockProps = useBlockProps(); |
| 37 | |
| 38 | const LatepointDashboardWrapper = styled.div` |
| 39 | box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.1); |
| 40 | border-radius: 4px; |
| 41 | border: 1px solid #ddd; |
| 42 | border-bottom-color: #bbb; |
| 43 | background-color: #fff; |
| 44 | padding: 20px; |
| 45 | `; |
| 46 | |
| 47 | const LatepointDashboardFormCaption = styled.div` |
| 48 | font-weight: 500; |
| 49 | margin-bottom: 10px; |
| 50 | font-size: 12px; |
| 51 | text-transform: uppercase; |
| 52 | letter-spacing: 1px; |
| 53 | `; |
| 54 | |
| 55 | const DItems = styled.div` |
| 56 | display: flex; |
| 57 | justify-content: space-between; |
| 58 | gap: 20px; |
| 59 | `; |
| 60 | |
| 61 | const LatepointDashboardItem = styled.div` |
| 62 | display: flex; |
| 63 | flex-direction: column; |
| 64 | padding: 20px; |
| 65 | width: 180px; |
| 66 | border: 1px solid #ddd; |
| 67 | background: #fbfbfb; |
| 68 | `; |
| 69 | |
| 70 | const DIName = styled.div` |
| 71 | padding: 10px; |
| 72 | border-radius: 4px; |
| 73 | background-color: #eee; |
| 74 | `; |
| 75 | const DIBody = styled.div` |
| 76 | padding: 10px 0; |
| 77 | margin: 10px 0; |
| 78 | border-top: 1px solid #ddd; |
| 79 | border-bottom: 1px solid #ddd; |
| 80 | `; |
| 81 | |
| 82 | const DIFooter = styled.div` |
| 83 | `; |
| 84 | |
| 85 | const DIButtonPrev = styled.div` |
| 86 | padding: 10px; |
| 87 | width: 30px; |
| 88 | background-color: #b4c6f5; |
| 89 | border-radius: 4px; |
| 90 | `; |
| 91 | |
| 92 | const DIDescription = styled.div` |
| 93 | padding: 5px; |
| 94 | border-radius: 4px; |
| 95 | background-color: #f8f8f8; |
| 96 | margin-bottom: 5px; |
| 97 | `; |
| 98 | |
| 99 | |
| 100 | return ( |
| 101 | <div {...blockProps}> |
| 102 | <InspectorControls> |
| 103 | <Panel> |
| 104 | <PanelBody title="Dashboard Settings"> |
| 105 | <TextControl __nextHasNoMarginBottom __next40pxDefaultSize |
| 106 | label="Caption" |
| 107 | value={attributes.caption || ''} |
| 108 | onChange={(value) => setAttributes({caption: value})} |
| 109 | /> |
| 110 | <ToggleControl __nextHasNoMarginBottom |
| 111 | label="Hide new appointment button and tab" |
| 112 | checked={attributes.hide_new_appointment_ui} |
| 113 | onChange={(value) => setAttributes({hide_new_appointment_ui: value})} |
| 114 | /> |
| 115 | </PanelBody> |
| 116 | </Panel> |
| 117 | </InspectorControls> |
| 118 | <IframeEmotionCacheProvider> |
| 119 | <LatepointDashboardWrapper> |
| 120 | <LatepointDashboardFormCaption>{attributes.caption}</LatepointDashboardFormCaption> |
| 121 | <DItems> |
| 122 | <LatepointDashboardItem> |
| 123 | <DIName></DIName> |
| 124 | <DIBody> |
| 125 | <DIDescription></DIDescription> |
| 126 | <DIDescription></DIDescription> |
| 127 | <DIDescription></DIDescription> |
| 128 | </DIBody> |
| 129 | <DIFooter> |
| 130 | <DIButtonPrev></DIButtonPrev> |
| 131 | </DIFooter> |
| 132 | </LatepointDashboardItem> |
| 133 | <LatepointDashboardItem> |
| 134 | <DIName></DIName> |
| 135 | <DIBody> |
| 136 | <DIDescription></DIDescription> |
| 137 | <DIDescription></DIDescription> |
| 138 | <DIDescription></DIDescription> |
| 139 | </DIBody> |
| 140 | <DIFooter> |
| 141 | <DIButtonPrev></DIButtonPrev> |
| 142 | </DIFooter> |
| 143 | </LatepointDashboardItem> |
| 144 | <LatepointDashboardItem> |
| 145 | <DIName></DIName> |
| 146 | <DIBody> |
| 147 | <DIDescription></DIDescription> |
| 148 | <DIDescription></DIDescription> |
| 149 | <DIDescription></DIDescription> |
| 150 | </DIBody> |
| 151 | <DIFooter> |
| 152 | <DIButtonPrev></DIButtonPrev> |
| 153 | </DIFooter> |
| 154 | </LatepointDashboardItem> |
| 155 | </DItems> |
| 156 | </LatepointDashboardWrapper> |
| 157 | </IframeEmotionCacheProvider> |
| 158 | </div> |
| 159 | ); |
| 160 | } |
| 161 |